Communication between a dozen arduinos I2C, Ethernet, Bluetooth, Wireless

So I have a project that will require about 13 arduino megas and I'm trying to determine the best way to have them all communicate. They will all be communicating with an SQL database as well.

I know I2C is an option, but if I've researched it correctly it can only have 112 pins used total, which this project is going to require 648 pins. I'm sure I could pyramid them up to have one master but I'm not sure that's the best option. Also is it possible to set up one arduino as both a slave reader and slave writer (different pins obviously)?

I also don't know about using wifi or bluetooth, but if those are my only options then that'll have to work.

Is connecting all of them to an ethernet switch a possibility?

Thanks in advance for any advice :slight_smile:

Bluetooth is hardly an option here, it is best used one-to-one with a device in the outside world - like your phone. An NRF24 network makes more sense. The performance and price is about the same as Bluetooth, but it is made for the job. WiFi may well be an option, as an ESP8266 can be as cheap as Bluetooth, is suitable for a local network, and can communicate with the outside world as well.

BrayleeNicole:
So I have a project that will require about 13 arduino megas and I'm trying to determine

This is a typical start of X-Y Question.

Please explain your idea. What do you want to achieve?
648 Pins? What kind of "Pins"? How many inputs, How many Outputs?
Digital, Analog? There are lot of addressable chips out there which will do that job better than arduinos.

What's the distance you want to span between your "pins"? mm,cm, m, (km)?

noiasca:
This is a typical start of X-Y Question.

Please explain your idea. What do you want to achieve?
648 Pins? What kind of "Pins"? How many inputs, How many Outputs?
Digital, Analog? There are lot of addressable chips out there which will do that job better than arduinos.

What's the distance you want to span between your "pins"? mm,cm, m, (km)?

Long explanation short it's a weight based inventory system for a large cabinet that has 162 bins.
Each bin would have a load cell (and an HX 711 board) as well as an RGB LED.
Each Arduino would handle 15 bins, so 30 output pins for PWM (the analog pins can be converted to work for that purpose) and 30 digital input pins from the HX711 boards.
The max distance for a load cell to an arduino would be just under 2 meters.

Nick_Pyner:
Bluetooth is hardly an option here, it is best used one-to-one with a device in the outside world - like your phone. An NRF24 network makes more sense. The performance and price is about the same as Bluetooth, but it is made for the job. WiFi may well be an option, as an ESP8266 can be as cheap as Bluetooth, is suitable for a local network, and can communicate with the outside world as well.

Thank you for your insight :slight_smile:

BrayleeNicole:
Each Arduino would handle 15 bins, so 30 output pins for PWM (the analog pins can be converted to work for that purpose)

If you mean PWM as produced by analogWrite() then that can only happen on the PWM pins.

