I started with the first (uncalibrated) listing, and started making changes (bringing the reading/calculation out to a function etc). It was working great. Then I added calibration as described, and my readings (see below) shot up unrealistically (the originals were about room temp)
I am inclined to believe the first readings as they are closer to the real room temp than the higher ones. So... after a few tries, I tried both pieces of example code...with the same results!
Uncalibrated:
0.71 volts
21.29 degress C
70.32 degress F
Calibrated:
189
5.69V power supply
0.81 volts
31.11 degress C
88.00 degress F
I am setup as described on the tutorial page. My arduino is a brand new dumenilove that I just got yesterday.
Any idea whats up here? I am kind of stumped. If it matters, I am using the USB connection for power (since thats how I am reading the sensor anyway)
I found two things. The first was an article that talked about changing the BANDGAPREF and that, after doing so, the first value should be thrown away.
On a fluke I started throwing away one read of it on every loop. This stabilized my measured power supply voltage at 5.12 V, as can be seen from this sample (I let it run for a while each time:
210
5.12V power supply
0.73 volts
23.50 degress C
74.30 degress F
Much closer to the "uncalibrated". Stable 5.12 every time instead of fluctuating between 5 and 5.7. So now it becomes a question of the 5.12 factor, or the 5.0.
My voltmeter measures 5.0 steady. I think I may try a proper calibration test as soon as I get a chance, but so far so good.
crush a icecube or 5 and put in a plastic bag with a bit of water (about icecube worth of water), tie the bag closed. Dry well on the outside and put on top of sensor.
While the Ice is melting it has a constant temp of 0C (if the water is pure, so use deionised water or car battery water (not battery acid, but the water to dillute it) if you can get that at the petrol station).
This is your constant 0C, the voltage level read form this will give you the offset voltage (it should be 0.500V)
If you get another value, then your sensor is not calibrated correcly.
Thanks, thats pretty much what I thought. I actually picked up some shrink wrap tubing today, since I was planning to wrap the sensors for final use anyway (measuring water temp actually).
Though, I am really fascinated by this BANDGAPREF reading.
If I just read it as the tutorial specifies:
int refReading = analogRead(BANDGAPREF);
float supplyvoltage = (1.05 * 1024) / refReading;
I get about 5.6 volts, it bounces around a bit, but around 5.6.
If I do the analogRead twice, and toss the first value, I get 5.12 steady.
If I put a delay as small as 5 ms between the reads, I get 4.89 steady.
This really makes me look at the articles that talk about measuring the supply voltage. I know I must be missing something subtle, but, so far, I am not sure what it is.
In any case, I will try the ice trick. Probably try boiling water too. Thanks
for accurate temperature of boiling water you need the absolute air pressure, that's why 0C is easier, 0C is steadier value.
The freezing/melting point is pressure dependent too but not as much.