Project tutorial
Temperature on an LCD

Temperature on an LCD

Check room, body, and outdoor temperatures with an easy to read LCD display.

  • 5,548 views
  • 6 comments
  • 11 respects

Components and supplies

About this project

In this simple project, I was searching around for a new way to read the temperature accurately. The problem with just lcd.print(Value) was that there was a huge fluctuation in the readings. What this code does is continuously add a variable using (+=) to the temperature until a condition is fulfilled. It then exits and calculates the average before printing it.

Code

tmpslcd.inoC/C++
#include <LiquidCrystal.h>//imports the libraries
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);//sets the LCD pins
const int sensorPin = A0;
float fntemp;
float sum;
float voltage;
int sensorVal;
int count;
void setup() {
  Serial.begin(250000);//begins serial interface
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  sum = 0.0;
  voltage = 0.0;
  fntemp = 0.0;
  sensorVal = 0;
  count = 0;  
}

void loop() {  
  if (count < 30) {//value represents the number of values averaged. Can
    sensorVal = analogRead(sensorPin);//be changed
    voltage = (sensorVal/1024.0)*5.0;//conversion of sensor value to °C
    sum += ((voltage-0.5) * 100);
    count ++;
    delay(1);//needed to recieve different vslues each time
  }
  else {
    fntemp = sum / count;//averaging
    count = 0;
    sum = 0.0;
  }
  Serial.println(fntemp);
  lcd.print(fntemp);
  lcd.print(" C");
  lcd.setCursor(0, 1);
  
  delay(50);//delay to prevent over flashing of the LCD
  lcd.clear();
  delay(0);
}

Schematics

Temperature Sensor
Assemble, Upload and watch it run!
temperature_sensor_msJox7Ivs8.fzz

Comments

Similar projects you might like

Ultrasonic Sensor with Alarm, LCD and Temperature

Project tutorial by MichDragstar

  • 27,670 views
  • 10 comments
  • 36 respects

DHT11 Humidity + Temperature Sensor with 16x2 LCD display

Project showcase by onatto22

  • 53,200 views
  • 13 comments
  • 58 respects

Clock without using RTC in Arduino with Temperature and humi

Project tutorial by ahmadordi

  • 30,463 views
  • 31 comments
  • 67 respects

Arduino Temperature - Humidity - Rain Sensor

Project showcase by Mako

  • 25,187 views
  • 7 comments
  • 25 respects

Portable Temperature Station

Project tutorial by Isaac100

  • 13,651 views
  • 10 comments
  • 42 respects
Add projectSign up / Login