Humidity sensor HIH4000
Today I connected the temperature sensor Honeywell HIH 4000 to the MSP430 Launchpad.
With a typical current draw of only 200 µA, this sensor is ideally suited for low-drain battery-powered devices.
Hardware considerations
HIH4000 has only three connections:
- Vcc
- GND
- Output
The output voltage varies linearly with the Relative Humidity. Output voltage depends on Relative Humidity as shown in picture
According to datasheet, output voltage ranges from 0.8 V to 4 V. Because ADCs are configured to have a Vref of 2.0 V, a voltage divider is required.
Just to prevent any possible impedance mismatch between the HIH4000 output and the ADC input, I added a 741 operational amplifier in buffer configuration
The Vcc is provided through the ULN2003LV integrated circuit
To determine the R1-to-R2 ratio, the following equalities can be written
and substituting
Vmax is the maximum sensor output voltage (4 V) and Vadc is the ADC maximum input voltage (2.0 V). This leads to
Assuming R1 and R2 equals to 10 kΩ, the Equivalent Series Resistor seen by the sensor output (ignoring the input impedance of the operational amplifier, which is in theory infinite) is
So the sensor current load is
which seems to be ok
Software implementation
Using the same functions I already talked about in my previous post, I can write a the function to read out the output value provided by the HIH4000 sensor
float val = SENSORS_AnalogRead(ADC12_B_MEMORY_1);
According to the datasheet, relative humidity read by the sensor must be compensated in temperature according to the formula
T being expressed in degrees Celsius
The formula to convert ADC reading into RH is
where
- "RH" is the relative humidity (%)
- "ADC reading" is value returned by the AD converter
- "ADC precision" is the ADC reference voltage (2.0 V) divided by the maximum value returned by the AD converter (1024). This resulting value is 2.0 V / 1024 = 0.00195
- "Vout @ 0 RH" is the output voltage when the sensor measures a Relative Humidity of 0. According to datasheet, this is 0.8 V. This value must be divided by the voltage divider ratio (2)
- "Voltage step per RH" is the variation in the voltage output when Relative Humidity changes of 1%. This can be calculated as
Note that the voltage divider ration must be taken into account when defining Vout@100RH and Vout@0RH
#define SENSORS_HIH4000_V_RATIO 2.0f
#define SENSORS_HIH4000_V_0RH (0.8f / SENSORS_HIH4000_V_RATIO)
#define SENSORS_HIH4000_V_100RH (4.0f / SENSORS_HIH4000_V_RATIO)
#define SENSORS_HIH4000_RH_MAX 100
#define SENSORS_HIH4000_V_PER_RH \
((SENSORS_HIH4000_V_100RH - SENSORS_HIH4000_V_0RH) / SENSORS_HIH4000_RH_MAX)
void SENSORS_ReadRH()
{
// read sensor value
float val = SENSORS_AnalogRead(ADC12_B_MEMORY_1);
// compensate with temperature
val = val / (1.0305 +
(0.000044 * SENSORS_Data.temperature) +
(0.0000011 * SENSORS_Data.temperature * SENSORS_Data.temperature));
// scale value to get RH
val = (val * SENSORS_ADC_VMAX) / SENSORS_ADC_STEPS_MAX;
val = (val - SENSORS_HIH4000_V_0RH) / SENSORS_HIH4000_V_PER_RH;
SENSORS_Data.humidity = val;
}