-1

For example; I'm measuring my body temperature. The value I read is (tP [2] + tP [3] * 256) = 182 or 181. Because MSB bytes always come at 0. But sensor body temperature is OK, not wrong.

bus.write_byte(DEVICE_ADDRESS, 0x02)
bus.write_byte(DEVICE_ADDRESS, 0x00)
bus.write_byte(DEVICE_ADDRESS, 0x01)
bus.write_byte(DEVICE_ADDRESS, 0xEE)

bus.write_byte(DEVICE_ADDRESS, 0x05)
bus.write_byte(DEVICE_ADDRESS, 0x90)
bus.write_byte(DEVICE_ADDRESS, 0x3A)
bus.write_byte(DEVICE_ADDRESS, 0xB8)

bus.write_byte(DEVICE_ADDRESS, 0x03)
bus.write_byte(DEVICE_ADDRESS, 0x00)
bus.write_byte(DEVICE_ADDRESS, 0x03)
bus.write_byte(DEVICE_ADDRESS, 0x8B)

bus.write_byte(DEVICE_ADDRESS, 0x03)
bus.write_byte(DEVICE_ADDRESS, 0x00)
bus.write_byte(DEVICE_ADDRESS, 0x07)
bus.write_byte(DEVICE_ADDRESS, 0x97)

bus.write_byte(DEVICE_ADDRESS, 0x02)
bus.write_byte(DEVICE_ADDRESS, 0x00)
bus.write_byte(DEVICE_ADDRESS, 0x00)
bus.write_byte(DEVICE_ADDRESS, 0xE9)

a = bus.read_i2c_block_data(DEVICE_ADDRESS, 0x05, 2)

b = bus.read_i2c_block_data(DEVICE_ADDRESS, 0x03, 2)


readbuff = bus.read_i2c_block_data(DEVICE_ADDRESS, 0x4C, 19)
bus.close()

tPTAT = 256 * readbuff[1] + readbuff[0]
tP[0] = ((readbuff[3] * 256) + readbuff[2])
.
.
tP[7] = ((readbuff[17] * 256) + readbuff[16])
tPEC = readbuff[18]
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
ARZU
  • 1
  • 1

1 Answers1

0

As per the datasheet of D6T-8L:

reference_temprature = 256*readbuff[1] + readbuff[0];
int i = 0;
int j = 0;
for( i = 2; i<16; i = i +2) {
   temprature[j] = (256*readbuff[i+1] + readbuff[i])/10.0;
   j++;
}
packet_error_check = readbuff[i];

Please follow the reference circuit from datasheet and validate the PEC. Here is another code sample: Github

Shivendra Mishra
  • 638
  • 4
  • 25