Pages: [1]   Go Down
Author Topic: Sensirion SHTxx Library Absolute Humidity and Heat Index functions  (Read 1991 times)
0 Members and 1 Guest are viewing this topic.
Morganton, NC
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 227
Posts: 14010
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Rob Tillaart

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

Morganton, NC
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/**
* 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();
}

Any help is greatly appreciated!

* SensirionSHTxx.h (3.62 KB - downloaded 13 times.)
* SensirionSHTxx.cpp (26.11 KB - downloaded 11 times.)
* keywords.txt (0.78 KB - downloaded 6 times.)
* ReadSHTxxValuesNBmine.pde (1.83 KB - downloaded 6 times.)
« Last Edit: April 20, 2011, 03:45:48 pm by MikeRector » Logged

italy
Offline Offline
Full Member
***
Karma: 3
Posts: 227
Muuuuu
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have used this code and schemas without troubles:
http://www.glacialwanderer.com/hobbyrobotics/?p=5
Good luck!
Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 227
Posts: 14010
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Code:
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:
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.
Logged

Rob Tillaart

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

Morganton, NC
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

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

i also added this to convert everything from C to F...
Code:
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:
Serial.print("Heat Index: ");
    Serial.println(calcHeatIndex);

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?
Logged

Pages: [1]   Go Up
Jump to: