I have followed the M8 temperature/humidity tutorial. And now I'm getting temp & humid readings:
"sh31_temp": 35.6306
"sh31_humid": 26.1173
The problem I have is that the temperature is reading about double what it should be and humidity is less than half what I think it should be.
Ideas/solutions/observations would be very welcome.
It's not clear why that's happening. If there was a data communication error the CRC check would fail. It's possible that the formula in the library is incorrect, but it seems to have worked properly in the past and hasn't been touched in 4 years.
int Sht3xi2c::pr_get_reading(double *temp, double *humid)
{
_wire->requestFrom(_i2c_addr, 6);
if (_wire->available() != 6)
{
return SHT31_I2C_ERROR;
}
uint8_t ts[2], rh[2];
ts[0] = _wire->read();
ts[1] = _wire->read();
*temp = -45.0+(double)(175.0*((uint16_t)((ts[0]<<8)|ts[1]))/0xFFFF);
if (_wire->read() != crc8(ts, 2))
{
return SHT31_CRC_ERROR;
}
rh[0] = _wire->read();
rh[1] = _wire->read();
*humid = 100.0*(double)(uint16_t)((rh[0]<<8)|rh[1])/(double)0xFFFF;
if (_wire->read() != crc8(rh, 2))
{
return SHT31_CRC_ERROR;
It makes me feel like I'm the only one to buy and try the M8 sensor.
system
Closed
July 20, 2024, 5:38am
4
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.