You are on page 1of 16

(/) Let's Make ...

Featured (/explore/) Write an Instructable Login (/account/login/) | Sign Up (/account/gopro)


(/about/create.jsp)

Classes (/classes/) Contests (/contest/) Forums (/community/?categoryGroup=all&category=all) Answers (/tag/type-question/?sort=RECENT)


(http://www.autodesk.com)

Teachers (/teachers/) advertisement

advertisement

About This Instructable

License:
8 252.267 views
271 favorites

(/file/FTHC5K1FVW22FQW/) adafruit
(/member/adafruit/)
Adafruit Industries
(http://www.adafruit.com/)

(/member/adafruit/)
Follow 673

Bio: 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 ... More (/member/adafruit/)

More by adafruit:

(/id/Logger-
(/id/Adaruit- (/id/Adafruit- Shield-
Resistor- Photo- Datalogging-
Helper/) Tutorial/) for-Arduino/)
Related

Erbbie - Desktop Smart


Garden (/id/Erbbie-Desktop-
Smart-Garden/)
by zacharyianhoward
(/id/Erbbie- (/member/zacharyianhoward/)
Getting started with the
Maxbotix sonar sensor -
quick start guide (/id/Getting-
started-with-the-Maxbotix-
(/id/Getting- sonar-sensor-q/)
What You'll Learn (/id/Tools-
and-Materials-for-Arduino/)
by bekathwia
(/member/bekathwia/)
(/id/Tools-
Internet Valentine
(/id/Internet-Valentine/)
by bekathwia
(/member/bekathwia/)
(/id/Internet-
Flora/Bluefruit Prototyping
Armband (/id/FloraBluefruit-
Prototyping-Armband/)
by Jessica Rajko
(/member/Jessica+Rajko/)
(/id/FloraBluefruit-

(/file/FFODOLCFVW22FQV/)

What is a temperature sensor?

An analog temperature sensor is pretty easy to explain, it's a chip that tells you
what the ambient temperature is!

These sensors use a solid-state technique to determine the temperature. That is


to say, they don't use mercury (like old thermometers), bimetallic strips
(http://en.wikipedia.org/wiki/Bimetallic_strip) (like in some home thermometers or
stoves), nor do they use thermistors (http://en.wikipedia.org/wiki/Thermistor)
(temperature sensitive resistors). Instead, they use the fact as temperature
increases, the voltage across a diode increases at a known rate. (Technically,
this is actually the voltage drop between the base and emitter - the Vbe - of a
transistor. By precisely amplifying the voltage change, it is easy to generate an
analog signal that is directly proportional to temperature. There have been some
improvements on the technique but, essentially that is how temperature is
measured.

Because these sensors have no moving parts, they are precise, never wear out,
don't need calibration, work under many environmental conditions, and are
consistent between sensors and readings. Moreover they are very inexpensive
and quite easy to use.

Some basic stats

These stats are for the temperature in the Adafruit shop, the Analog Devices
TMP36 (http://www.ladyada.net/media/sensors/TMP35_36_37.pdf) (-40 to
150C). Its very similar to the LM35/TMP35 (Celsius output) and LM34/TMP34
(Fahrenheit output). The reason we went with the '36 instead of the '35 or '34 is
that this sensor has a very wide range and doesn't require a negative voltage to
read sub-zero temperatures. Otherwise, the functionality is basically the same.

Size: TO-92 package (about 0.2" x 0.2" x 0.2") with three leads
Price:$2.00 at the Adafruit shop (http://www.adafruit.com/index.php?
main_page=product_info&cPath=35&products_id=165)
Temperature range: -40 degrees C to 150 degrees C / -40 degrees F to 302
degrees F
Output range: 0.1V (-40 degrees C) to 2.0V (150 degrees C) but accuracy
decreases after 125 degrees C
Power supply: 2.7V to 5.5V only, 0.05 mA current draw
Datasheet (http://www.ladyada.net/media/sensors/TMP35_36_37.pdf)

Step 1: How to Use a Temperature Sensor

(/file/F2GV32XFVW22FS4/)

(/file/FN38NEMFVW22FS3/) (/file/FQMOXG2FVW22FS2/) (/file/FUAL50PFVW22FS1/)

How to measure temperature!

Using the TMP36 is easy, simply connect the left pin to power (2.7-5.5V) and the
right pin to ground. Then the middle pin will have an analog voltage that is
directly proportional (linear) to the temperature. The analog voltage is
independent of the power supply.

To convert the voltage to temperature, simply use the basic formula:

Temp in Celsius = [(Vout in mV) - 500] / 10

So for example, if the voltage out is 1V that means that the temperature is
((1000 mV - 500) / 10) = 50 degrees Celsius

If you're using a LM35 or similar, use line 'a' in the image above and the formula:
Temp in Celsius = (Vout in mV) / 10

Testing your temperature sensor

Testing these sensors is pretty easy but you'll need a battery pack or power
supply.

Connect a 2.7-5.5V power supply (2-4 AA batteries work fantastic) so that


ground is connected to pin 3 (right pin), and power is connected to pin 1 (left pin)

Then connect your multimeter in DC voltage mode to ground and the remaining
pin 2 (middle). If you've got a TMP36 and its about room temperature (25
degrees C), the voltage should be about 0.75V. Note that if you're using a LM35,
the voltage will be 0.25V
(See image below)

You can change the voltage range by pressing the plastic case of the sensor
with your fingers, you will see the temperature/voltage rise.
(See image below)

Or you can touch the sensor with an ice cube, preferably in a plastic bag so it
doesn't get water on your circuit, and see the temperature/voltage drop.
(See image below)

Connecting to your temperature sensor

These sensors have little chips in them and while they're not that delicate, they
do need to be handled properly. Be careful of static electricity when handling
them and make sure the power supply is connected up correctly and is between
2.7 and 5.5V DC - so don't try to use a 9V battery!

breadboarded to-92 -

They come in a "TO-92" package which means the chip is housed in a plastic
semi-cylinder with three legs. The legs can be bent easily to allow the sensor to
be plugged into a breadboard. You can also solder to the pins to connect long
wires. If you need to waterproof the sensor, you can see the next step for an
Instructable for how to make an excellent case.

advertisement

Step 2: Project Examples


(/file/FXRI6OSFVW22FWI/)

(/file/FMA1VSJFVW22FWH/)
Arduino + XBee - Solar-Power Temperature Sen

Remote temperature sensor

BIOVID - a biofeedback editing system

Video editor that uses biofeedback (body temperature)

How to waterproof a LM35 sensor for use in a Remotely Operated Vehicle (robot
submarine) (https://www.instructables.com/id/Waterproof-a-LM35-Temperature-
Sensor/)

[A "smart coaster" lets you know when your coffee/tea is safe to drink
http://www.popsci.com/node/29314]

Some of these projects use thermistors (resistors that change their resistance
based on temperature), but can very easily be adapted to to a solid state sensor
like the TMP36

Step 3: Reading the Analog Temperature Data


(/file/FTS2VHIFVW22FYR/)
Temperature Sensor Tutorial! by
adafruit (/member/adafruit/) in electronics (/explore/category/technology/keyword/electronics/)

Download
Unlike the FSRh or (/id/Temperature-Sensor-Tutorial/)
photocell sensors we have looked 5 Steps Collection
at, the. TMP36 and friends I Made it! Favorite Share
doesn't act like a resistor. Because of that, there is really only one way to read
advertisement
the temperature value from the sensor, and that is plugging the output pin
directly into an Analog (ADC) input.

Remember that you can use anywhere between 2.7V and 5.5V as the power
supply. For this example I'm showing it with a 5V supply but note that you can
use this with a 3.3v supply just as easily. No matter what supply you use, the
analog voltage reading will range from about 0V (ground) to about 1.75V.

If you're using a 5V Arduino, and connecting the sensor directly into an Analog
pin, you can use these formulas to turn the 10-bit analog reading into a
temperature:

Voltage at pin in milliVolts = (reading from ADC) * (5000/1024)


This formula converts the number 0-1023 from the ADC into 0-5000mV (= 5V)

If you're using a 3.3V Arduino, you'll want to use this:

Voltage at pin in milliVolts = (reading from ADC) * (3300/1024)


This formula converts the number 0-1023 from the ADC into 0-3300mV (= 3.3V)

Then, to convert millivolts into temperature, use this formula:

Centigrade temperature = [(analog voltage in mV) - 500] / 10

Step 4: Simple Thermometer


(/file/FCHF7TZFVW22FZI/)

This example code for Arduino shows a quick way to create a temperature
sensor, it simply prints to the serial port what the current temperature is in both
Celsius and Fahrenheit

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


}

Step 5: Auto-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.
(http://blog.everythingrobotics.com/2009/06/09/reading-widget-battery-voltage/)
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


}

Comments

We have a be nice comment policy.


Please be positive and constructive. w I Made it! Add Images Post Comment

MSargent99 (/member/MSargent99/) 2016-10-22 Reply

You mentioned: "You can also solder to the pins to connect long wires."

Any idea how long the wires can be?

I would like to use one of these as an outside air temperature sensor by just
hanging a long set of wires out the window with the temperature sensor at the
end and leave the Arduino and power source inside the house nice and dry.

ShogunM (/member/ShogunM/) 2016-03-17 Reply

what sensor will i use underwater to detect object?

masterleo (/member/masterleo/) . ShogunM (/member/ShogunM/) Reply

2016-08-20
A sonar ?

good question !

MaryamO2 (/member/MaryamO2/) 2016-04-02 Reply

Can someone tell me what are the basic components of a temperature sensor ?

masterleo (/member/masterleo/) . MaryamO2 (/member/MaryamO2/) Reply

2016-08-20
plastic metal and silicon. I guess. You can find an answer on
wikipedia
rinksrides (/member/rinksrides/) 2016-04-30 Reply

Adafruit, note that diodes are NTC devices @ -2mV/K. Vf will drop across a
diode with rise in temperature.

masterleo (/member/masterleo/) . rinksrides (/member/rinksrides/) Reply

2016-08-20
so what should we do, knowing that ?

Breezy7 (/member/Breezy7/) 2016-08-04 Reply

Hi. I'm not an electrician but I am good with words & have a fair understanding
of this tutorial. Having said that, I'm about to ask a possibly stupid question. It
sounds like the temperature sensor has to be in a separate device if your phone
doesn't already have one installed. Then, one would have to connect that
device to the phone in order to get a temp reading. Is that true? Or is there a
way to have a sensor installed in your phone? I'm thinking the answer is 'no' on
the install. The phone in question isn't old, it IS Android but it's down the quality
totem pole & is nothing fancy. I'm thinking that the phone (Samsung J1)
wouldn't have all of the necessary components to do an install. Am I right?
Thanks for your time.
Breezy

masterleo (/member/masterleo/) . Breezy7 (/member/Breezy7/) 2016-08-20 Reply

buy a sensor on the internet, go to a local fablab, take an arduino wire


evrithing up and try it out

nchirca (/member/nchirca/) 2016-08-03 Reply

Thank you for your tutorial.

pkokkinis (/member/pkokkinis/) 2015-06-05 Reply

Is there a way to have two temp sensors on one Arduino and when one temp
drops below the other, it turns on a blower fan?

electric guy (/member/electric+guy/) . pkokkinis (/member/pkokkinis/) Reply

2016-03-24
uh great idea if it does plz tell me cause that would be awesome
s
and it would help me in what I'm building

RedstoneM (/member/RedstoneM/) . pkokkinis (/member/pkokkinis/) Reply

2015-09-22
2 analog inputs, compare them with
if(analogRead(portForSensor1) < analogRead(portForSensor2))
digitalWrite(fanPort);

Akin Yildiz (/member/Akin+Yildiz/) 2015-03-28 Reply


is there any way to use the ds18b20 temp. sensor in "analog mode" this way.?
no libraries, no conversions. i just need to see raw data/numbers (0-1024) on
serial monitor.
i just can't find a single post that doesn't involve libraries

thank you, very informative post.!

nyffeler (/member/nyffeler/) 2013-10-08 Reply

Since many years I'm using the LM35 in "metal case" for a lot experiments in
the physical chemistry practical course of the ETH Zurich. The metal case has
the advantage of a shorter time constant compared to TO-92 (~3s vs. >8s), but
it is much more expensive. Recently I replaced the LTC2408 ADC interfaced via
the lpt port by the ADS1248 and an Arduino for data transfer to the host.

snoop911 (/member/snoop911/) . nyffeler (/member/nyffeler/) 2014-01-16 Reply

Do you happen to have any code for retrieving data from the ads1248?
despite the input, the adc the adc result doesn't follow.

ashmnit (/member/ashmnit/) 2012-06-05 Reply

I know some detail about thermocouples which tried to outline in the site
http://www.about-thermocouples.com (http://www.about-thermocouples.com)
But i came to know about such IC first time.Can it be used to display
temperature directly.

TerryKing (/member/TerryKing/) 2011-06-01 Reply

I would think about going to the Digital sensor DS18B20. A how-To for Arduino
is here: http://arduino-info.wikispaces.com/Brick-Temperature-DS18B20

mattadamsnet (/member/mattadamsnet/) 2011-01-05 Reply

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.

mbainrot (/member/mbainrot/) 2010-10-11 Reply

From memory there is a way to change vref so you can do the 3.3v scale on a
5v arduino.
Be careful as from memory you can damage the 'druino if you feed it 5v when
the ADC is expecting 3.3v

dgallimore (/member/dgallimore/) 2010-07-29 Reply

This is great! I've never found such a simple explanation as to how to use an
Arduino before. Could you tell me though, what's the maximum length that the
wires can be between the Arduino and sensor? Thank you for a great 'ible!

johnnyhellfire (/member/johnnyhellfire/) 2010-06-09 Reply

This was a great idea and has taught me a lot about this platform. had a
suggestion thought, how bout if you can find a way to put the read out on a pc
and a built in lcd screen, that way you can take this anywhere and it ll let ya tell
you the temp where ever you are. the applications in ghost hunting would be
tremendous.

Plasmana (/member/Plasmana/) 2009-06-16 Reply

Wow, they are so much you can do with the Arduino, I must get my self one...

ReCreate (/member/ReCreate/) . Plasmana (/member/Plasmana/) Reply

2009-06-17
Yeah, I may get myself one...

Plasmana (/member/Plasmana/) . ReCreate (/member/ReCreate/) Reply

2009-06-17
Thats cool

ReCreate (/member/ReCreate/) . Plasmana (/member/Plasmana/) Reply

2009-06-17
Yeah

Plasmana (/member/Plasmana/) . ReCreate (/member/ReCreate/) Reply

2009-06-18
lol

ReCreate (/member/ReCreate/) . Plasmana (/member/Plasmana/) Reply

2009-06-18
Laugh out loud...

Plasmana (/member/Plasmana/) . ReCreate (/member/ReCreate/) Reply

2009-06-19
Meh, 'lol' is easier to type. :-)

ReCreate (/member/ReCreate/) . Plasmana (/member/Plasmana/) Reply

2009-06-25
I'm getting myself an arduino(and now that i am typing it more
often i now know how to spell it right! :P), The lowest price i found
anywhere on the internet(blagonet, blagoshpere lol what did i say lol? lol)
at $27.9869 American dollars! But it is the Older one, From 07 the latest
one from 09 is the one i want for like 3 dollars more at 29.99 American
Dollars. On ebay i found one for 19.99, but of course, its a fake, coming
from hong kong and having more than 10000 of them...so yeah...

andros1200 (/member/andros1200/) . ReCreate (/member/ReCreate/) Reply

2009-07-11
Get the Duemilanove. It's worth the extra $3. >.> It automatically
switches to the power source your using, so you don't have that annoying
jumper, and with the ATMega328p it has twice as much storage space for
sketches and twice as much ram and EEProm compared to the
Diecimillia.

Heres a good place to get one:


http://www.sparkfun.com/commerce/product_info.php?products_id=666
(http://www.sparkfun.com/commerce/product_info.php?products_id=666)

If you havn't already gotten one.

ReCreate (/member/ReCreate/) . andros1200 (/member/andros1200/) Reply

2009-07-11
I'm getting a duemilanove from some place for about 27 dollars,
look for my topic about it

andros1200 (/member/andros1200/) . ReCreate (/member/ReCreate/) Reply

2009-07-12
Just be sure to build a robot that takes over the world and it has
to look like this:
http://bbs.chinadaily.com.cn/attachments/month_0805/cute%20little%20bunny_LZcNR0iKF5qw.jpg
(http://bbs.chinadaily.com.cn/attachments/month_0805/cute%20little%20bunny_LZcNR0iKF5qw.jpg)

ReCreate (/member/ReCreate/) . andros1200 (/member/andros1200/) Reply

2009-07-12
lol, I would need an arduino nano XD

ReCreate (/member/ReCreate/) . Plasmana (/member/Plasmana/) Reply

2009-06-19
GRRR

llanyort (/member/llanyort/) 2009-07-02 Reply

how many seconds do i need to wait between polling the sensor ? i would like
to poll the sensor every .5 - 1 second. is this feasible ?

PaloAltoMark (/member/PaloAltoMark/) 2009-06-18 Reply

Artificial Intelligence: Thanks for your help. The link you provided to the wiki was
very helpful. It seems that type K thermocouples are the most practical for
hobbyist use. For those interested, you can purchase a type K for $6 at the
below link: http://www.virtualvillage.com/thermocouple-with-14-x-4-type-k-
probe/sku003820-031. (http://www.virtualvillage.com/thermocouple-with-14-x-4-
type-k-probe/sku003820-031.) I'm sure there are plenty of other sources as
well; (If your oven came with a meat probe, you have a thermocouple)
PaloAltoMark (/member/PaloAltoMark/) 2009-06-17 Reply

Is anyone aware of similar temperature switches that would work at high


temperatures such as those in a BBQ grill (200-600 degrees F)?

kikiclint (/member/kikiclint/) . PaloAltoMark (/member/PaloAltoMark/) Reply

2009-06-17
I know they make thermistors and thermocouples which would
work in that range.

PaloAltoMark (/member/PaloAltoMark/) . kikiclint (/member/kikiclint/) Reply

2009-06-18
Thanks much for the help

Artificial Intelligence (/member/Artificial+Intelligence/) . PaloAltoMark


(/member/PaloAltoMark/) 2009-06-17 Reply

For measuring such high temperatures, you may want an other type of
temperature sensor called a thermocouple
(http://en.wikipedia.org/wiki/Thermocouple).

ReCreate (/member/ReCreate/) 2009-06-17 Reply

It's shaped like a transistor?

Swishercutter (/member/Swishercutter/) 2009-06-16 Reply

Great Instructable. $2 seemed high for the TMP 36...I found them on Digikey for
a bit less, $1.35 http://search.digikey.com/scripts/DkSearch/dksus.dll?
Detail&name=TMP36GT9Z-ND
(http://search.digikey.com/scripts/DkSearch/dksus.dll?
Detail&name=TMP36GT9Z-ND) Prices drop as you go higher in quantity.

jj37 (/member/jj37/) 2009-06-16 Reply

Great instructable 4 stars and thanks I always had a bit of difficulty with
accuracy.

ReCreate (/member/ReCreate/) 2009-06-15 Reply

I never knew about these before! Very interesting!

I More Comments

advertisement
Ad
Descargar manual
Descarga manuales gratis con AtoZManuals
free.atozmanuals.com

Newsletter About Us
Let your inbox help you discover our best Who We Are (/about/)
projects, classes, and contests. Instructables Advertise (/advertise/)
will help you learn how to make anything! Contact (/about/contact.jsp)
Jobs (/community/Positions-available-at-Instructables/)
enter email I'm in!
Help (/id/how-to-write-a-great-instructable/)
Find Us Resources
Facebook (http://www.facebook.com/instructables) For Teachers (/teachers/)
Youtube (http://www.youtube.com/user/instructablestv) Residency Program (/pier9residency)
Twitter (http://www.twitter.com/instructables) Gift Premium Account (/account/give?sourcea=footer)
Forums (/community/?categoryGroup=all&category=all)
Pinterest (http://www.pinterest.com/instructables)
Answers (/tag/type-question/?sort=RECENT)
Google+ (https://plus.google.com/+instructables)
Sitemap (/sitemap/)

Terms of Service (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |


Privacy Statement (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |
Legal Notices & Trademarks (http://usa.autodesk.com/legal-notices-trademarks/) | Mobile Site (https://www.instructables.com)
(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)
2017 Autodesk, Inc.

You might also like