2

I am planning to connect multiple Arduinos to my Raspberry Pi. There are basically two ways I can achieve that:

  1. Use an USB hub. Each Arduino will then be available through ordinary serial commands both for reading and writing. The USB hub I have is powered and can handle both communications and powering the Arduinos.

  2. Use I2C, so that the Arduinos are I2C slaves of the Raspberry Pi.

Since USB is used for updating the Arduino, I don't have the best feeling about using this same connection for "management" tasks.

Are there any known disadvantages to using the pre built USB socket on the Arduino in "production", any best practises or similar saying that I should not do this? Is this USB socket meant to be used for debugging and code deployment only?

The plan is to let the computer send commands to the Arduinos using a serial protocol. The computer will automatically detect whenever an Arduino is connected and immediately send a "hello" command over serial. The Arduino is then supposed to send back its "name" and a list of capability keywords. A capability may be "motion-sensor". The computer will then know that it can ask the Arduino if it has detected motion. Other capabilities may be "temperature-sensor", "barometric-sensor", "lights".

It's for a generic open source home automation system/robotics system I am working on creating a framework for.

  • 1
    Personally, I'd look at using a bused asynchronous serial scheme, a bit like RS485 but perhaps without the differential drivers/receivers if the distances are short, since you can software tri-state the ATMega's serial output pin. If you either use soft serial or bare ATmegas without the USB interface chips (or pull the series resistors to isolate them), this means the only hardware you need is a piece of wire - no hubs, no muxes, etc. Actually, this would work best with Leonardo's where you have the USB interface for programming and the hardware serial free for coms. – Chris Stratton May 28 '14 at 3:29
1

One complication you should be aware of is that in its default configuration, an Arduino Uno (and I assume that is what you’re talking about) will automatically reset whenever a serial connection is opened to it. This is easily bypassed with a capacitor between RESET and GND, but not taking it into account might make for hours of debugging fun.

The other complication is that just after a power up or RESET, an Arduino will delay for a second or two to listen for a programmer connection on the serial port, but that’s something you’ll have to take into account anyway.

0

I would go with USB rather than I2C for these reasons:

  • The Arduino can be powered via USB so there is no need for extra power supplies.
  • The system will work with PCs, making it easier to develop the code and the product more versatile.
  • USB cables are commercially available with standardised sockets. I2C cables would have to be made to specification (e.g. this app note) and would require some kind of additional socket for robust termination.
  • The Arduino Wire (I2C) library will hang if you disconnect the cable in the middle of waiting for a byte.

A good product will be robust and easy to use. One thing you may wish to consider is to create an internet of thing (IoT) type system. This involves the Arduinos sending sensor data to the web via the RPi. It could be that the RPi is a dumb conduit for the Arduinos, or it could collate the data and present itself as the end device. Check out Xively for details. I made a basic system to do the former, it is on github here.

  • The plan is to make a web app framework so whenever you hook something into a computer and that computer is running this software, the arduinos will add them self to the UI. – frodeborli May 27 '14 at 15:53
0

In my opinion, think USB on the Arduino is stable enough for production use.* There are ways to rename your Arduino if someone would connect it to a computer.

I think the real problem with this approach is people tampering with it. I know it's open source and all, but do you really want users (if it does get produced on a big scale, which is unlikely, but possible) without much tech knowledge plugging it into their computer?

If none of that sounds like a problem to you (and the delay/reset problems outlined by others isn't a big deal), I'd say go for USB. It's pretty easy to use, and it's universal, thus someone could connect the system to their computer if you developed the software for PC.

*Assuming you're using a full Arduino in a production environment, you won't care about if it shows up to the computer as "Arduino Uno."

  • This is an open source project so being open for tampering is no problem whatsoever. I want people to take the framework and make their own stuff. – frodeborli May 27 '14 at 15:51

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.