And the datasheet states i can change the device's i2c address with the sequence : 0xa0 0xaa 0xa5
sent to the control register 0x00. I have tried for hours to get this to work, every combination I can think of but the address wont change.
I have one device hooked up to the serial bus, I run i2c scan, it gives me address 0x5a, then I run a variation of this code:
Then i run the i2c scan again with no change in address, I have tried every combination of this I can think of; doing it all at once with no breaks in-between, not stating a new address, tried a bunch of different new desired addresses. I checked the error codes for the return values of Wire.endTransmission() and the other's and they are all returning 0's which means successful transmissions...
Any other suggestions? I have thought about a multiplexer but It's a project for university and I'm already over my budget so I'm really hoping to find some other way around it. I've read up about "switching" the clock and some other wires to trick one of the devices into discarding the communication, I couldn't find any real guide on this however and I'm not the most hardware savvy.
First of all: the documentation could be wrong or outdated.
At least that documention is very confusing. It uses some kind of serialI2C code, which seems to add extra. The documentation itself is confusing. They say it is just like the 24C04, that is chip is very simple.
The I2C address is 0x5A. The register address of the control register is 0x00. The sequence of 0xA0, 0xAA, 0xA5 makes no sense at all. How should those bytes be used ? I think that is the sequence for the weirdo-nutty serialI2C.
Let's write the new address to the control register.
Connect just one of those modules to the Arduino.
Wire.beginTransmission(0x5a);
Wire.write(0x00); // control register
Wire.write(0x34); // new address
int error = Wire.endTransmission();
Serial.print("Error=");
Serial.println(error);
The error should be zero (no error). After that, unpower everything. And after that run the i2c_scanner. Is it at 0x34 ?
The new address is used when it starts, so I assume that it is stored to an internal eeprom.
I think the address must be above 0xA0 (unshifted), that is 0x50 (shifted).
Could you try again with a number above 0x50 ? Be sure to unpower it.
Sometimes a register is a 16 bit register. Perhaps that should be used.
The Control register has no bits, but it accepts commands. Perhaps 0xAA is the command for a new address.
A test with the control register as 16 bit register or with a command:
Wire.beginTransmission(0x5a);
Wire.write(0x00); // control register
Wire.write(0xAA); // command
Wire.write(0x66); // new address
int error = Wire.endTransmission();
Serial.print("Error=");
Serial.println(error);
The address seems to be 0x80 now, I could investigate into why this works but I'm a tad scared to try. If anyone runs into this from google try it this out.
It works ? Amazing. You send three commands to the control register in three seperate I2C transactions, command 0xA0, 0xAA and 0xA5, followed by the new I2C address.
And they all three are commands ? and you don't have to enter the old I2C address ?
That could be according to the (very limited) description.