Digital Thermometer With Arduino Uno and Lm35

by thunderrobo56 in Circuits > Arduino

166 Views, 0 Favorites, 0 Comments

Digital Thermometer With Arduino Uno and Lm35

IMG_3940.jpeg

It shows you the temperature with C symbol. C means Celsius

Supplies

IMG_3943.jpeg

This shows you the components

Circuit

IMG_3942.jpeg

tuis is the circuit


Code

#include <Wire.h>

#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd(0x27, 16, 2); // Address 0x27, 16 columns, 2 rows


const int lm35Pin = A0;


void setup() {

 lcd.begin(16, 2);

 Serial.begin(9600);

}


void loop() {

 float temperature = getTemperature();

 displayTemperature(temperature);

 delay(1000); // Update every second

}


float getTemperature() {

 int sensorValue = analogRead(lm35Pin);

 float voltage = sensorValue * (5.0 / 1023.0);

 float temperatureC = (voltage - 0.5) * 100.0;

 return temperatureC;

}


void displayTemperature(float tempC) {

 lcd.clear();

 lcd.setCursor(0, 0);

 lcd.print("Temp: ");

 lcd.print(tempC);

 lcd.print(" C");

}