Now for the conversion on Arduino analog pin in:
0V = 0 and 5V =1023, you do the math
To test temperature:
place crushed icecube and a bit of water in plastic-bag (or condom ) and place over sensor, The sensor should give the analog value for 0C. use another human-readable thermometer to take the temperature in the room, the sensor is giving the analog value for this temperature. Repeat for stable higher temp, perhaps boiling water at nearly 100C, and sensor touching upper-outside of the pan/pot...
To get a "workable" formula for the Arduino to calculate temperature or RH%:
open Excel and input the values for Voltage or Arduino analog-in as X-axis and oC or %RH as Y-axis.
Make Scatter plot of the data (use the dots, not whole line)
Right click on one of the resulting points and choose trendline
Right click on the trendline and choose format trendline
select show formula, and choose the right type of trendline (straight line or poy (2 to 5 degree) or exp)
The formula for either temp or humidity should be visible now in the plot, it can be used with arduino to calculate right values.
The formula for %RH seems to be:
y = 4,8008x^5 - 47,772x^4 + 184,64x^3 - 343,78x^2 + 334,28*x - 110,6
where number after ^ is an exponent.
Thanks for posting - I just learned a whole lot about excel and arduino :-).
Got RH working well with the code below based on a linear trendline (to make the maths easy) and the data provided in the data sheet. Now for some reason I don't understand the temperture outputs on the data sheet are given in ohms and the output from arduino is showing 1023 which is presumably 60C or higher...? One thing is for sure - it's cold and wet here today.... any ideas?
int tempsense = 0;
int rhsense = 0;
int temp = 0;
int rh = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
tempsense = (analogRead(1));
rhsense = (analogRead(2));
temp = (tempsense/50);
rh = ((30.855*(rhsense/204.6))-11.504);
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println(" C ");
delay(100);
Serial.print("Humidity: ");
Serial.print(rh);
Serial.println("% ");
delay(1000);
}
Ahhh-ha I got the temp value to respond by engaging the pullup resitors on that pin - I just need to figure the formula out now as dividing the analogread value by 50 is clearly wrong !!!
Good that you are getting some data
What voltage are you getting from the temp sensor?
Now the datasheet gives the ohm of the temperature
so now we need to do some calculations.
You really need to work from a value given from the table, and by far the most accurate value to reach is the 0C, if your room is excactly 25C then fine use 25C
If you use the 0C, place sensor in plastic bag, crush icecube and place in another plastic bag and add a tiny amount of water to wet the crushed ice. Tie ice plastic bag tightly and wipe any moisture/water from the outside. Place icebag on top of baged sensor, The ice holds excactly 0C while melting!
Now read the voltage value from the Arduino (convert the 0 to 1023 value to voltage).
The formula for Amps = V/R (voltage divided by resistance)
The Arduino outputs 5V so if you read 4V then the voltage drop is 1V (5V - read value).
Amps = 1V/163810 Ohm
The amps should remain constant, so now that you have the konstant of I (amps) then you can find the voltage drop for the other temperatures by multiplying I*R = V (where I is your constant and R is the resistance of the table above).
The resistance drops when warmed up so it will eat less voltage.
I recomend to make another excel plot from the table above but with calculated voltage instead of Resistance:
X-axis: Voltage (or 0-1023 digital values)
Y-axis: Temperature
I think the temp part of the sensor is duff as the value goes from 908 down to 892 when droping from 22C to 0C which is less than 1 degree resolution!! I guess I'm stuck with just RH with this sensor.... but learnt loads so thanks for your time and knowledge
Thanks for sharing your work - very much appreciated. I have now had a go and finally got the sensor working On my arduino 328 it outputs sensible figures but when I load up onto a 168 the figures are quite a bit out - any idea why this should be?