Wire.write(0x04) // select starting register with "write()" Wire.beginTransmission(DEVICE_I2C_ADDRESS) // select device with "beginTransmission()" Typical I2C read from a selected start register goes like that for reading two bytes from register 0x04 and 0x05: #define DEVICE_I2C_ADDRESS 0x5A // this must be the I2C bus address of your device You will have to select the register by using a write command. for example, the i2c slave's address is 0x5A, the code Wire.requestFrom(0x5A,2) can read two 8-bits data from slave 0x5A, from the register address ox01 and 0x02.īut i want to read data from register address ,such as ox04, directly? how should i do? The method Wire.requestFrom(address,numberofdata), the address is the slave's address, it is not the slave's register's address.
0 Comments
Leave a Reply. |