Humidity Data Conversion Error?

Discuss mobile apps for Texas Instruments products.
pmasingh
Posts: 6
Joined: 22:48, 01 Apr 2015

Humidity Data Conversion Error?

Postby pmasingh » 17:24, 26 Mar 2016

I am constantly getting -ve values for the RH.

Notice in the TI CC2650 Wiki the following code for converting raw humidity data:

void sensorHdc1000Convert(uint16_t rawTemp, uint16_t rawHum,
float *temp, float *hum)
{
//-- calculate temperature [°C]
*temp = ((double)(int16_t)rawTemp / 65536)*165 - 40;

//-- calculate relative humidity [%RH]
*hum = ((double)rawHum / 65536)*100; <<<<<<<<<<<<<<<<<<<<<<<<<<
}


Comparing to the following in EVO tisensortag-ble.js:

instance.getHumidityValues = function(data)
{
// Calculate the humidity temperature (Celsius).
var tData = evothings.util.littleEndianToInt16(data, 0)
var tc = -46.85 + 175.72 / 65536.0 * tData

// Calculate the relative humidity.
var hData = (evothings.util.littleEndianToInt16(data, 2) & ~0x03)
var h = -6.0 + 125.00 / 65536.0 * hData <<<<<<<<<<<<<<<<<<<<<

// Return result.
return { humidityTemperature: tc, relativeHumidity: h }
}


I've lost touch with the Little Endian/Big Endian world, can some confirm that the EVO code is correct?

Many thanks!
Peter

Return to “Texas Instruments”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest