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).
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.
/**
* 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()
{
SHTxxSTATE_SENSOR result;
/*
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(taSmp);
Serial.print("C. Dewpoint-Temperature: ");
Serial.print(tdSmp);
Serial.print("C. Humidity: ");
Serial.print(rhSmp);
Serial.println("%");
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.begin();
shtxx.setTimerInterval( 3000 );
shtxx.enableTimer();
}
void loop()
{
// process sht measurement
processSHTxx();
}
calcHeatIndex = shtxx.check(&calcHeatIndex); //Added this
the return value of the function is a _state so I think this line should be something like
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.
However, the heat index reading i get is off by about -12 degF. according to a heat index calculator found here, Heat Index & Wind Chill Calculator, 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.