Simple and Low Cost Temperature and Humidity Sensor


Here’s a simple and low cost temperature and humidity sensor.  I’ve been developing a control system for an industrial application for one of our clients.  As part of that system we have a microcontroller located in a box with some other equipment, and thought it would be good to include some environmental monitoring.  Mostly we want to know if the things get too hot, or if they start to get wet due to maintenance people spraying down the outside of the equipment boxes (which are supposed to be water proof).

To do this we’re using a PIC16F1789-I/PT to monitor a Honeywell HIH-5030-001 relative humidity sensor as well as a Texas Instruments (who purchased National Semiconductor) LM35DM temperature sensor.  We’re doing quite a bit more with the PIC16F1789-I/PT in our design, but I’ve stripped all of the applications specific circuitry away in the schematic above.

One of the nice features of the PIC16F1789 is that is has a built in voltage reference and a 12 or 10-bit analog-to-digital (ADC) converter.   With the voltage reference set to 4.096V and the ADC configured for 12-bit, the output resolution of the ADC is 4.096V/4096 bits, or 1mV per bit.   Accuracy is less.  The on-board reference is rated for +/-4%, and ADC noise will probably cause you lose the lowest 4-bits of a 12-bit ADC.  Most of this can be overcome by designing a calibration process into the microcontroller operating system.  However, in this case we’re implementing a sledgehammer of a design, not a finely tuned instrument, so we’ll accept the shortcoming of the analog measurements.

The LM35 temperature sensor is a venerable IC.  It outputs 10mV / degree C, with an accuracy of +/- 0.5C.  So our ADC measurement of the LM 35 on pin RA0 equates to ADC measurement / 10 = degrees Celsius.

The HIH-5030-001 is a +/-3% relative humidity sensor.  The datasheet for that part provides an equation to convert voltage to relative humidity.


Vout also equals 1mV*ADC_Count.

0.001V*ADC_Count = 5V*(0.00636*RH+0.1515)

ADC_Count * 0.001V/5V = 0.00636*RH + 0.1515

RH = (0.0002*ADC_Count – 0.1515) / 0.00636

So if the ADC_Count = 2000 (or 2V) RH would equal 39% +/-3% (not including ADC inaccuracies).

The second equation can be used to provide temperature compensation for the relative humidity measurements.

Next week I’ll show some of the code used in this temperature and humidity sensing design. In the interim here is the parts list for the schematic shown at the beginning of this blog.  One thing to note is that the humidity sensor we selected stops working if it gets wet.  But then again our electronics will stop working if it gets wet.


Speak Your Mind


This site uses Akismet to reduce spam. Learn how your comment data is processed.