Go Down

### Topic: HR202 Humidity Sensor (Read 24919 times)previous topic - next topic

#### rudmac

##### Jan 20, 2013, 03:51 pmLast Edit: Jan 20, 2013, 04:37 pm by rudmac Reason: 1
Hello,

I got a HR202 humidity sensor and I have no idea how to convert the analog result to HR%. I haven't found any exemple code at internet.

If someone have a example, please send to me. I apreciate.

int analogPin = 0;

void setup()
{
Serial.begin(9600);          //  setup serial
}

void loop()
{
Serial.print("Analog: ");
Serial.print(getValue());
Serial.print(" Digital: ");
delay(1000);
}

float getValue() {
// need some calca to HR%
return val;
}

#### robtillaart

#1
##### Jan 20, 2013, 04:28 pm
Rob Tillaart

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

#2
fixed. tks

#### kuhntucker

#3
##### Jan 20, 2013, 04:52 pm

Hello,

I got a HR202 humidity sensor and I have no idea how to convert the analog result to HR%. I haven't found any exemple code at internet.

If someone have a example, please send to me. I apreciate.

The datasheet you provided contains a chart which converts resistance of the sensor to humidity at a given temperature.  You could put that table an array, and then look up and interpolate values based on the value from the temperature sensor which it appears you are missing.
Alternatively, you could generate a function from the values in the table.   Spreadsheets graphs and trend lines are helpful for that.

#### kuhntucker

#4
##### Jan 20, 2013, 05:50 pm

Alternatively, you could generate a function from the values in the table.   Spreadsheets graphs and trend lines are helpful for that.

I plotted the 25C results against the log of the resistance and found that a 4th order polynomial function fits the data quite well, with an R^2 value of 1.    Personally, I'd probably go with the function approach, since I find it more aesthetically pleasing.

#### rudmac

#5
##### Jan 20, 2013, 07:00 pm
ok, tks.

I will figure out to transform it into a formula using also the ambient temperature matter.

tks

#### mimo

#6
##### Feb 27, 2013, 05:47 am
hello, I just bought the sensor of HR202.
By the way have anyone had been successful how to get the reading in RH%? I had tried to search from the other sources, but it seems that not many info could get about this sensor.

#### robtillaart

#7
##### Feb 27, 2013, 07:45 pm
Quote
You could put that table an array, and then look up and interpolate values based on the value from the temperature sensor which it appears you are missing.

you can use - http://playground.arduino.cc/Main/MultiMap - for non-linear mapping (it mixes lookup & interpolation)
Rob Tillaart

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

#### sxorpheus

#8
##### May 05, 2013, 02:45 pm
I am trying to get this sensor to work , but with out much luck, does anybody got the correct formula / calculation.

#### geir_moen

#9
##### May 06, 2013, 12:51 pm
This looks like a horrible sensor ;-)
First of all - Relative Humidity is, by name, relative to the air temerature.
The reading from this sensor is therefore incomplete, and cannot be used unless you already know the air temperature.
.. And if I read the documentation right, you will have to create a 500-2000 Hz frequenzy at 1.5 volt. And then messure the inductance.

Can I recomend a completely difrent approach to your project?
Alternative 1 : "DHT11 Digital Temperature and Humidity Sensor"
It is close to the range of HR202. It messures temp. and RH. It will give you the calculated RH digitaly over the serial port. It costs about \$1.50 on eBay
Alternative 2 : "DHT22/AM2302 Digital Temperature Humidity Sensor"
The same as DHT11. A bit more expensive, but it has a wider range and has better precision. If you want precision, it is worth the extra money.

#### chchengl

#10
##### Aug 23, 2013, 05:56 am
I got same problem.there is no related information in web.
So that,I did humidity experiment & got convert function as following.

Voltage:    4.01-4.20-4.32-4.36-4.48-4.52-4.63-4.78
Humidity:  99   -90  -86   -82   -80   -74   -70   -62

Slope:-47.65  intercept:290.63  R-square:0.9863

Humidity=-47.65*(Voltage)+290.63

#11

#### TomGeorge

