Hello back. Welcome back to Surilli playground. In this tutorial we will interface a 16x2 Liquid Crystal Display (LCD) with Surilli GSM so that can display temperature and humidity values from a DHT11. Interfacing is simple except the circuitry which becomes a little tricky. But you do not need to worry. This tutorial is made easy and as simple as possible and you can wire your hardware up and running within an hour. After all, this is what Surilli does. DIY In Minutes! So lets get started.
Liquid Crystal Displays (LCDs):A 16x2 LCD has 2 horizontal rows each comprising of 16 displaying character. This means that a total of 32 characters can be displayed on a 16x2 LCD. An LCD is used in many electronics projects to display the status of the process, voltage levels, sensor values, system health and the list goes on n' on. Lets now cut the theory part and jump to the hands-on.
PIN NUMBERING: The PIN numbering goes from left to right (1 - 16).
STEP 1: Setup Arduino IDE for SurilliMake sure you have selected the right port, board and processor for the Surilli as shown in the picture below and it is programmable (compile and upload “Blink” from File>Examples>Digital>Blink onto your Surilli to check if everything is working fine).
STEP 2: The circuitryThe circuitry is a little complex so we will go through it first. Complete your circuit connections and then move on to the next step.
The brightness of the LCD can be controlled by using a variable resistor connected at PIN3 (CONTRAST CONTROL) of the LCD. But to make it simple, connect it to the ground and it will work at full contrast and brightness as shown in Figure 1.
STEP 3: Upload & Burn Code Onto Surilli- If you do not have the DHT library, download it from the source given below. Unzip the downloaded .rar file and paste in into: This PC > Documents > Arduino > libraries.
- Now you have completed setting up your hardware and Arduino IDE. Copy and paste the Arduino sketch given below into your Arduino IDE and hit upload.
- After it is uploaded, the LCD will start to show printed data i.e. temperature and humidity values extracted from the sensor as shown in the Figure 2 below:
#include <LiquidCrystal.h>
#include <dht.h>
#define dht_apin 13 // Analog Pin sensor is connected to
dht DHT;
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = A0 , en = A1, d4 = 9, d5 = 10, d6 = 11, d7 = 12;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
}
void loop() {
DHT.read11(dht_apin);
int h = DHT.humidity;
int t = DHT.temperature;
if (t < 100 && h < 100) {
lcd.setCursor(0, 0);
String T = "Temperature=" + String(t) + "C";
lcd.print(T);
lcd.setCursor(0, 1);
String H = "Humidity=" + String(h) + "%";
lcd.print(H);
}
delay(1000);
}
That’s all for now. If you have any queries, visit surilli.io or contact our support. Stay connected with Surilli family for more amazing stuff :)
Comments