In this article, we are going to make a device That can Sense and Display Temperature on LCD and control LED by Temperature. We are going to learn how to interface the LM-35 Temperature Sensor and Arduino along with Arduino code.
We are going to use the following components for this project:
- Arduino MEGA 2560 microcontroller
- LM35 Temperature Sensor
- 16X2 LCD Display
- LEDs
- 10K Registers
- Bread Board and Wires.
The Arduino Mega 2560 is a powerful microcontroller board based on the ATmega2560 microcontroller. This is one of the popular Arduino boards in the Arduino family. It has 54 digital i/o pins. 14 pins can be used as PWM pins, 16 pins can be used as analog inputs, 4 UARTs which are known as hardware serial ports, a USB connection, a power jack, a reset button, etc. It contains everything needed to support the microcontroller. We have to simply connect it to a computer with a USB cable or we can power it with an AC-to-DC adapter or battery to get started.
Arduino Mega-2560 |
LM-35 sensor is a temperature sensor that can be connected to an Arduino board to measure the current temperature of any place. it's an analog linear temperature sensor. The output voltage varies linearly with a change in temperature. This sensor has three pins (VCC, GND, and out). The pinout of LM35 is shown in the figure below:
LM-35 Temperature Sensor |
LM35 Interfacing with Arduino Mega-2560:
The connection between Arduino mega and LM35 is very simple. We are going to connect LM35 VCC to Arduino VCC, LM35 GND to any on the Arduino GND, and Vout to Arduino Ao analog pin.
|
QC1602A 16x2 LCD display is an LCD display with 16 columns and 2 rows that can be connected to an Arduino board to display any character or string.
16X2 LCD Display |
16x2 liquid crystal display (LCD) with Arduino Board:
Let's connect the LCD to the Arduino board. First, we power up the LCD display by connecting LCDs VSS and VDD pin to boards GND and 5v pin respectively.
As the RS pin or register select pin is used for sending commands or data to the LCD (For example if the RS pin is set on low commands to the LCD like setting the cursor to a specific location, clearing the display, turning off the display and so on, and when RS pin is set on High state commands like data or characters to the LCD) we will connect this pin with boards a PWM pin-like pin 12. After setting up we can send commands to LCD like this:
lcd.setCursor(0, 1);
The RW pin is used to read from LCD or write to LCD. As we just wrote to the LCD, we connect RS pin boards GND pin for the low state.
The E pin enables the writing to the registers or the next 8 data pins from D0 to D7 we connect this E pin to boards with any PWM pin-like pin 10. We set the pin by writing this
LiquidCrystal lcd (12, 10, 5, 4, 3, 2);
Then we connect the LCDs data bus line D4-D7 to the board’s 4 PWM pin-like pins 5,4,3,2 respectively. We set this pin by writing this
// LiquidCrystal lcd (RS, E, D4, D5, D6, D7);
LiquidCrystal lcd (12, 10, 5, 4, 3, 2);
Pin A and K is used to set the backlight. So, we connect pin A, K
to boards pin7(PWM) and GND respectively. We set the backlight by writing like this:
int backLight = 7;void setup() {pinMode(backLight, OUTPUT);//sending commands to set the backlight to high (1)digitalWrite(backLight, HIGH);}
Pin V0 is used to set the display contrast. So, we connect pin V0 to board pin8(PWM). We can also use a potentiometer to control the contrast or we can set the contrast by writing like the following:
//setting up pin 8 to contrast
int contrast = 8;
void setup() {
pinMode(contarst, OUTPUT);
//sending commands to set the contrast to high(1)
digitalWrite(contrast, HIGH);
//or analogWrite(contarst, 250);//value from 0-255
}
LCD Display connection with Arduino:
From LCD |
TO microcontroller |
Vss |
GND |
Vdd |
5v |
Vo |
Pin 8 |
RW |
GND |
RS |
Pin 12 |
EN(Enable) |
Pin 10 |
D4 |
Pin5 |
D5 |
Pin4 |
D6 |
Pin 3 |
D7 |
Pin 2 |
A |
Pin7 |
K |
GND |
LED Indicator connection with Arduino:
Finally, we can connect an LED light as an indicator of high or low temperature. We will connect LED to an Arduino 13-number digital pin.
LM-35 Temperature Sensor and LCD Display Arduino Code
The program is simple and straightforward. The Arduino program for the Temperature Monitor system with LM-35 Temperature Sensor and Arduino is given below:
Final Outcome of the Project:
Temperature Monitor using LCD Display |
Post a Comment