Hi All,
I got a couple of HCZ-J3A humidity sensors to have a play with mainly because they're cheap, £0.80p conpared to £13 plus for a DHT11. I've got it attached to A1 via a 10k voltage divider and I'm only getting a reading if I exhale directly over the sensor,and even then it's a tiny reading. I've included code and the serial output, any help would be muchly appreciated!
Temp 25.00
Humid Raw 14
Voltage 0.07
Humid Actual -28.98
Temp 24.73
Humid Raw 15
Voltage 0.07
Humid Actual -28.82
Temp 24.64
Humid Raw 15
Voltage 0.07
Humid Actual -28.82
Temp 24.47
Humid Raw 16
Voltage 0.08
Humid Actual -28.66
Temp 24.38
Humid Raw 16
Voltage 0.08
Humid Actual -28.66
Looking over the data sheet, it seems to me that you should be using a smaller divider resistor or a different kind of circuit. A 1k resistor is probably worth trying since the lowest resistance of the sensor is around 1k. A 2k resistance results in a drain of no more than 5mA, should be OK on the Arduino.
However, a rc circuit with a frequency counter might work better, ie detect how the frequency of the circuit changes as r changes. Use the resistor in a classic 555 astable multivibrator circuit (see http://www.circuitstoday.com/555-timer-as-an-astable-multivibrator), then count the pulses/s via one of the interrupt pins with an ISR. Every second, review the count, calculate the humidity. Maybe you can even eliminate the 555 from the equation with some equivalent software magic on the Arduino.
I.e. charge a serie RC circuit via a pin for longer than you know it needs to. Then measure the elapsed time until the voltage across the resistor drops to 1/3Vcc, recharge, rinse and repeat. You may even be able to use the same pin to do both. The size of the capacitor will then determine the frequency with which you can update the humidity. In other words, you need a fairly small capacitor in order to make the circuit work quickly. A common 0.1uF cap might be a good start, then experiment. If you have any 1000pF/1nF film caps lying around, that might be an even better bet since you'd be able to sample the sensor several times per second.
If you drop deep down into the ADC functions (i.e. change the ADC pre-scaler, use ADHL instead of analogread, etc.), you can get some very fast reads at a loss of resolution (i.e. quasi-8bit) that may be acceptable. Then run a couple of loops in a row, and average or (better yet) decimate to improve your results if necessary. Coming up with a curve-fit for the data (as a function of resistance and temperature) will be interesting.
Thanks Constantin! I'll try a 1K resistor and see if that makes any difference. I've seen a 555 astable circuit mentioned on the PIC forums, but I wasn't sure if this was needed, to be honest I'm hoping to keep the circuit for these sensors as simple as possible, but I'll give it a try and see if I get any results!
Thanks for the reply!
I just re-read the datasheet and noticed that they have a 1V maximum input voltage!!!! You will need to have a bigger resistor in series, at least 5K to keep the voltages down to safe levels for the sensor. Even a 555 circuit may also expose the thing to too much voltage unless you use a series resistor. I apoogize for overlooking that tidbit in the datasheet.
One option is creating a separate 0.5V voltage supply for the AREF pin to improve your resolution across this resistor. Also in the datasheet is a reference towards driving the thing with a 1kHz AC signal. Since I don't understand the underlying technology, I have no idea why the sensor requires this sort of excitation. You could consider running current back and forth through the thing to emulate a sine wave signal with a square signal instead. By keeping the DC voltage down to 0.5V, you should be safe.... at least I hope!
This sensor is a lot more difficult to implement than I expected. Perhaps that's what is driving the higher costs of competing models... i.e. they have temperature sensors, conditioning circuits, etc. on board that do all this work for you. How valuable is your time? I'm starting to wonder if a DHT-11 isn't a better bet.
Hi Constantin, thanks for taking the time to reply. Yes, according to the datasheet and the PIC forums, these need an AC source. I think I'm confusing impedance and resistance!
From the PIC forums....
The very cheap sensors are capacitative,
and require an AC power supply.
The impedance (not resistance) changes.
I'm thinking you are correct about the additional components required driving cost up. These were stupidly cheap, but have proved early impossible to interface with! I've not found one site that mentions using them with anything apart from a PIC and AC current. I was expecting it's output to be fairly consistent (ie. 2 Kohm = 20%RH), but I'm struggling to get anything meaningful out of it. I think it's time I got a couple of DHT11s!
The more I look at this thing, the more I wonder about where it is implemented by itself and why.
Feeding a stable 1kHz AC signal into anything would likely require a dedicated chip to do the work. Then something needs to measure the impedance and output a useful signal (whether its pulses or whatnot). Oh, and you also need a temperature sensor to compensate the output... My guess is that you're holding the sensor portion of what is inside the DHT sensor... they add the other required hardware and have a small processor in there to do all the work for you and deliver a nice data stream on request.
I use the DHT22s and for $12 from iteadstudio or $10 from Sparkfun they work great. Plus, compared to the analog-output humidity stuff that Honeywell sells, they are very inexpensive and much more capable. Better yet, the use of a digital signal makes DHTs far more easily implemented in remote sensor nodes than systems using analog signals.