Digital Thermometer With Arduino Uno and Lm35
by thunderrobo56 in Circuits > Arduino
196 Views, 0 Favorites, 0 Comments
Digital Thermometer With Arduino Uno and Lm35
It shows you the temperature with C symbol. C means Celsius
Supplies
This shows you the components
Circuit
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");
}