Using popular Pressure, Temperature sensor LPS25H
and Circuits.I2C
Seems I either don’t understand the Circuits.I2C API or don’t understand the I2C sensor device
My code has to do single-byte register transfers rather than reading 3 sequentially addressed registers to get the latest Pressure value : e.g. for device at bus address 0x5d
and the LSByte of the Pressure value in Register 0x28
this is what I see :
Read each byte value seperately
iex(fb2@fb2-e53f.local)24> Circuits.I2C.write_read ph_ref, 0x5d, <<0x28>>, 1
{:ok, <<241>>}
iex(fb2@fb2-e53f.local)25> Circuits.I2C.write_read ph_ref, 0x5d, <<0x29>>, 1
{:ok, <<190>>}
iex(fb2@fb2-e53f.local)26> Circuits.I2C.write_read ph_ref, 0x5d, <<0x2a>>, 1
{:ok, "?"}
Try reading the 3 registers in one go
iex(fb2@fb2-e53f.local)28> Circuits.I2C.write_read ph_ref, 0x5d, <<0x28>>, 3
{:ok, <<241, 241, 241>>}
iex(fb2@fb2-e53f.local)29>
Thanks !