Apologies for raising the thread, but I've just been having a play with a similar (very cheap
) humidity sensor, and I thought I might as well share the results:-
http://www.technobotsonline.com/index.php?dispatch=attachments.getfile&attachment_id=492
Using an 08M I faffed around with the pwm command, but the lowest frequency you can get is around 2KHz at 25% duty cycle, and the results were a bit unpredictable and seemed to have a weird time-constant. I also tried to copy the Basic Stamp's RCTIME command, but failed. Next I tried a 555 timer generating a 1kHz "squarewave" (more like the alps with deju-vu
) into an ADC input, but again the results didn't seem very meaningful, although it was obviously working to some degree.
The last, and most successful attempt was using the tune command to charge a cap, and read the voltage from it. In order to keep the voltage across the sensor in spec, I used a 20M resistor from Output2 in series with the sensor, to ground. In parallel with the sensor was a cap (I tried 100uF, 10uF and 0.68uF) and the ADC reading was taken from between the sensor and resistor, at one end of the cap. I also attached a DS18B20 to get some idea of interaction with temperature. Code as follows:-
Code:
Symbol Temperature = b0
Symbol Humidity = w1
Temp:
readtemp 1,Temperature
goto RH
RH:
tune 0, 15,($90)
readadc 4,Humidity
goto DataOut
DataOut:
sertxd (#Temperature,",",#Humidity,13,10)
pause 1000
goto Temp
I cut and pasted the output into Excel and drew the attached graphs, to get some idea of responsiveness and hysteresis. The RH graph is inverted (80-RH), the Temp graph is true, first set of results use a 100uF cap, second the 0.68uF. The 10uF results were similar. The first set of results (Temp1 and RH1) show some "handling noise" (read p*ss*ng about!
) at first, followed by a small peak in temp and a larger peak in RH where I blew on it. After watching the decay, in units of 10 second samples, I blew on it "a bit longer and harder", as per IEE8633846, ISO99999, RAL3524 et al.
The second set of traces show the initial charging of the cap better, reaching equilibrium much faster, followed by me blowing on it in much the same way as my second attempt. After the sensor output had settled again I gave it a quick blast with a heatgun, and you can see the large spike in temperature, with the corresponding fall in
relative humidity, caused by heating the air. You can also see the hysteresis in the sensor, as the level never quite comes back up (down?!?) to where it was before. I did some dodgy calculations based on vague assumptions and came up with a figure of 5% hysteresis, which isn't far off the spec, and close enough to the sexy £50 SPI sensor (whose name I forget
) which gives +/-2% in its spec. I also suspect that the reason the capacitor size appears to make so little difference in the decay time is because the sensor lag overwhelms it.
Obviously this is just mucking around, but I'm interested in making small(ish) sensors for a home automation system, distributing them on a serial network - one of the prime concerns is cheapness! I don't know if I will end up using this design, but at £0.60 per sensor (plus £4 for the DS18B20), versus £50.....
Hope this is of interest to someone, let me know if I've made any obvious mistakes, or if you come up with a better idea I can steal!
Ix