Go Down

Topic: Sensirion SHTxx Library Absolute Humidity and Heat Index functions (Read 3278 times) previous topic - next topic


Can anyone help me to figure out how to get the Absolute Humidity and Heat Index functions values from the  Sensirion SHTxx Library found here? http://code.google.com/p/sensirionshtxx/ and also mentioned here? http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1292537089

I've tried using the ReadSHT1xValuesNB example and adding hi = shtxx.read(calcHeatIndex); then serial.println(hi);, but all it reads back is 999.99 (because the hi default read error is set to 999.99).

Any help is greatly appreciated!


Can you post your code you have sofar, maybe we can spot something missing.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


Apr 20, 2011, 10:42 pm Last Edit: Apr 20, 2011, 10:45 pm by MikeRector Reason: 1
Sorry for taking so long to respond, busy with work. here is the code i have so far, basically its the example NB code, i've tried calling the calcHeatIndex function, but all it returns is 0.00.
Code: [Select]
* ReadSHT1xValuesNB
* Read temperature and humidity values from an SHT1x-series (SHT10,
* SHT11, SHT15) sensor in non-blocking mode.
* Copyright 2010 Eric C. Gionet <lavco_eg@hotmail.com>

#include <SensirionSHTxx.h>

// Specify data and clock connections and instantiate SHT1x object
#define dataPin 10
#define clockPin 11
// instantiate SensirionSHTxx instance
SensirionSHTxx shtxx(dataPin, clockPin);
#define SMP_ERR 999.99
static float taSmp = SMP_ERR;
static float tdSmp = SMP_ERR;
static float rhSmp = SMP_ERR;
static float calcHeatIndex = SMP_ERR;  //Added this
void processSHTxx()
   STATE CODES (checkSensor):
     Sleeping,     // 0
     Measuring,    // 1
     Completed,    // 2
     WriteError,   // 3
     Timeout       // 4
 // poll sensor
 result = shtxx.check(&taSmp, &rhSmp, &tdSmp);
 calcHeatIndex = shtxx.check(&calcHeatIndex);  //Added this
 // validate sensor result code
 if ( result == SHTxxSTATE_COMPLETED ) {
// Print the values to the serial port
   Serial.print("Air-Temperature: ");
   Serial.print("C. Dewpoint-Temperature: ");
   Serial.print("C. Humidity: ");
   Serial.print("Heat Index: "); //Added this
   Serial.println(calcHeatIndex); //Added this
 } else if ( result == SHTxxSTATE_WRITE_ERROR || result == SHTxxSTATE_TIMEOUT ) {
   taSmp = SMP_ERR;
   tdSmp = SMP_ERR;
   rhSmp = SMP_ERR;
   Serial.println("Sensor Read Error/Timeout");

void setup()
  Serial.begin(9600); // Open serial connection to report values to host
  Serial.println("Starting up");
  // set shtxx measurement interval (3-sec)
  // and enable non-blocking
  shtxx.setTimerInterval( 3000 );

void loop()
  // process sht measurement

Any help is greatly appreciated!


I have used this code and schemas without troubles:
Good luck!


Code: [Select]
calcHeatIndex = shtxx.check(&calcHeatIndex);  //Added this

the return value of the function is a _state so I think this line should be something like

Code: [Select]
state = shtxx.check(&calcHeatIndex);

if ( result == SHTxxSTATE_COMPLETED  && state == SHTxxSTATE_COMPLETED )  // CHECK BOTH !!!
// Print the values to the serial port

both readings must be complete to give good values.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


Thanks for all the input. i have tried a few things and am getting heat index readings now...

i added this...
Code: [Select]
static float calcHeatIndex = SMP_ERR;

then this under poll sensor...
Code: [Select]
calcHeatIndex = shtxx.calcHeatIndex(rhSmp, taSmp);

i also added this to convert everything from C to F...
Code: [Select]
calcHeatIndex = (calcHeatIndex * 9.0)/ 5.0 + 32.0;
    taSmp = (taSmp * 9.0)/ 5.0 + 32.0;
    tdSmp = (tdSmp * 9.0)/ 5.0 + 32.0;

then this to send the result to the serial monitor...
Code: [Select]
Serial.print("Heat Index: ");

However, the heat index reading i get is off by about -12 degF. according to a heat index calculator found here, http://www.easysurf.cc/cnver16.htm, an air temp of 71.73 a dew point of 57.13 and a humidity of 60.08 should give a heat index of 76.05f. instead i get a heat index reading of 64.33.

i've made sure that the values were in the correct places in the "calcHeatIndex = shtxx.calcHeatIndex(rhSmp, taSmp);", if i switch the rhSmp and taSmp, it jumps up to 122degF.

Any ideas or suggestions?

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131