I have 3 arduino's each with 6 LDR (light sensors) for a total of 18 analog inputs giving 0 to 1023 of data. What I'd like to do is to get all 18 sensor data from each arduino within 1 second. I have something up and running (all in C with wiringPi) with 1 arduino, but 1) the data is all 8 bit which doesn't help and 2) no idea how to add multiple arduino devices. This isn't for any real project, just something I'd like to try.
1 Answer
By looking at your question, it seems that you are trying to gather light data from multiple Arduino boards and using Raspberry Pi as collection (and may be reporting) point.
SPI specification has no set length limitations but when run a few meters apart, it is susceptible to EMI/RFI, cross-talk, slew rate issues. Assuming your Arduino boards are far apart, you need a differential pair bus like RS485, RS422, etc.
To answer your question in simple words yes, you can use SPI to communicate between 3 or more Ardunino boards contingent to proximity between your nodes.
Master with three independent slaves: Simple in operation but limited to the GPIO pins required for each SS. Each additional slave will require one additional Slave Select pin.
Master with daisy chained slaves: More scalable (adding slaves will not use additional pins) but will get more complex in operations.
Is, it recommended to use SPI to communicate over a long distance, No!
My recommendation will be to use ESP8266 modules with Arduino boards and transmit the data over WiFi and collect using Raspberry Pi Ethernet (or WiFi interface)
Referencing the star topology diagram above, your blue spheres can be Arduino boards, red disc in the middle can be Raspberry Pi and yellow segments will be your WiFi link to Raspberry Pi.
-
Do you have a reference to a working example of daisy chained slaves?– crishojApr 24, 2016 at 8:09
-
1@crishoj I don't, but it will not be hard to code one or find one on the internet. Apr 24, 2016 at 20:29
;;;;IDxxxyyyzzz,[data];;;;
, where;;;;;;;;
is a "separator" between packets and asks all the Arduinos to check if the next packet's ID is theirs then act accordingly). That's basically how SPI works. Let me know if it's an answer.