Mega I2C

I need to communicate 7 Arduino Megas over approximately 3m. All 7 Megas are at different common mode voltages.
I thought of using optocouplers and a 12V bus to isolate the arduinos.

Can this work? any comments/advice?

KerneelsM:
All 7 Megas are at different common mode voltages.

What does that mean? AFAIK all Megas work at 5v.

…R

3m is likely to be too far for I2C, it is means Inter-Integrated Circuit so very close by.

You could use ethernet - though that would mean a shield on each one or maybe RS485 though again that would also require more hardware.

Is it six to one, or is it seven to seven?

Are you aware of this and would it suffice?

Just one example, there will be others.

Use regular Serial, say Serial 1.
Master TX1 → slave1 Rx1,
slave1 Tx1 → slave2 Rx1,
slave2 TX1 → slave3 RX1,
slave3 TX1 → slave4 RX1
slave4 TX1 → slave5 RX1
slave5 TX1 → slave6 RX1
slave6 TX1 → slave7 RX1
slave7 TX1 → master RX1

Each one reads the message; if not intended for it, it passes it to the next.
If it is, it sends an ACK with its address, and whatever data needs to go back.
The following devices all pass the message along as it is not for them. Eventually the master sees it.

Could even do a global message each slave gets it and passes it along with a bit in the global ack message to show it got it.

countrypaul:
3m is likely to be too far for I2C, it is means Inter-Integrated Circuit so very close by.

This MegaPoints YouTube Video shows I2C working over 100m of cable. The MegaPoints boards use Atmega microprocessors.

I would be surprised if there is a problem at 3m. What's the difference between I2C and TTL serial?

...R

As Robin2 shows, longer distance comms are possible but it appears that the longer the distance between nodes the lower performance as far as I can tell.

Long distances do appear possible, but care has to be taken with the selection of the wire to be used etc.

I think TTL serial does not use a clock and has recieve and transmit on seperate lines, where as I2C does use a clock and has a single line for recieve and transmit boh have a seperate gound line.

I have 98 4V cells in series connected to a charger.
A group of 14 cells is measured by one Mega. Each mega has its own regulator to supply the mega with 8V (which itself regulates down to 5V)
This means there are 7 megas each measuring a group of 14 cells. Each supplied by a regulator (running off its group of 14 cells) supplying it with 8V.
This means that mega one is connected from 0V to 58V (supply regulated down to 8V). The next is connected from 58V to 116V (its supply regulated down to 8V). The next is connected to 116V to 174V. etc...

This means each mega runs off 58V. But the next runs off the next set of cells sitting at a different common mode voltage.

Now in this case one cannot use normal serial since they runs off the same ground line.
In my case there are 7 different ground lines that cannot be connected together since this will short a group of 14 cells.

Therefore I need an isolated communication bus where each mega is completely isolated from the next. There is no common between each mega. So normal serial will not work.

I don't know enough about I2C to know whether it would work through opto-isolators. My guess is that the fact of the single communication wire for 2-way comms would present a problem.

I see no difficulty in using opto-isolators for regular Serial communication as the Tx and Rx lines are separate. You could organise things so that a Master Arduino communicates with the others as Slaves. If the Master controls when the Slaves speak that can all happen over a single Serial connection on the master. This diagram shows how the slaves can be connected to the Master Rx.

R2-multiTX.jpg

There is no problem connecting the Master Tx directly to several slaves.

Another option would be wireless communication using nRF24L01+ modules. This Simple nRF24L01+ Tutorial may give you some ideas.

...R

I thought I2C requires a common ground similar to serial.

By the time you have implemented opto-isolators for serial or I2C I think I would be looking at either Robin's wireless option using the nRF24L01+ modules, or a Wifi solution maybe using a ESP8266 on each Mega with 6 acting as stations (STA mode) and one acting as an AccessPoint (AP mode) - this latter one could also connect to another AP if you wanted to get data onto another device such as a PC.

countrypaul:
I thought I2C requires a common ground similar to serial.

It does. But I2C uses two wires (including GND) whereas Serial uses three.

...R

Robin2:
It does. But I2C uses two wires (including GND) whereas Serial uses three.

...R

But surely I2C uses Serial Data (SDA) plus the clock (SCL) so the ground is a 3rd wire like serial?

Yes, SDA, SCL, Gnd = 3 wires.

try RS485 with isolated transmitters

countrypaul:
But surely I2C uses Serial Data (SDA) plus the clock (SCL) so the ground is a 3rd wire like serial?

Yes. My mistake.

The difference is that Serial uses two of the lines for data whereas I2C uses a single line for data in both directions. Serial does not have a clock line.

...R

They do sell I2C repeaters/isolators which may be a possibiity, and rs485 isolating drivers are available.

Wha sort of environment will this be in? Industrial with large motors around? Domestic with next to know external interference? Somewhere between with low/high interence?

Countrypaul,
This is in a solar system application where there under normal operation conditions there are no big motors around. The initial application is for residential use but eventually does not rule out industrial use.

I am interested in the I2C repeaters/isolators. Can you give some part numbers?

I need the isolation since the Arduino Megas are at different common mode voltages and a 'Common' common is not possible. The commons are all at different voltages is steps of 58V.

noiasca,
I am also considering RS485. Do you have any part numbers for the isolated drivers?

I have not used I2C repeaters/isolators, but I happened to spot they were available, so don't take that as a recommendationor even assume they are suitable for you application. There may be easier ones to solder too!

https://uk.rs-online.com/web/p/digital-isolator-ics/7532309?cm_mmc=UK-PLA-DS3A--google--PLA_UK_EN_Displays_%26_Optoelectronics_Whoop--Digital+Isolator+ICs_Whoop--7532309&matchtype=&aud-827186183686:pla-338837313498&gclid=EAIaIQobChMIuaKskdry6wIVU-btCh2HcA6aEAQYCiABEgL9DfD_BwE&gclsrc=aw.ds

As for RS485 - I would look through some of the other topics in this forum and see what others are using/recommending, or even just start a new topic and ask for recommendations.

Thanks to you all.

It looks to me as RS485 is the correct way to go. I found some isolated RS485 drivers from Texas Instruments and it looks good.

Thanks again.