Tutorial: Digital Termometer with Arduino and 16x2 LCD Display

This tutorial shows an interesting way to read the temperature from the environment with the Arduino, and shows it on a LCD 16x2 display (in Fahrenheit), by using some elements from its programming and the temperature LM35DZ sensor.

For that, it will be necessary the following components:

- 1 Arduino board

- 1 LCD 16x2 display

- 1 10K potentiometer

- 1 Temperature LM35 sensor

- Jumpers for connection

This sensor captures the external temperature and converts it into a corresponding voltage value. In this circuit, we connect the output Vo of the sensor to the Arduino’s A0 pin, which converts it to a float value of temperature, and then, exhibits it on the LCD. The 10K potentiometer adjusts the contrast of the display.

 

Now, set up the circuit below with the Arduino and the other components:  

And then, open the Arduino’s IDE and enter the following code:

 

#include  <LiquidCrystal.h>         // Include the library to use a LCD display

#define          sensor           0        // Define the A0 pin as “sensor”

 

int  Vin;           //  Variable to read the value from the Arduino’s pin

float  Temperature; //  Variable that receives the converted voltage value to temperature

float     TF; // Variable to receive the converted value from  ºC to ºF

 

LiquidCrystal  lcd    (12, 11, 5, 4, 3, 2); 

/* The function above declares which Arduino’s pins will be used for controlling the LCD */

void  setup()

{

  lcd.begin(16, 2);                            //  It tells the Arduino that the display is a 16x2 type

  lcd.print("Temperature: ");           //  Send the text to the screen of the display.

}

void  loop()

{

  Vin = analogRead (sensor);  /*   Tells the Arduino to read the pin and stores the value in “Vin” */

  Temperature=(500*Vin)/1023;  /* Converts the voltage value into temperature and stores it into the “Temperature”  variable  (in  ºC)*/

TF = ((9*Temperature)/5)+32; // Converts  ºC to ºF

  lcd.setCursor(0, 1);           // Moves  the cursor of the display to the next line

  lcd.print(TF);    // Exhibits the value of the temperature on the display

  lcd.print(" F");         // Writes “F” to indicate that it is in Fahrenheit scale.

 

  delay(1000);  //  Waits for a second to read the pin again

}

In the end, upload the code to your Aduino.

Your project to show the temperature is ready!!! We hope you have enjoyed. Any doubts, post here.

Note: The LM35DZ sensor converts temperature values from -55ºC to 150ºC.

If somebody is interested, this is the explanation for the conversion calculation from voltage to temperature done by the software.

In this sensor, for each 1ºC received, the Vo output is added in 10mV, in a range from 0 to 5V, with 10 bits of resolution for Analog/Digital conversion (1024 different values to represent the temperature).

Thus, the maximum value (1023, therefore it is from 0 to 1023) will be 5V. The half will match 511 or 2.5V, and so forth. For calculation purposes, there would be 5V in the output of the sensor for a temaprature value of 500ºC (which is different in a real situation). However, this regard lets us generalize it to the following relation:

Temperature  ----- Vin

         500ºC  ----- 1023              (maximum values)

 

So, there will be:

Temperature = (500*Vin)/1023, but as it is in ºC and we want in ºF, we convert it:

TF = ((9*Temperature)/5)+32, and this is the printed value on the LCD display.

 

See you next time!!!

 

Reference links:

- arduino.cc/en/Tutorial/LiquidCrystal

- "LM 35" datasheet

Views: 27216

Tags: 16x2, LCD, LM35, display, environment, sensor, temperature

Comment by HaimaN Adel on January 26, 2013 at 8:42am

thank you

Comment by Roman Piątkowski on July 18, 2013 at 6:18am

There's n error in your code.

Must change  Temperature=(500*Vin)/1023 to  Temperature=(500.0*Vin)/1023.0 becouse temperature over ~30 makes minus values on lcd (Vin*500 is over limit of 32k) 

Comment by Angelo Palloni on August 23, 2013 at 10:10am

I love this setup.

Comment by Angelo Palloni on August 23, 2013 at 10:11am

it worked perfect for me, first time.

Comment

You need to be a member of GarageLab (arduino, electronics, robotics, hacking) to add comments!

Join GarageLab (arduino, electronics, robotics, hacking)

Latest Activity

GarageLab posted a blog post

Three men receive mind-controlled bionic hands

Three men have been equipped with bionic hands which they …See More
21 hours ago
Rey Canedo is now a member of GarageLab (arduino, electronics, robotics, hacking)
22 hours ago
Devin Moss posted a discussion

Free-spinning high torque DC motor

I'm looking for a high-torque DC motor (able to lift 20 pounds) which, when turned off, will spin…See More
Saturday
Marcelo Rodrigues posted a blog post
Saturday
Profile IconJack Gromek, pratik and KEKELI LOGAH joined GarageLab (arduino, electronics, robotics, hacking)
Friday
GarageLab posted a blog post

Stanford’s cheap nanomaterial filter could solve the air pollution problem

The rapidly increasing industrialization in many parts of the world comes with economic benefits,…See More
Friday
GarageLab posted a blog post

Blub Uno Clock Displays Time with One Nixie Tube

We’ve seen our share of Nixie tube clocks, but the Blub Uno is different. This is a clock that…See More
Thursday
GarageLab's blog post was featured

LEGO X Converts Creations into 3D Models in Real Time: Body and Soul

Created by Gravity Research Club, LEGO X creates a 3D model of whatever you’re building while…See More
Wednesday
sathiyakumar is now a member of GarageLab (arduino, electronics, robotics, hacking)
Feb 24
GarageLab posted blog posts
Feb 24
Profile Iconaymen hleli, gunawan eko, Dean Sanders and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Feb 23
GarageLab posted a blog post

Street Fighter Played with Pianos: Sound Fighter

Back in 2014 we saw an piano that was turned into…See More
Feb 23
GarageLab posted blog posts
Feb 20
Profile IconRobert Choi and Pierre Gelinas joined GarageLab (arduino, electronics, robotics, hacking)
Feb 20
David Wachter commented on GarageLab's blog post DARPA is developing a sensing bionic hand
"This would be nice for all of the military amputees that have been 'produced' since the…"
Feb 18
GarageLab's blog post was featured

AirBoard: The Flying Segway

Currently up for funding on…See More
Feb 18
GarageLab posted a blog post

DARPA is developing a sensing bionic hand

Not content just to chip in creating better mind-controlled bionic limbs, DARPA is focusing on…See More
Feb 18
Profile IconAmr Anwar and recca joined GarageLab (arduino, electronics, robotics, hacking)
Feb 18
GarageLab posted a blog post

Voltera V1 Circuit Board Printer: Print-A-Sketch

The latest in the growing niche of circuit board printers, the Voltera V1 can print up to two…See More
Feb 16
GarageLab posted a blog post
Feb 13

© 2015   Created by Marcelo Rodrigues.

Badges  |  Report an Issue  |  Terms of Service