Humidity sensor and AC output

George Sephton

Senior Member
Hi I have a TruSens humidity sensor bought from Rapid and I have discovered that it requires AC power and will not run on DC power which the PICAXE output. I hadn't intended to use the mains or a motor and dynamo so does anyone know how to do it with a PICAXE. I have searched around and haven't found out much.

Someone said in another thread about usin PWM and pulseout could create one but I wondered if anyone had done this before and has any code they could help me with.

Thanks,
George S.
 

Andrew Cowan

Senior Member
I wonder whether pulsed DC would do, or if it needs reversing polarity (ie an H bridge).

For pulsed DC, a 555 would be best. For proper AC, you would need an H bridge. Both of these suggestions assume it will work with a square wave - not a sin wave.

Andrew

Edit: Looking at the datasheet, it needs fast AC (0.5 to 2kHz), and a sin wave would probably be needed. This may be too fast for a picaxe.
 
Last edited:

hax

New Member
What current does the unit use?

If its only a few milliamps, then you can use the sound command to generate a 1Khz square wave.

Invert the square wave with an inverter IC and tap the power off the inverted signal and the original signal. This will give you a 5V peak to peak AC supply.

Run through a non polarised resistor capacitor circuit to smooth out the square wave into a more or less sine wave.
 

BeanieBots

Moderator
The PICAXE is perfectly capable of producing the desired frequency using PWM. If a sinewave REALLY IS required, then simply filter with a second order RC network. I've not read the datasheet so have no idea about the exact requirements but you may need to buffer the post RC sinewave with an amp such as an op-amp.
Having given it the required sinewave, how will you read the (presumably) sinusoidal signal it gives off?
 

BeanieBots

Moderator
Invert the square wave with an inverter IC and tap the power off the inverted signal and the original signal. This will give you a 5V peak to peak AC supply.
That's 10v peak to peak.
Voltages are relative. A signal changing between 0v and 5v is AC 5v peak to peak.
 

hippy

Ex-Staff (retired)
Hi I have a TruSens humidity sensor bought from Rapid and I have discovered that it requires AC power
I'm guessing this is the cheapo 50p HCZ-J3A HUMIDITY SENSOR (61-0984) device. If I get an order into Rapid ( not sure when ) I'm going to order a few and have a play. I reckon there may be some way to use it easily and simply even if not driven under recommended conditions and, at that price, limited lifetime may not be a problem, for example, don't run it continuously. As to any accuracy, I have no idea.

With these sort of components it's often a case of busk it and see, wire something up, see what happens, and if it works everyone benefits, if it catches fire, emits a bang, melts a PICAXE or creates a black hole which consumes the universe, mark it up as part of the fun of pushing the frontiers of bodging things :)

Most of my electronics is done for fun and I get enjoyment from hacking things and nudging at the boundaries of 'maybe it will work' but that's not to everyone's taste. Unless you can find the time to do the experimenting yourself and put up with the trials and tribulations of something which ultimately may not work the best solution is often to get something which is plug and go or is tried and tested and known to work, although that usually is a more expensive route.

Unfortunately there are a lot of things out there which 'could be used' but no one's ever done that, so it's often do it yourself, pay the cost of someone having done the work or hope somene gets round to having discovered how to use it before you need to.
 

George Sephton

Senior Member
http://www.rapidonline.com/netalogue/specs/61-0984.pdf is the datasheet.

I agree with hippy Im not doing all this for gain, I really dont need to know how humid my room is but it's a lot of fun and it doesn't matter what it costs. Thanks very much about ordering them and yes it is the cheapo one, lol.
Im not sure but maybe it'd work with a square wave as that would be helpful, would it matter too much, the only time ive come across sine waves are in maths so im not sure how its all used in electronics.

But yeah if its a limited time then it would have to be run maybe once a day instead over every 10 seconds like i will with the LDR and temperature sensor. (part of my project)
 

BeanieBots

Moderator
The datasheet does not give any warning about DC levels. For the cost & risk, I'd experiment with DC and see what happens.
The figures quoted are for 1v rms sinewave. Note the 1V MAX rating, so don't go sticking 5v into it!
Creating a method of reading the AC impedance will be much harder than generating a nice clean 1v rms sinewave.
If you want to try to do it "properly", lookup "precision rectifier" in google or whatever. Not too tricky to make but will require a few op-amps. Then it's a question of building an AC driven potential divider with the sensor as one limb and using the "precision rectifier" to measure the AC volts across it.
It is also VERY temperature dependant so you will need to compensate.
Not very accurate due to the 2% hysterisis giving overall accuracy (AFTER compensation) of +/- 5%.

The moral here is "you get what you pay for" & "read the spec before you buy".
The golden rule is, if there is no datasheet, DON'T BUY.
 

hippy

Ex-Staff (retired)
My thoughts were to build an oscillator so the humidity sensor had AC through it and changed the frequency, or somehow use it as an RC from a couple of PICAXE pins and time the charge/discharge time. Triangle is close to a sine wave if you squint hard enough :)
 

LizzieB

Senior Member
I think you can get a reasonable result quite simply. The datasheet defines the output as impedance vs humidity. I don't think the waveform has to be perfect to measure that, and it's not a very accurate device anyway - see the temperature dependency. I would use the picaxe PWM output to generate a squarewave, put that through two or three stages of RC filtering to get it close to a sine wave and apply it to the sensor (one side grounded) through another resistor. Connect the junction of the resistor and sensor to a simple diode/capacitor detector and feed the resulting dc voltage to the picaxe ADC input.
 
Last edited:

George Sephton

