Humidity Sensor HH10D

Sometime back, I ordered a HH10D, humidity sensor from sparkfun with the idea of integrating this sensor with an Arduino Pro (3.3V). This is a relatively cheap relative humidity sensor with an accuracy of about 3% sufficient for measuring  humidity at home.

20110921-122823.jpg

The sensor is pretty straightforward to use, once you figure out the mistakes in its data sheet. The sensor stores some calibration constants (sensitivity and an offset value) in an EEPROM packaged with sensor. The data from the EEPROM can be read using I2C (Arduino Wire Library). After that the sensor just returns frequency that can be measured and the RH can be calculated using the formula in the datasheet.

Couple of things to note about the datasheet:
– Device address is 81
– Though the device is marked as an I2C, the I2C communication is only required to read the constants from the EEPROM.

Once the constants have been read the sensor can be directly used without ever needing to connect the I2C lines. Another tricky thing with the sensor is an accurate way of measuring the frequency! A simple pulseIn approach will give wildly fluctuating results due to errors in measuring the frequency. To overcome this, there are a couple of suggestions that I discovered on the web:

– Using the FreqCounter library. This library uses the internal timers to measure the frequency accurately. You can download and get more details of this library from: http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/
– Averaging the frequency measurements with pulseIn

Though the FreqCounter library is more accurate, there is something to be said for the flexibility and ease of the second method.

I have wrapped both the approaches along with all the functionalities of the sensor in a class (HH10D). The class makes it easy to choose either method and allows customizations for measurements. The code is well documented, so please feel free to check it out at: http://www.mediafire.com/?0k9efr0g38bng

UPDATE: Library for Arduino 1.0 and higher can be downloaded from https://www.box.com/s/ody8705fmjtc3zimfakt

Below is a sample program using the library!

#include "WProgram.h"
#include "FreqCounter.h" // Optional (not required by this code)
#include "Wire.h" // Required once to get the constants
#include "HH10D.h"  //HH10D library

using namespace std;

HH10D humid(6); //Not using FreqCounter library

void setup()
{
    Wire.begin();
    humid.setup();   // Reads the constants from the EEPROM
    humid.setSampleSize(2048); // Number of samples to average the humidity value
    Serial.begin(9600);
}

void loop()
{
    // Get RH
    float rh = humid.getRH();
    Serial.println(rh,2);
    delay(5000);
}

int main(void)
{
	init();
	setup();
	for (;;)
		loop();
	return 0;
}

10 responses to “Humidity Sensor HH10D

  1. First I’d like to say… Thank you so much for posting about this. Very helpful! I tried compiling the sample program you have posted above, but I get a bunch of errors. Can you please tell me what version of the Arduino software you used for compiling it? I’ve noticed that with each different version of Arduino software (18, 22, 23, and 1.0) I tried compiling with I get different errors.

    • Jeff, this was done using C/C++ on XCode on MAC. To use directly with Arduino, just download and install the HH10D in the Arduino library (http://arduino.cc/it/Reference/Libraries <- link shows how to install and use a contributed library). You would need both the FreqCounter library (provided link in the post) and the HH10D.

      To use it, just use the same code as above without the using namespace std line and the main function.

  2. Jeff, this was done using C/C++ on XCode on MAC.
    To use directly with Arduino, just download and install the HH10D in the Arduino library (http://arduino.cc/it/Reference/Libraries <- link shows how to install and use a contributed library). You would need both the FreqCounter library (provided link in the post) and the HH10D.

    To use it, just use the same code as above without the using namespace std line and the main function.

  3. Pingback: temperature humidity | Pearltrees

  4. I found this post very useful as I’m planning to buy this sensor. But one thing was not clear for me. What did you mean when you said “the sensor can be directly used”. Is it possible to continue using I2c for reading data?

    • What I meant was that once you read the constants from the EEProm, you do not need the I2C connections anymore. I2C is only required once during the setup to figure out the constants. The rest of the time, you just use the Frequency and the formulae in the datasheet to calculate the humidity.

      • Ok. And what kind of connection is available to read data after the initial setup besides I2C?

      • Its on-demand. You connect a digital input port to the Freq out pin of the HH10D. Measure the frequency with the digital input whenever you need the reading for the Humidity

  5. is there a way to make this chip addressable? re-solder the eeprom chip leads and read from the eeprom?

    • I would doubt that! From the datasheet it seems that it is fixed. Rather, than making this re-addressable, I would just opt to read the constants once and never bother about them.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s