I2C Adressing issue

Hello :o ,

We are developing a master control panel setup which is connected to about 5 lamps with each of them having an Arduino Nano each (dist max 100 cm).

The control panel acts as the Master and the lamps are slave devices with a unique address. We are running into issues when it comes to having a unique address on the slaves.

For Example: What if we made a 1000 lamps (slaves), we would run-out of unique addresses post the number 127. Our goal is to have a custom ID or address such as ABCD0001 and use this ABCD pool till ABCD9999. This way random 5 lamps from the 1000 can be connected to the master via I2C and all 5 will have unique addresses.

Summary: IS THERE ANYWAY TO HAVE CUSTOM ADDRESSES (8 chars long at-least) HARD-CODED ONTO MY SLAVE DEVICES ? 8) 8) 8)

According to wikipedia, I2C does have a 10 bit addressing mode. I expect you would need to tweak the library to use it, or at least find one that someone else has done.

Alternatively, give every nano the same address and use I2C to send messages on the bus that contain your ABCD addresses and a command for on or off.

8 character I2C address, no.
8 character identifier, yes.

Your master needs to query each slave to get its identifier which it then associates with the I2C address.

For Example: What if we made a 1000 lamps (slaves), we would run-out of unique addresses post the number 127. Our goal is to have a custom ID or address such as ABCD0001 and use this ABCD pool till ABCD9999. This way random 5 lamps from the 1000 can be connected to the master via I2C and all 5 will have unique addresses.

A 1000 lamps at a distance of about 1m between lamps results in a 1km I2C bus. At standard speed (100kHz) the maximum bus length is about 50cm. If you decrease the speed significantly you may get a few meters to work but your expected length is out of reach.

Forget I2C, change to RS-485 or something similar which is designed for such bus lengths.

I think his intent is to have only five lamps connected, out a pool of a thousand. Can't imagine why though.

wildbill:
I think his intent is to have only five lamps connected, out a pool of a thousand. Can't imagine why though.

The idea is to have several slave devices manufactured with a unique ADDRESS, so no two devices will have the same ID. Example I2C sensors cannot be connected to the same I2C data line if they're address is identical to each other, then there would be a conflict.

Our goal is have several slaves with a unique address and then you can plug and play the slave device onto the I2C bus since no two devices will have the same address

mikb55:
8 character I2C address, no.
8 character identifier, yes.

Your master needs to query each slave to get its identifier which it then associates with the I2C address.

This seems super feasible, we can dynamically change the address according to the identifier. I assume the identifier is a unique char set of some sort it can send back to the master, but the question lies if two devices with the same address are connected to the BUS, then how do you identify the conflict and make their address unique?

vikramnayak:
This seems super feasible, we can dynamically change the address according to the identifier. I assume the identifier is a unique char set of some sort it can send back to the master, but the question lies if two devices with the same address are connected to the BUS, then how do you identify the conflict and make their address unique?

Not possible. I2C is not designed as a plug and play system. You have to manually set the I2C addresses to avoid conflict.

If you want plug and play then you need to look at more complex systems such as an IP networking with MAC addresses and DHCP.

Yes, you are asking for 64 bits of addressing. This will get into some very complex hardware, and with the 100 Cm length you may have to add signal buffering chips, TI makes them for the I2C buss buffer designed for long lines. What I would recommend is changing the physical layer from I2C to either RS485 or a simple single wire bus. All would work with a serial protocol of some type. The RS486 would be great for several thousand feet. In your case I would suggest a simple 1 wire buss. You can use the software serial to drive the buss. For the bus connect a avalanche rated N-Channel MOSFET Gate to the serial output pin (with software serial you define it). Connect the Source to the Ground, The output becomes the Drain pulled up with maybe a 10K resistor. On the receiving end you need an inverted with a high impedance input. You can use a SN74AHC1G14 Schmidt inverter, a 74HC14 will work, it just has 5 extra gates. At the input of your board Put a 27K pull up resistor, then connect the input of the board to the input of the gate, the output of the gate becomes the serial to the arduino. This should work to at least 20 meters depending on baud rate. Care on the input pull up devices, you may have to recalculate them when you get more then maybe 6 receivers on line. You can also use the inexpensive RS485 boards, maybe $1.00 each. Just hardware enable them to receive for the remotes and transmit on the master. Once you have the physical layer working there is a lot of code available to send & receive data via the serial port.This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil