3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Temperature Sensor Tutorial!

Step 5Auto-calibrating supply-independent thermometer


This example is similar to the one above except that now we use a special trick where we read the analog value of a fixed reference voltage inside the chip and then use that to make a precise calculation. This also means it will work right no matter what voltage the Arduino is running at!

//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

#define BANDGAPREF 14 // special indicator that we want to measure the bandgap

/* 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
delay(500);
}

void loop() // run over and over again
{
// get voltage reading from the secret internal 1.05V reference
int refReading = analogRead(BANDGAPREF);
Serial.println(refReading);

// now calculate our power supply voltage from the known 1.05 volt reading
float supplyvoltage = (1.05 * 1024) / refReading;
Serial.print(supplyvoltage); Serial.println("V power supply");

//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);

// converting that reading to voltage
float voltage = reading * supplyvoltage / 1024;

// 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
}

« Previous StepDownload PDFView All StepsNext Step »
1 comment
Jan 5, 2011. 7:28 AMmattadamsnet says:

174
6.18V power supply
0.84 volts
33.88 degress C
92.98 degress F

173
6.22V power supply
0.84 volts
33.76 degress C
92.76 degress F

Heres the problem, .. its more like 70-72 degrees in here and im using USB power which my volt meter measures at 5.10v, the sensor @ the sensor is measuring .583v help me out here.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
234
Followers
17
Author:adafruit(Adafruit Industries)
All-original DIY electronics kits - Adafruit Industries is a New York City based company that sells kits and parts for original, open source hardware electronics projects featured on www.adafruit.com ...
more »