Pages: 1 [2]   Go Down
Author Topic: Using an HS1101 humidity sensor  (Read 10066 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
just worked? Where's the fun in that?
Once and a while in the future you will wish for such "luck" smiley-wink

The fun is now you can think of adding new functionalities, actions to be taken at certain humidity levels (motors valve, airco's etc)  , logging the levels and analyse them day vs night (add an RTC!!) ... There is always fun around the corner !

Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(using UNO)
Got this circuit working with code below.  Used a storebought humidity gauge to calibrate, according to Parallax datasheet, the function is linear.  Could have tried to calibrate using the result++, but I found the micros() method gave me better results.  Is this off base?  i am a newb.

 Regardless, using a 2M pull down resistor, I get spot on humidity readings using a script that averages mulitple readings of the capacitor decay time in microseconds and is calibrated using a slope of .1667 and offset of -67.00.   -- The averaging gives much more consistent readings than one-off reads.

don't make readDelay too small or it will affect the sensor readings.  An accurate read could take a few seconds if your sample size is large.

thoughts?  i am sure this script could be tidied up a bit... would love feedback, I am just happy I am getting accurate reads!
Quote
int sensorPin1 = 4;

long result = 0;
unsigned long time1=0;
unsigned long time2=0;

long readingsPer=20.0;
long readDelay=200.0;

#define RH1(time) ((.1667*time)-67)

void setup()                    // run once, when the sketch starts
{

  Serial.begin(9600);
  Serial.println("start");      // a personal quirk
}
void loop()                     // run over and over again
{
  long H=RH1(evalHumid(readingsPer, sensorPin1));
  Serial.println("_____");
  Serial.println(H);
  Serial.println("_____");
  delay(1000);

}

long evalHumid(long samples, int sPin){
  long avgtime=0;
  for (int i=0;i<samples;i++){
    RCtime(sPin);
    avgtime+= decayTime(3);
  }
  avgtime=avgtime/samples; 
  return(avgtime);

}

long RCtime(int sensPin){
  long result = 0;
  pinMode(sensPin, OUTPUT);       // make pin OUTPUT
  digitalWrite(sensPin, HIGH);    // make pin HIGH to discharge capacitor - study the schematic
  delay(1);                       // wait a  ms to make sure cap is discharged

  pinMode(sensPin, INPUT);  // turn pin into an input and time till pin goes low
  digitalWrite(sensPin, LOW);// turn pullups off - or it won't work
  decayTime(1);  
  while(digitalRead(sensPin)){    // wait for pin to go low
    //result++;
  }
  decayTime(2);
  delay(readDelay);
  //return result;                   // report results   
}

long decayTime(int input){
  if (input==1){
    time1=micros();
  }
  if (input==2 ){
    time2=micros();
  }
  if (input==3){
    return (time2-time1);
  }
}

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there, I've been struggling with this sensor, I have used your code, but still I don't get the results done well. I'm comparing it to a SHT15 sensor.
My question is, how do you calculate the slope and the difference, in this case RH1(time) ((.1667*time)-67) ??
For example, for a 60% humidity, I get 242 as a reading. I have tried increasing the 67 to 247 to get the same results, but when I put it on a 75% humidity environment, the results goes to 108, which obviously is off the chart.

Please enlight my path!

Thanks
Greetings
Giovanni
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there, I've been struggling with this sensor, I have used your code, but still I don't get the results done well....

Me too...

Code:
start
_____
226
_____
_____
225
_____
_____
224
_____

but... reading the device Documentation from here http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/27920-HS1101-v1.0.pdf seems that getting the RH is simple as:

TDecay= 2.4•%RH + RHconstant

Code:
endTime=micros()-startTime;
endTime=endTime*10;
endTime=endTime-HS1101_RH_CONSTANT;
endTime=(endTime)/24;

also in this way readings seems meaningless... may be my hs1101 is broken? What happens if polarity is inverted?
Logged

Cumming, GA
Offline Offline
Edison Member
*
Karma: 20
Posts: 1643
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What happens if polarity is inverted

Hmm. I don't recall it having a polarity.  It is essentially a "humidity" variable non polarized capacitor.
Logged

Pages: 1 [2]   Go Up
Jump to: