I just built my second Arduino project that includes simple temperature reading using TMP36. The project is identical to this site.
I also tested out the sensor by following the instruction above and got reading of 0.75 volt at room temperature.
But as soon as I put this in breadboard I get around 98 F degree but steady reading (+/- less than 1). My room should be around 79, 80. My conversion from Celsius is correct.
I'm using computer's USB for power and using 5 volt output. Is the noise or other factor that I didn't consider? Thanks.
The USB power is not 5V but lower. However when the Arduino reads the analog value, it assumes that the 5V is 5.00V.
If the 5V is lower, the analogRead() returns a higher value.
A digital temperature sensor like the DS18B20 doesn't have that problem. But you need a library to read the temperature from the DS18B20.
Analog input is around 0.74 with Multimeter while UNO is running the loop with USB power from computer
Serial print says 0.86 via Serial monitor
Raw reading is 177 via analogRead()
Room thermometer is at 80
Calculated value in F is around 97 (36 C)
all values are approx to nearest integer value.
@jack wp, as suggested from the linked web site, I used two AA batteries and that read 0.75 at room temperature but Serial reading says around 0.86.
One thing I want to try is using 9V as suggested. But the reason I used USB was to feed the reading to computer so that I test the sensor and to log it there.
With that said, can I still use USB to collect data and use external power at the same time?
If not, what other method can I use to log data to computer? I can probably use Ethernet shield but trying to minimize additional hardware as I'm still new to arduino. I must be missing a big picture somewhere.
Jack, I figured that reading was necessary so I did one last night. The 5V is reading 3.26 V with Multimeter. I changed the value of 5.0 to 3.26 in code but that gave me wrong range value also. Can you help me adjust the formula?
Also, as suggested by others, I'll try using 9V external power. Hopefully, new calculation can adapt to that voltage also. Thanks for helping.
It is unusual that your 5V would be reading so low as 3.26. How are you getting your power?
You changed the formula, and it didn't read correctly, did it not go far enough, or did it go to far. Just for testing, you should be able to try other values in that formula to get a pretty close celebration, but for the long run, you should get your 5 volts, more accurate.
But with external power of 9V, I should be ok without calibration, right?
Well, that is not a given. I would have assume the 5v by USB via desktop computer would have been lots closer to 5 volts.
You need to hook it up and check all the voltages, to verify they are pretty accurate, then if so, "it should be ok".
You may find that the reading varies depending on what the computer is doing. You should never use 5v usb power as a voltage reference. I suggest you use the 3.3v pin as the reference instead. Read about the analogReference function.
Caltoa:
The USB power is not 5V but lower. However when the Arduino reads the analog value, it assumes that the 5V is 5.00V.
If the 5V is lower, the analogRead() returns a higher value.
A digital temperature sensor like the DS18B20 doesn't have that problem. But you need a library to read the temperature from the DS18B20.
Can anyone please expand on the first paragraph here, or point me in the direction of an explanation? Why would the USB power not be 5V, but be lower? Thanks
Using the code from the link and adjusting for my Arduino 5.0 volts which is a 4.811 volt ref the code as used in the instructable works fine and is within +/- 1.0 Degree C and converts to Deg F. just fine. When posting code please use code tags because it makes your code easier to follow. Anyway using A0 in and my own Vref here is what works.
//TMP36 Pin Variables
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
/* setup() - this function runs once when you turn your Arduino on. We initialize the serial connection with the computer
*/
void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
}
void loop() // run over and over again
{
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 4.811 / 1024; // My V Ref
// print out the voltage
Serial.print(voltage); Serial.println(" volts");
// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((volatge - 500mV) times 100)
Serial.print(temperatureC); Serial.println(" degress C");
// now convert to Fahrenheight
float temperatureF = (temperatureC * 9 / 5) + 32;
Serial.print(temperatureF); Serial.println(" degress F");
delay(1000); //waiting a second
}
On a USB note? The USB voltage is what it is to put it simply. I measure the 5 V pin on my board. That is what it is and when using a 5 volt ref in my code I adjust it accordingly. I normally use a 9 ~12 VDC external supply but still measure my Arduino 5 V pin which is then the onboard 5 volt reg output.
Sorry, initially I never caught this was an old thread.