The problem you face is that the sensor is simply a two terminal resistance element that changes resistance proportional to relative humidity. As such it must be wired into a voltage divider network (or a balanced bridge type circuit) to generate a given voltage range for the humidity range you wish to measure. So until you can calculate the resulting voltage measurement range you are not ready to write any software to handle the values you receive on a analog input pin. So show your sensor wiring setup and maybe we can help with the proper mapping of measurement values.
Lefty
Good point DC42 as that adds another dimension to the interface circuitry needed, a AC voltage source, a divider or bridge circuit, then a diode rectification/filtering stage to finally end up with a DC measurement voltage value.
Well that value "humconst" which is 0.16/0.0062 is about 26....
So therefore "humi = prehum - humconst" will be -ve for all values of prehum < 26.
Now, prehum is valb, which is the reading from the analog pin, which may be from 0 to 1023, and therefore can be < 26.
If I were you I'd add more serial.print() lines in your code to track the calculation through the steps so you can see where the -ve comes from. I'm guessing those constants in that script are derived for the sensor you mention (the other one, not your one) as part of some kind of calibration and probably don't apply to yours.
Currently in my country it is about 70% humidity
the value received by the analog input is from 1060 to 70% of humidity.
When I made ??the mist on the sensor is at 1090-1100.
It's that simple? I remove 1000 and I have good values?
retrolefty:
Good point DC42 as that adds another dimension to the interface circuitry needed, a AC voltage source, a divider or bridge circuit, then a diode rectification/filtering stage to finally end up with a DC measurement voltage value.
I was thinking more along the lines of using one of the PWM pins to generate a 1kHz square wave, feeding this to a resistor and then the sensor, with a capacitor to ground on the other side of the sensor. Connect the resistor-sensor junction to an analog input and measure the high and low voltages, synchronising the ADC conversions to the timer generating the 1KHz.
retrolefty:
Good point DC42 as that adds another dimension to the interface circuitry needed, a AC voltage source, a divider or bridge circuit, then a diode rectification/filtering stage to finally end up with a DC measurement voltage value.
I was thinking more along the lines of using one of the PWM pins to generate a 1kHz square wave, feeding this to a resistor and then the sensor, with a capacitor to ground on the other side of the sensor. Connect the resistor-sensor junction to an analog input and measure the high and low voltages, synchronising the ADC conversions to the timer generating the 1KHz.
I would for me just look for a humidity sensor that has more internal smarts and does all the low level stuff itself. Such a raw sensor can have so many problems with calibration and accuracy problems that I don't know if it's worth the effort.
If you're going to base your calibration on the fact that it's "about 70" when you take a reading to base your calculations on, you might as well not have a sensor in the first place.
But I'd go with Lefty's idea that you need a more crafty sensor anyway!
Hi,
your sensor seems to be working a whole lot like the EFS-10 humidity sensor, which I just recently managed to hook up to the Arduino and get to work thanks to the good people at this forum (yes, that's you MarkT :-).
The EFS-10 works on the same principle - you generate a square wave to feed it and you cannot use DC.
The code to drive it is available here, along with some documentation
This is the circuit I use an LM135 to measure temperature.
The square wave is generated by switching two digital pins on and off at the right frequency.
I am sure there is room for improvements, but I think it might be a starting point at least.