Creating a custom “communication protocol” between 2 particle devices via I2C, one acting as a slave(photon) and one as a master(argon), I was lead many times reading invalid values (value 0x31). Specifically, when I try to read from the master, and the slave lags behind I usually get this value (which is not present in the data that I send, but its not random as well). In conclussion I read invalid bytes when it seems that master can read, but actually the slave doesn’t send anything or writes slowly. Does anybody observed something similar?
Update: I did some more digging around. The slave address I was using is 0x18, which, as I understand, is shifted to the left (x2) and the last bit is (0 for write 1 for read). Thus when I try to read from the slave I send the 0x18 << 2 | 1 = 0x31. Tried with different address (0x19) and I read 0x33. So now it seams that the master reads back the read command from the I2C Bus instead of reading the data sent by the slave.