4

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
    Why not just use USB? – Steve Robillard Feb 21 '16 at 18:42
  • Why not just use serial? – PNDA Feb 22 '16 at 9:57
  • I would use serial however how would I connect with the other 2 arduinos using just 1 port? the whole idea is to not use USB and have the arduinos powered by external means because the pi is already using all 4 usb ports for other things – linuxgnuru Feb 22 '16 at 10:07
  • You could, in theory, attach an unlimited number of Arduinos to the single serial port and use an identifier "header" (e.g. ;;;;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. – PNDA Feb 22 '16 at 10:27
  • 1
    If you were willing to consider non-wiringPi solutions my pigpio allows for software serial on arbitrary GPIO. You could probably get SPI to work (PI would have to be master, Arduinos would have to be slaves, you would need to bit bang the slave select lines) but I don't think you would find it a particularly interesting experiment. – joan Feb 22 '16 at 14:27
1

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.

SPI Multi Slave

Master with daisy chained slaves: More scalable (adding slaves will not use additional pins) but will get more complex in operations.

Daisy Chained Slaves

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)

ESP8266+Arduino

Star Topo

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? – crishoj Apr 24 '16 at 8:09
  • 1
    @crishoj I don't, but it will not be hard to code one or find one on the internet. – Chetan Bhargava Apr 24 '16 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.