Arm Mbed OS support forum

Data address for HTU21D temperature and humidity sensor

Hello everyone, i’m new to this so i’ll be really happy to find some help here.

I’m currently working on a preject using HTU21D sensor with mbed NXP LPC1768, I’ve found many programs here on the plateform but none is willing to work.

After some troubleshooting, I find that the variables ST and SRH used in the formulas to calculate temperature and humidity aren’t reading correct values, however idk which address i should use to read this data from my sensor.

If anyone has been through this, it would be great help.

PS : here are the links to the different codes i used
https://os.mbed.com/users/andcor02/code/HTU21D_TEMP_HUMID_SENSOR_SAMPLE/
https://os.mbed.com/users/alipford3/code/HTU21D_HELLOWORLD/

Thank you very much.

Hello,

I am not sure if understand your question but usually is good to read datasheet of the hardware.
According to the page 11/21 section Hold/No Hold master modes, both libraries use different modes. That is why they use different registers.

BR, Jan

Yes i have read the datasheet ofc. The given address in the codes to read temperature/humidity data is 0xFFFC however it doesn’t figure in the datasheet at all besides it gives a false value.
Idk if the code writers had the same problem, gonna see more.
Thank you for your reply.

But 0xFFFC is not any address and also it not figure as an address in the code. In the code is 0x40 (aka 0x80 and 0x81 according to direction - R/W) as I2C slave address and 0xE3 and 0xE5 ( Hold master) and 0xF3 and 0xF5 ( No Hold master) as addresses of sensor registers.
The value what you receive from sensor also contain two status bits what must be zero out before calculation. That is why is 0xFFFC used.

BR, Jan

Yes i saw all these addresses in the datasheet and i quite understand them, however i still don’t get your explanation, could you give me more details please as to how the 0xFFFC is figured (ps : i also have an AHT10 sensor that i would like to use if i could figure out this address).

Good explanation is on page 11-12 of datasheet.

However…
0111 1100 1000 0010 (0x7C82) - measured value + two status bits (bit0 and bit1)
1111 1111 1111 1100 (0xFFFC) - Bitwise And for zero out
0111 1100 1000 0000 (0x7C80) - result of Bitwise AND for calculating of the real value

BR, Jan

Okay thank you very much for your help, it is clearer now.