Reply
Posts: 19
Registered: ‎07-20-2015
Accepted Solution

Si7021 code as used with Thundersense

Hi,
When I look at the data sheet, and even in this forum, the code for the Si7021 sensor is wrong when used with the Thundersense. (Look in si7021.c)

if( status == SI7021_OK ) {
/* Data is ready */
*rhData = ( (uint32_t) readData[0] << 8 ) + ( readData[1] & 0xfc );
*rhData = ( ( ( *rhData ) * 15625L ) >> 13 ) - 6000;


and the Data sheet

125 * RH_Code / 65536 - 6


can anyone explain?

Thanks
Simon M

 

(Sorry if this is a repeat, my PC crashed when I pressed send, and didn't know if the original was sent)

Posts: 67
Registered: ‎04-09-2015

Re: Si7021 code as used with Thundersense

This code returns the humidity in % times 1000. It is written in this way to avoid use of floating point numbers.

Highlighted
Posts: 19
Registered: ‎07-20-2015

Re: Si7021 code as used with Thundersense

Thanks jogammel

It was a brain fade day!

 

Multiply 125 * 1000, then divide by 2 to find the lowest integer. (15625)

What threw me is 125^2 = 15625

 

Yours Simon M.