Skip to content
Advertisements

Simplest Arduino based thermometer using LM35 and LCD i2c screen

Hi everyone, this is a quick diy thermometer based on Arduino and LM35 temperature sensor and shown on a LCD I2C screen

 

Wiring:

 

LCD i2c Library: Download library

 

Code:

Download .ino

//Arduino Thermometer using LM35DZ sensor with a LCD display

//SurtrTech Youtube channel

#include <Wire.h> //Libraries for I2C and LCD

#include <LCD.h>

#include <LiquidCrystal_I2C.h>

float temp;   //Variable where we will stock the temperature value

int tempPin = 0; //Pin used with the sensor output here it's A0

#define I2C_ADDR 0x27 //I2C Adress

#define BACKLIGHT_PIN 3 //LCD Stuffs :D

#define En_pin 2

#define Rw_pin 1

#define Rs_pin 0

#define D4_pin 4

#define D5_pin 5

#define D6_pin 6

#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup() {

  Serial.begin(9600);

  lcd.begin (16,2);

  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

  lcd.setBacklight(HIGH);

  lcd.home ();

}

void loop()

{

  temp = analogRead(tempPin); //Reading the value from the analog input

  temp = temp * 0.48828125; //Sensor calibration to get the real value

  lcd.clear();

    lcd.setCursor (0,0); //Start writing on 0.0 on lcd screen

    lcd.print("Temperature");

    lcd.setCursor (0,1);

    lcd.print(temp); //Temperature value

    lcd.print(" C"); //Celsius of course :D

   

     delay(1000); //Refresh every 1s

}

 

Advertisements

Yassine View All

Electronics, Automation engineering student... I try to share my little experience with other electronics amateur.

One thought on “Simplest Arduino based thermometer using LM35 and LCD i2c screen Leave a comment

  1. Good night;
    Below is the correct Source Code, since the one on your Site contains some errors:

    //Arduino Thermometer using LM35DZ sensor with a LCD display

    //SurtrTech Youtube channel

    #include //Libraries for I2C and LCD

    #include

    #include

    float temp; //Variable where we will stock the temperature value

    int tempPin = 0; //Pin used with the sensor output here it’s A0

    #define I2C_ADDR 0x27 //I2C Adress

    #define BACKLIGHT_PIN 3 //LCD Stuffs 😀

    #define En_pin 2

    #define Rw_pin 1

    #define Rs_pin 0

    #define D4_pin 4

    #define D5_pin 5

    #define D6_pin 6

    #define D7_pin 7

    LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

    void setup() {

    Serial.begin(9600);

    lcd.begin (16,2);

    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

    lcd.setBacklight(HIGH);

    lcd.home ();

    }

    void loop()

    {

    temp = analogRead(tempPin); //Reading the value from the analog input

    temp = temp * 0.48828125; //Sensor calibration to get the real value

    lcd.clear();

    lcd.setCursor (0,0); //Start writing on 0.0 on lcd screen

    lcd.print(“Temperature”);
    lcd.setCursor (0,1);

    lcd.print(temp); //Temperature value

    lcd.print(” C”); //Celsius of course 😀

    delay(1000); //Refresh every 1s

    }

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s