Sensor4

Humidity sensors on USB


Edsard Boelen, 18 november 2009
Not only the temperatures fluctuate much in my house, I have got a feeling that the humidity is too. so it's time to measure that. normaly the sensors are expensive, about 20,- but I found some on ebay for a tenth of the price.


The idea



SENSOR -> Cap to frequency -> frequency to bsd -> usb controller -> data logger

The sensor

The sensor has the following charasteristics:
.
At 10% humidity, the sensor has a capacitance of 100pf, at 90% its 150 pf.
As the sesnors are changing on capacitance, I need a capacaty to frequency generator. after that a frequency counter, and after that a usb coupling.

here is the capacitance to frequency converter:


The frequency counter

This part was actually the hardest part of the system, although it looks so easy. I used a atmega88 to convert the frequency to a decimal value, I needed to use 2 features of the chip I never used before: the timer, and the interrupt controller. Therefore I made some small test programs.

Catching interrupts on the atmega88:
interupt.c shows how to work with interrupts, timer.c shows how to work with timers on the atmega88

The frequncy converter application: after a lot of testing, I got a sensible value out of sensor. The lower the value the more humid it is. After that was the task to send it to the computer. At first I used the build in RS232 USART, but I got some problems getting the rs232 to usb interface working with my own linux kernel. So I used my own simple protocol. consisting of a data and a clk signal, as it is just one direction. At the start it would send 10 pulses hi, and 1 low, after that the first digit in pulses, i.e. 5 means 5 pulses hi, then again 10 pulses hi and 1 low second digit. after that it will send 10 pulses low.
hum2.c is the program
here is the schematic:


The usb interface


The usb interface is the for me familiar obdev.at Vusb library, it receives the pulses, and sends them when asked for.
the code is converter.c the package with usb drv is here



This is the resulting prototype


The server application


The client talk to the usb device and prints out the value with a timestamp. get the app: readhum.c

The web application




end