I just got a H25K5A, the only humidity sensor they had in the store. I figured it won't be that difficult to interface it, but I may need some help.
Here is the only datasheet I managed to find:
It recommends a driving frequency of 1 KHz, but why do I need a square wave to drive this thing, can't I just use it in a voltage divider circuit, or some sort of bridge with constant voltage/current?
Also, I now realize that I need a thermistor to compensate for the temperature effect, is that correct?
If so, I have a 30 KOhm thermistor, but I need 50 KOhm one for that sensor. Is it possible to read both sensors on separate ADC channels and then do the math in software? How much would accuracy suffer from this approach?
aaronds:- You have a similar sort of sensor to the first one. It is a capacitive sensor. When you modified that inverter did you:-
Change the frequency it operated at to 1KHz?
Adjust the output voltage from 120V to 1V?
Apply the output to the sensor in series with a resistor and rectify and smoothed what was across the sensor before reading it with the arduino's A/D?
If you did all that you would have found you weren't able to measure the full range of humidity because the output covers 4 decades of impedance.
Kirll :-
but why do I need a square wave to drive this thing
Because it is not a pure resistive sensor, there is a capacitive element to it similar to the other one. What makes you think it is a square wave? There is nothing in the data sheet to suggest this, in fact with the rating of 1V RMS that implies a sine wave also. The impedance are different to the first but they still cover a vast range that you will no be able to cope with using the analogue input of the arduino directly.
Both
The normal way to deal with a sensor of this type would be to make it a frequency defining part of an oscillator and then measure the resulting frequency. However that might upset the calibration as the data sheet infers it should be used at 1KHz, this is quite low for this sort of thing. However, your only other option is to construct a non linear amplifier and those are both expensive and a nightmare to build.
So I would try and build it into an oscillator and see what you get.
It probably won't be as accurate and calibration will be a nightmare, but still, it's a pretty simple solution, and should be possible. How much of a "capacitive element" is there? What if I only measure the active resistance?
I was hoping to find an application note of some sort, or a project that uses this type of sensor, or at least some theory on the subject. Alas, the interwebs have not blessed me with such fruits yet
I looked at the data sheet and it made me smile. It starts off by saying:-
MEAS France / HUMIREL HS24LF resistive sensor is designed for cost sensitive applications such
as HVAC, copying machine and weather-forecast station; mostly indoor applications.
Now indoor weather-forecast station there's something to think about.
Well, people have large homes these days, maybe big enough to have their own climate
However, the idea is cool -- using 2 i/o pins and an ADC channel is a pretty economical interface, as opposed to, say, a non linear amplifier or even a 555-based oscillator. I am a programmer trying to stay away from AC.
I still can't figure out exactly how the algorithm works though. When am I supposed to take the ADC reading? Every time the polarity of the pins changes, the voltage in the middle will follow an exponential curve. There should be a period of around 0.35 ms when the voltage is relatively stable, but that's definitely not long enough for an ADC reading.
You are supposed to take the Vrms reading, something which is hard to do with just an A/D. So the best bet would be to take the peak reading. This involves taking the input and putting it through a diode and then smoothing it with a small capacitor before measuring it. You also need to supply it with an AC signal of around 1KHz from either an oscillator or a timer on the arduino. As this needs to be symmetrical around ground then you need to couple this into the resistor and sensor through a capacitor.
The words in that application note do not fill me with confidence, personally I don't believe a word of it.
I'm not entirely sure this is relevant, but I bought a handful of HCH-1000 capacitive humidity sensors thinking I'd be able to drive it with DC and a resistor and measure the charge-time directly with the Arduino's ADC. Then, after seeing this thread, I went back and re-read the datasheet and see that it's the same design as the sensors mentioned in this thread. grumble
I've found a number of interesting discussions and thought I might pass them along:
There's a user on electro-tech-online.com named blueroomelectronics who is building a thermostat kit with humidity sensing. Here are discussions around his kit and adding that functionality. This is the schematic of the kit; note the fairly simple arrangement of the 555 timer for generating a frequency based on relative humidity and how it's input to the PIC. This is a presentation from Honeywell that contains several sample circuits, including a couple that appear to output a voltage based on %RH, using a couple of 555s and a pair of op-amps.
The simple frequency-generating 555 circuit looks like the simplest. What are your thoughts on that one, Mike?
The problem with the cricket one is that it is not applying a symmetrical signal across the sensor. The inclusion of the series capacitor in the Honeywell application note ensures that happens so that is the configuration to go for. In essence it is incorporating the sensor in an oscillator circuit and measuring the resulting frequency. You could go with the simpler circuit and do all the offset correction stuff in software.
I did spend some more time reading, now all my posts seem so ignorant ...
Firstly, capacitive RH sensors are not the same as resistive ones. For my sensor, I have to read out the resistance, and eliminate the capacitive component. I still must use unbiased AC to avoid permanent damage to the sensor.
There is another user on electro-tech-online.com who had the same problem. He passes the AC through a cap to eliminate the DC bias, then uses an "ideal diode" and (I assume) takes a peak reading.
I am thinking of following the app note approach above. I know it sounds ridiculous in parts, but surely it's the simplest possible schematic for interfacing this type of sensor with a microcontroller. I was wrong to state that there's not enough time to do an ADC sample. The chip is capable of completing a read in 13us (as per the datasheet), and has a sample-and-hold circuit. Stupid me.
I'll outline what I think is the correct algorithm below:
* Set I/O 1 and 2 to outputs
* Start alternating the voltages on the I/O pins every 500us:
HIGH/LOW, then LOW/HIGH. This gives f=1KHz 10V p2p square wave
Can be done with a timer/interrupt or PWM
* Set value_stateA=0; value_stateB=0;
* Take one ADC reading, discard result (first reading takes 13 ADC clocks longer)
* Do N times
* Wait for a HIGH/LOW state of I/O pins
* Start ADC conversion 350 us after the beginning of the half-period
* Wait for the conversion to complete
* Add the result to 'value_stateB'
* Wait for a LOW/HIGH state
* Start ADC conversion 350 us after the beginning of the half-period
* Wait for the conversion to complete
* Add the result to 'value_stateA'
* Stop alternating the levels on the I/O pins setting both LOW.
* Average out 'value_stateB' and 'value_stateA'
value_stateA = value_stateA/N
value_stateB = value_stateB/N
* At this point, two values for R(RH) can be calculated using the two values:
(I'll asume value_stateA and value_stateB are in Volts (easy to calculate), so we have:
R(RH) = (Vcc x R1)/value_stateA - R1
R(RH) = (value_stateB x R1)/(Vcc - value_stateB)
Of course, I can only measure the voltage in one state, but taking the two should give better accuracy and point out any mistakes in the algorithm.
I am not sure if I'l use arduino's libraries for this project, or I'll do the firmware from scratch. It requires precise timing that may be hard to do with analogRead() and digitalWrite().
I've had very little formal training in electronics, so my approach may be horribly wrong. I'll be glad if anyone provides some criticism
@blador, this works only with resistive humidity sensor, the capacitive element is ignored. if yours is capacitive, the approach will have to be modified with a few more external components, and you should be measuring time, not voltage ...