Let’s see how to interface Arduino with temperature sensor. LM35 is a three-terminal temperature sensing device. It is used to measure temperature in the range of -55°C to 150°C. It is a three-terminal device that produces an analog voltage proportional to the temperature of its surroundings. We can convert the analog output into digital using ADC. The sensitivity of LM35 is 10mV/degree Celsius it does not require any extra calibration (e.g. 300mV means 30℃). Its output is very precise. Supply voltage ranges from 4V to 30V.
Circuit Diagram of Arduino with temperature sensor:
Components Required:
- Arduino UNO R3 board
- Variable resistor 10kΩ
- Resistor 220Ω
- 8 bit LCD
- Mini breadboard
- LM35 temperature sensor
- Few wires & cable for power supply
Circuit connections:
The LM35 temperature sensor is powered by an Arduino board via VCC & GND pins.
The analog output pin of the LM35 temperature sensor is connected to the analog input pin A0 of Arduino.
10 K Ohm potentiometer controls the brightness of the panel.
The second pin is connected to pin 3 of the LCD.
First pin of potentiometer connected to + VCC.
Third pin of potentiometer connected to GND.
RS pin of LCD connects to digital pin 12 of Arduino UNO.
Pin E (Enable) connected to digital pin 11.
Pin D4 connects to pin number 5.
D5 pin connects to digital pin 4 of Arduino.
Pin D6 connects to digital pin 3.
Pin D7 connects to digital pin 2 of Arduino UNO.
R / W pin connected to the GND.
Pin 1 and pin 4 are connected to GND.
Pin 2 connected to + VCC.
The first and third pins of the potentiometer can be interchanged.
Working of Temperature sensor with code:
#include <LiquidCrystal.h> float temp; int sensor = A0; float tempc; float tempf; LiquidCrystal lcd (12, 11, 5, 4, 3, 2); The instance of the LiquidCrystal lcd shows LCD pins connected to the Arduino digital outputs. void setup () { // set the number of columns and the number of lines of lcd lcd.begin (16, 2); } void loop () { temp=analogRead(sensor); Read analog voltage from sensor and store it in a temporary float variable. tempc=(temp*4.88)/10; This line converts float value into °C. tempf=(tempc*1.8)+32; This line converts °C into Fahrenheit. lcd.setCursor(0,0); lcd.print("Temp in C = "); lcd.println(tempc); These two lines print Temperature value in °C. lcd.setCursor(0,1); lcd.print("Temp in F = "); lcd.println(tempf); Above two lines print value in Fahrenheit }
Arduino with temperature sensor Final Output:
#include <LiquidCrystal.h> int sensor = A0; float temp; float tempc; float tempf; LiquidCrystal lcd (12, 11, 5, 4, 3, 2); void setup () { lcd.begin (16, 2); } void loop () { temp=analogRead(sensor); tempc=(temp*4.88)/10; tempf=(tempc*1.8)+32; lcd.setCursor(0,0); lcd.print("Temp in C = "); lcd.println(tempc); lcd.setCursor(0,1); lcd.print("Temp in F = "); lcd.println(tempf); }
Here is the TinkerCAD Simulation of This project:
Conclusion:
- The above circuit is used to monitor the temperature in many places,
- In weather monitoring system.
- In farming fields
- Industrial places
- At home and anywhere there is a need for temperature data.