-->
Page 1 of 1

Changing a slave's i2c address

PostPosted: Wed Feb 20, 2019 4:58 pm
by jak888
Hi all,

Not strictly ESP8266 related, but here goes:

I am developing a piece of hardware, that has one master and many slaves on an i2c bus. I want to implement some sort of auto addressing on the i2c, so I have a relais that interrupts the i2c connection to the next module.
On startup, the slave takes address 127, and gets its address from the master on that address. I noticed that the Wire library does not offer an end() method, so I'm wondering how I can change the address and what happens if I just call the begin() method again with the address?
Calling begin() twice seems to compile and run just fine, but will it:
listen on both its address and 127, just its address or just 127?

Unfortunately, I don't have any hardware to test that out yet.

Also, if there's a better way of auto addressing, I'm happy to hear it.

Thanks in advance for you input!

Re: Changing a slave's i2c address

PostPosted: Sat Feb 23, 2019 8:19 am
by theenggprojects
Yeah you can easily change the I2C addresses of your slaves. You can also assign some specific I2C address from master to your slave. IF you don't have the hardware then download Proteus software. It has I2C components which you can interface with Microcontrollers like Arduino UNO or Nano and can test it out.