As part f a larger project which I think will benefit from a temperature sensor, I ordered a couple of TMP36 temp sensor ICs from an ebay supplier, since so much info about them exists online. I'm using a NANO and for my initial experiments, I powered it from the 3.3V NANO output, and fed the input to analog input A1. I also called analogReference(EXTERNAL) in my setup() call, and tied the AREF pin to the 3.3v pin as well (yes, I remembered to make the connection AFTER initialization completed). For a quick and dirty test, I'm basically doing the below in my loop. I'm printing output via a serial.println() statement, about every 2 second.
#define SECOND (1000 * 60)
#define aref_voltage 3.3
loop()
{
{
uint16_t tempReading = analogRead(A1);
float voltage = tempReading * aref_voltage;
float tempF, tempC;
voltage /= 1024.0;
static uint32_t display_timer = millis();
tempC = (voltage - 0.5) * 100; // .5V offset
tempF = (tempC * 9.0 / 5.0) + 32;
if ((millis() - display_timer) > (SECOND * 2)) // every 2 seconds
{
display_timer = millis();;
Serial.println(String("") + "A = " + tempReading + " V= "
+ voltage + " Temp = " + tempF + 'F'');
}
}
So the result was a display of a fairly constant 65 degrees F. But knowing the room was more like 72 was a little discouraging.
A = 217 V= 0.70 Temp = 67.88F
A = 217 V= 0.70 Temp = 67.88F
A = 215 V= 0.69 Temp = 66.72F
A = 217 V= 0.70 Temp = 67.88F
So I thought about the fact that this reading is only using about the first 1/4 of the usable A/D range. So I thought I might increase its accuracy by using one of the other analogReference() options available. The sensor output was only about .7 Volts, at the current output, so I set my analogreference(INTERNAL), which is supposed to to generate a 1.1 V analog reference. I changed my aref_voltage define to 1.1 as well. Finally I disconnected the AREF from the 3.3 v pin, though I continued to power the TMP36 from the 3.3V.
So the result, with the same calculations (except with the aref_voltage updated and the analogreference(INTERNAL) set) , was that I now had more realistic 71 degree output...
A = 666 V= 0.72 Temp = 70.78F
A = 666 V= 0.72 Temp = 70.78F
A = 664 V= 0.71 Temp = 70.39F
A = 662 V= 0.71 Temp = 70.00F
The good thing here is that more of the A/D counts are being used in the measurement, and I'm never going to need to measure beyond the 90s (F) anyway. Even 100 F would still be well below the max 1023 count of the A/D.
But the more disturbing thing was when I tried to test changing the temperature, and the TMP36 didn't seem to respond so well. OK, I realize this isn't a very scientific experiment, but I have a cheap "dime-store" digital thermometer, and if I hold its probe between my fingers it will quickly get to at least 90 in less than 1/2 a minute. Not so with this TMP36 setup. Holding the whole IC between my fingers (no, I'm not touching its wires), it rarely went beyond 75 degrees, even after a more than a minute.
A = 693 V= 0.74 Temp = 76.00F
A = 688 V= 0.74 Temp = 75.03F
A = 689 V= 0.74 Temp = 75.22F
A = 690 V= 0.74 Temp = 75.42F
A = 688 V= 0.74 Temp = 75.03F
I'm not too concerned about the different readings with the different voltage references, because I suspect it could be corrected by more accurately setting my aref_voltage define. After all, neither the 1.1V nor the 3.3V output on my NANO are that close (the 3.3 measures 3.379, and the 1.1 measures 1.153). So this could be corrected by a calibration "fudge" factor.
But my bigger concern is whether I'll have any accuracy once I get a few degrees past the nice 70 degree "room temp" range. Why couldn't I move the temp by more than 5 degrees with my fingers, when another thermometer move over 15 degrees doing the same thing? I thought maybe the problem was that I'm testing an a breadboard, and it might be acting like a big heatsync through its own pins. But after taking another TMP36 and soldering one two feet of very thin flexible wires, with a 3 pin header on the other side for easy plug in, the result was the same. I could tightly hold this IC all day, and it rarely exceeded 75 F.
Is this the best I can expect from TMP 36 ICs?