If the Arduinos are all close together why not create a Serial BUS. If you connect as in this image several CHILD Arduinos can be connected to one PARENT. The PARENT will decide which CHILD should speak (unlike in real families :slight_smile:

arduino.png

Image from this Thread

...R
Simple nRF24L01+ Tutorial

Depending on the desired sample rate, you could probably do all of the measurements with only one arduino using one PWM pin and one analog input. This is possible if you multiplex both the PWM output and analog input pins across all load cells.

Just a thought - might save you a TON of effort.

Robin2:
If you mean PWM as produced by analogWrite() then that can only happen on the PWM pins.

If the Arduinos are all close together why not create a Serial BUS. If you connect as in this image several CHILD Arduinos can be connected to one PARENT. The PARENT will decide which CHILD should speak (unlike in real families :slight_smile:

arduino.png

Image from this Thread

...R
Simple nRF24L01+ Tutorial

I have thought about it and it is a possibility, but some arduinos could be kinda spread out if the cabinet doors are open and that's the only thing worrying me about this method.

Power_Broker:
Depending on the desired sample rate, you could probably do all of the measurements with only one arduino using one PWM pin and one analog input. This is possible if you multiplex both the PWM output and analog input pins across all load cells.

Just a thought - might save you a TON of effort.

So I'm gonna look this up in a little bit, but am I understanding right that I can program all 600+ pins on only two physical pins and everything would still be able to differentiate between each bin and led?

when we assume to have 13 Arduinos, one for 15 bins, what's the distance between from one Arduino to Arduino, and what's the largest distance from one to one (e.g. from the first Arduino to the last in the chain?).

BrayleeNicole:
, but some arduinos could be kinda spread out if the cabinet doors are open

What would be the max distance between a CHILD and its PARENT?

...R

BrayleeNicole:
So I'm gonna look this up in a little bit, but am I understanding right that I can program all 600+ pins on only two physical pins and everything would still be able to differentiate between each bin and led?

Yes, you would need a few muxes - but still very possible. Don't forget that you'll need a few pins (not a lot) to control the muxes. You can use muxes for both inputs and outputs. That being said, you can't mix and match inputs and outputs on the same mux, if that makes sense.

Here is a good tutorial on multiplexing

As for the analog muxing, you'll need a special "analog" mux (i.e. https://www.amazon.com/16-Channel-Analog-Digital-Breakout-CD74HC4067/dp/B0183KFEZE)

noiasca:
when we assume to have 13 Arduinos, one for 15 bins, what's the distance between from one Arduino to Arduino, and what's the largest distance from one to one (e.g. from the first Arduino to the last in the chain?).

So I'm pretty sure the max distance will be 6 ft

Robin2:
What would be the max distance between a CHILD and its PARENT?

...R

I'm pretty sure it's 6 ft. The doors (1.5' wide each) each have 4 children and the center (3' wide) would have 4 children and 1 parent.

Power_Broker:
Yes, you would need a few muxes - but still very possible. Don't forget that you'll need a few pins (not a lot) to control the muxes. You can use muxes for both inputs and outputs. That being said, you can't mix and match inputs and outputs on the same mux, if that makes sense.

Here is a good tutorial on multiplexing

As for the analog muxing, you'll need a special "analog" mux (i.e. https://www.amazon.com/16-Channel-Analog-Digital-Breakout-CD74HC4067/dp/B0183KFEZE)

Awesome, thank you so much. I'll definitely look into this option. :slight_smile:

BrayleeNicole:
Awesome, thank you so much. I'll definitely look into this option. :slight_smile:

Also, you may need layers of muxes if you're talking about 600+ signals. As in you might have 30 muxes that touch the sensors directly, then feed 15 of those mux outputs to an extra mux, and the last 15 to another mux. Then feed the output of both those muxes to their own analog input pins.

In the above case, you would need 32 muxes to monitor 450 signals. However, for 31 muxes you need about 128 digital pins to select the desired channel for each mux. You might consider using a shift register to control such a large number of digital I/O without having to add more Arduinos.

Now that I think about it, a hybrid approach might be best:

  • have 3 or so Arduinos close together in a single enclosure
  • each Arduino will have two layers of muxes
  • each Arduino will communicate to a master Arduino via serial (Shameless plug)
  • master Arduino will have a user interface (user defined - web, lcd, etc)

This approach is both feasible and scaleable

Muxes layered like that will yield inconsistent results.
I would prefer to see you use multi-input A/D chips, like MCP3208.

You can use the shift register idea to make all the chip selects needed, just need 3 pins to drive a long string of them.
Then 3 pins connected to all devices in parallel - SCK, MISO, MOSI, with some signal buffering.
This way the analog signals only see one mux and fast ADC converter each, vs 3-4-5 layers of muxes before seeing and ADC.
Data is converted fast and passed along at fast SPI speeds, vs going thru layers of muxes and converted by a slow ADC int the Uno/Mega.
The 8-channel muxes can be distributed to be near the analog sources, vs running analog sources where ever and picking up who knows what kind of external noise on the way.

BrayleeNicole:
I'm pretty sure it's 6 ft. The doors (1.5' wide each) each have 4 children and the center (3' wide) would have 4 children and 1 parent.

That should be well within the range of a wired serial connection.

...R