I2C write more than one byte of data


#21

Sorry for leaping in, but Hugo is travelling today. The sequence "\x02\x00\x01\x40" is 0x02 for read, 0x00 for the start address, 0x01 for the address increment, and 0x40 for the number of reads (64). See p31 of the datasheet.

Yes, you send as a string the data the component (whatever it is) expects. In this case that’s the command plus three bytes of data, but it might just be a register address, a different comment, or an address plus further data. The crucial thing is that you just provide a string of the bytes and impOS does all the work sending in in the correct way.


#22

Thanks smittytone,
If you can take a quick look at the code i sent in previous post and tell where I am doing wrong, It will be very big help.


#23

That command looks correct (per the datasheet), however, looking at the configuration register docs (section 8.2.2.1) it seems like 0x3e46 is not a valid value to write to this register (ie, the example is wrong)

In particular, bit 13 is “1” here. The docs say it must be “0”.

If the value sent is instead 0x1e46 you will set 400kHz I2C (correct), step mode (?), 15 bit ADC and 256Hz refresh.

That’d be a write of

i2c.write(0x60 << 1, "\x03\xc9\x1e\xf1\x46")

#24

…any update? Seems like, from my reading, there was a doc issue here.