6

I am building a bunch of slave devices (Arduinos) that operate autonomously, but will report data back to a single raspberry pi and update their clocks from the pi's time.

I've only worked with one arduino using serial, but I would imagine that 20 arduinos needs a special solution. I don't know how to split serial, but I've also considered SPI and I2C. Would either of these be the way to go?

Given that there are 20 units, I don't think I should go with wifi as I fear there would be loss of connectivity often. I prefer a hardwired method.

EDIT: Also, these arduinos won't be close to each other. They will be spread out, no more than 30 feet from the pi.

asked Apr 8, 2016 at 15:18
9
  • I2C works with 20 slaves. With SPI you'd at least have to use some generic GPIO pins as address lines. Both should do. Commented Apr 8, 2016 at 15:28
  • @Ghanima can data be written in both directions? Can the slave report 'all good' or 'error on pin 1', for example? Also, the furthest arduino will be 30 feet from the pi. Commented Apr 8, 2016 at 15:49
  • 1
    You will probably have trouble running 20 30ft I2C connections. I2C likes to have very-low capacitance on the clock and data lines. See electronics.stackexchange.com/questions/106265/… . There are nuances to different electrical topologies as well e.g. ring vs star. Commented Apr 8, 2016 at 18:12
  • 2
    As per the last comment you would probably get better connectivity via wifi, not worse. Commented Apr 8, 2016 at 18:23
  • 1
    I think you need multipoint bus such as RS-485 or CAN. You could use I2C with P82B96 or similar buffer IC as well. Commented Apr 9, 2016 at 0:21

4 Answers 4

0

schematic

simulate this circuit – Schematic created using CircuitLab

I2C will be just fine, but don't forget to apply a power and use diodes to ensure a proper power flow

answered Apr 8, 2016 at 20:26
10
  • You might want to explain that diodes part. Commented Apr 8, 2016 at 21:08
  • @Ghanima three diodes per power line (+ and -/gnd) Commented Apr 8, 2016 at 21:10
  • Let me rephrase my question: why? Commented Apr 8, 2016 at 21:12
  • @Ghanima I had some cases in I2C "long chains" when the I2C master's VCC was not enough to properly power it all on, discovered just by an experiment adding slaves one by one. The problem is that an external PSU must have the same GND with master(RPi) and the diodes to prevent SoC from frying - there are some precedents not only with RPi Commented Apr 8, 2016 at 21:19
  • 2
    What on earth is "I2C VCC" supposed to be? I²C has 2 open-drain data lines with pullup to supply voltage. The Pi has on-board pullup. Commented Apr 9, 2016 at 1:31
1

I'd use Wifi and sockets. It's relatively simple to use Qt (or even plain C++) to implement a multi-connection client/server. There are lots of tutorials on the net.

answered Apr 8, 2016 at 19:50
1
  • I looked that up, but that looks like it may be overkill for the small amount of data that I'll be sending. It looks like I'd have to develop my own software in C++ for the networking vs using a library for I2C Commented Apr 8, 2016 at 20:44
1

You should be able to use I2C over these distances with careful layout. I would suggest you use the slowest I2C speed (although the Pi default is already 100kHz). You should also use a bi-directional level converter at the Pi end as the high level would otherwise be marginal for the Arduino.

answered Apr 9, 2016 at 1:53
1
1

A wired solution would be to use RS-485. You can connect many devices on a single twisted wire (two wire) cable. There is an good example at https://arduino-info.wikispaces.com/SoftwareSerialRS485Example. The modules shown are really cheap. I see vendors having 5 of them for 7.99. You can also use a USB to RS-485 dongle on the Raspberry Pi.

answered Apr 14, 2016 at 18:55
2
  • More detail is needed. The link might provide the answer, but the essence of what is on the webpage needs to be included in your answer. Commented Apr 14, 2016 at 19:12
  • So I guess I would just put two wires into each screw terminal if I want to link them with more than 2 arduinos, correct? This won't affect the signal? Commented Apr 14, 2016 at 19:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.