#12
##### Apr 12, 2015, 05:21 am
Hi,
the HR202 sheet says.

Quote
(1) Avoid polarization, driving voltage or current should be 100% alternative.
(2) Please measure the sensor with LCR alternative-current bridge, don't use multimeter.
This is the naked sensor, you need to build the AC supply, recommend 1.5Vac at 1Khz, and conversion hardware before feeding a signal suitable for the Arduino, eg DC level.

Tom.....
Everything runs on smoke, let the smoke out, it stops running....

#### alexafa

#13
##### Jun 05, 2015, 02:10 pm
Hi all,

This is my function to use HR202.

I use datasheet to determine HR.

Sorry for my English.

/**
* LA HUMEDAD A TRAVES DE HR202
* */
int oms0G[] = { 10000, 10000, 6400, 2900, 1400, 700, 370, 190, 105, 62, 38, 23,
15, 10, 7 };
int oms5G[] = { 10000, 10000, 4600, 2100, 1000, 500,260, 140, 80, 48, 30, 18,
12, 8, 5 };
int oms10G[] = { 10000, 7000, 3200, 1500, 750, 380, 200, 110, 62, 37, 24, 15,
10, 7, 5 };
int oms15G[] = { 10000, 5000, 2300, 1100, 540, 280, 150, 84, 50, 30, 19, 12, 8,
6, 4 };
int oms20G[] = { 6700, 3400, 1750, 850, 420, 210, 115, 64, 39, 24, 15, 10, 7, 5,
3 };
int oms25G[] =
{ 5000, 2600, 1300, 630, 310, 160, 87, 49, 31, 19, 13, 8, 6, 4, 3 };
int oms30G[] =
{ 3900, 1900, 970, 460, 235, 125, 69, 39, 25, 16, 10, 7, 5, 3, 2 };
int oms35G[] = { 3000, 1500, 740, 380, 190, 100, 56, 33, 20, 13, 9, 6, 4, 3, 2 };
int humedad[] = { 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 };
float getHumidity(float degreesCelsius) {
// read the value from the sensor:
float trueRH = 0;
int* arrayOMS;
if (degreesCelsius >= 35) {
arrayOMS = oms35G;
} else if (degreesCelsius >= 30) {
arrayOMS = oms30G;
} else if (degreesCelsius >= 25) {
arrayOMS = oms25G;
} else if (degreesCelsius >= 20) {
arrayOMS = oms20G;
} else if (degreesCelsius >= 15) {
arrayOMS = oms15G;
} else if (degreesCelsius >= 10) {
arrayOMS = oms10G;
} else if (degreesCelsius >= 5) {
arrayOMS = oms5G;
} else if (degreesCelsius >= 0) {
arrayOMS = oms0G;
}
for (int i = 0; i < 15; i++) {
if (HIH4030_Value > arrayOMS) {
if (i > 0) { //Aproximamos el resultado (Si no es ni el primero, ni el Ășltimo)
//HIH4030_Value //Ohmios actuales
int ohmsRM = arrayOMS[i - 1];
int humRM = humedad[i - 1];
int ohmsRm = arrayOMS;
int intervaloOHMS = ohmsRM - ohmsRm;
int valIOMS = HIH4030_Value - ohmsRm;
float mult = (float) valIOMS * 100;
float porcOhms = ((float) mult) / intervaloOHMS; //Porcentaje del rango de ohms;
int intervaloR = humRM - humRm;
trueRH = ((porcOhms * intervaloR) / 100) + humRm;
} else {
int ohmsRM = arrayOMS;
int ohmsRm = arrayOMS[i + 1];
int humRm = humedad[i + 1];
int intervaloOHMS = ohmsRM - ohmsRm;
int valIOMS = HIH4030_Value - ohmsRm;
float mult = (float) valIOMS * 100;
float porcOhms = ((float) mult) / intervaloOHMS; //Porcentaje del rango de ohms;
int intervaloR = humRM - humRm;
trueRH = ((porcOhms * intervaloR) / 100) + humRm;
}
break;
}
}
return trueRH;
}

Go Up