Senior Member
Well I have ordered a square wave generator from maxim so if it ever arrives I'll follow one of those circuits to create a sine wave then pass an ac current through the humidity sensor which can then be read by the PICAXE. I'll post my circuit here when I get it working.
Thanks everybody.
 

BeanieBots

Moderator
@ KMoffett, thanks, I missed that.
@ George Sephton, there's a perfectly good square wave generator in the PICAXE! (PWMout).
I'd also slap a cap in series just in case the PWM duty is not exactly 50%.
Then go with LizzieB's suggestion as the sensor accuracy does not warrant much else.
 

George Sephton

Senior Member
there's a perfectly good square wave generator in the PICAXE! (PWMout).
I was aware of that but I've run out of pins on my PICAXE, if I have any I will use PWMOUT instead as it is easier. What would the code be to produce a square wave, because I can then use that to convert it into a sine wave.
 

hippy

Ex-Staff (retired)
One thing to watch out for with PWMOUT is it has a lower limit of frequency which is quite high, but this can be reduced by under-clocking the PICAXE or by poking various internal pre-scalers; more info via Forum Search.
 

BeanieBots

Moderator
With a lower limit of 0.5Hz, it would also be an option to use high/low statements but the use of a DC blocking cap would be more essential to gaurantee no DC component.

It would also give the option of synchronising the ReadADC command with the "AC" and might be a way of avoiding the need for a detector circuit.
Certainly worth a play.

do
High H_drive
pause N
readadc H_sense
{other code}
Low H_Drive
Pause (N+time for {other code})
loop
 

InvaderZim

Senior Member
From the datasheet:
Impedance range at 60%RH and 25°C (1kHz, 1Vrms) 14.2 – 38.5 kΩ

That's a wide range; if you need an absolute measurement, you'll need a way to calibrate it. If you just need to know if it is more humid today than it was yesterday, then your job is easy.
 

Coyoteboy

Senior Member
Most items run happily on pseudo-AC, hence the proliferation of 12>240v inverters using it, cant see an issue using the axe to generate it?
 

fernando_g

Senior Member
This is a capacitive-type sensor. Its capacitance (and thus, its impedance) changes with humidity, and somewhat also with temperature.
Therefore, frequency accuracy is another factor you should consider. I believe the Picaxe's internal clock is far more accurate than any external RC based oscillator.

That is what I would do:

1) Use the Picaxe's PWM output. Also use 1 Khz, since the device is characterized at that frequency.

2) The PWM wizard indicates that these values are outside range. What you could do is use a CD4013 as a divide by 4, which will also provide a perfectly symetrical square wave. The PWM frequency would be now 4 Khz. From the wizard, this equals to pwmout 2 , 249, 500

3) Filter it with a 2 pole RC filter. Buffer the signal with an opamp before feeding it to the sensor.

4) The sensor will form the upper leg of a voltage divider, the bottom leg being a resistor whose value is halfway between the sensor's upper and lower resistance range.

5) Rectifiy the signal with a precision rectifier, and feed it to the PICAXE's ADC.

That is the hardware part, the software follows.

6) Since the device has a lot of temperature dependency, it would be worthwhile to include a temperature sensor and perform some temperature correction.

7) Also the device is highly non-linear. Some sort of curve fitting correction would be nnecessary. I don't know how to do this with the integer math. Maybe other gurus know.

All in all, this is a handful, and looks like a very challenging (read: fun) project. If you need help with the analog portion of the circuits, feel free to ask.
 

Jaguarjoe

Senior Member
If its a capacitance sensor why not use it as the timing capacitor in a 555 oscillator circuit then use the picaxe to measure that frequency?
 

fernando_g

Senior Member
If its a capacitance sensor why not use it as the timing capacitor in a 555 oscillator circuit then use the picaxe to measure that frequency?
Doing a Google search, I found that there is an additional RH sensor technology, which I was previously not aware of: resistive humidity sensor.

According to the information in the link below: "...Most resistive sensors use symmetrical AC excitation voltage with no DC bias to prevent polarization of the sensor. The resulting current flow is converted and rectified to a DC voltage signal for additional scaling, amplification, linearization, or A/DRconversion..."

Therefore, this sensor must be a resistive, not a capacitive one.

http://www.sensorsmag.com/sensors/Technology+Tutorials/Sensors/Humidity/Moisture/Choosing-a-Humidity-Sensor-A-Review-of-Three-Techn/ArticleStandard/Article/detail/322590
 

KMoffett

Senior Member
If its a capacitance sensor why not use it as the timing capacitor in a 555 oscillator circuit then use the picaxe to measure that frequency?
The datasheet clearly stated not apply DC directly to that sensor. The timing capacitor in a 555 oscillator is continuously at a varying DC voltage. Pulsating DC is not AC.

Ken
 

fernando_g

Senior Member
Doing yet another Google search, found the following circuit for a capacitive type sensor, a Humirel HS1101LF, where the 555 idea could be put to good use... Please note this is different from the one originally discussed in the thread.
This particular sensor is available from DigiKey.
 

Attachments

Last edited:

hippy

Ex-Staff (retired)
While "do not apply DC" is there for a reason, pulsed DC isn't the same as AC, a square wave isn't a sine wave, the real question is what effect will those have and how large will the effects be ? That can probably only be determined by experimenting.

Considering these sensors are cheap and stocked by Rapid it suggests they mey be a component in widespread use in cheap consumer product, desktop hygrometers and all-in weather-station-come-alarm-clocks. Maybe a place to look is where have these been used and see what the designers have done there. We may be imagining it's a lot more complicated than it actually is.
 
Top