Tag Archives | lcd

Portable Temperature & Humidity Monitor System

The purpose of this build is to become more familiar with how to develop a free-standing Arduino system using the Arduino Nano. The Nano is a smaller equivalent to the Arduino Uno, but with fewer interface options. It obviously occupies less space since it is a smaller footprint while having reduced overall dimensions. The project makes use of a DHT temperature and humidity sensor that interfaces with the Nano and it includes a 16×2 LCD display to indicate measurement results.

As temperature and humidity variations appear within the immediate environment, there are readings at the sensor read into the Arduino Nano. The system is configured and programmed to accept those readings and report them to the liquid crystal display. The ambient conditions surrounding the sensor are processed within the Nano to translate sensor data into usable information at the display.
The system is powered by a 9V battery stepped down to a regulated 5VDC supply. The power module supports the Nano, DHT sensor, and LCD display. The power supply module’s detachability renders the Nano accessible for ease programming and alternative power through the Nano’s USB receptacle. This setup removes any permanent tethering with extended life through a power supply module’s USB-A receptacle if a power bank is used instead. The 10K-ohm potentiometer is a brightness control for the LCD display.

The system schematic makes no use of passive components except for the single variable resistor (10K-ohm potentiometer). The direct connections between the Nano and display provide for desired simplicity during build and diagnostics. The DHT11 sensor pin-out provides for clarity about necessary connections at the Nano.

1602A LCD Display Pinout

PinSymbolFunction
1VSSGround
2VDD+5VDC
3V0Contrast
4RSRegister
5R/WRead/Write
6EEnable
7D0Data
8D1Data
9D2Data
10D3Data
11D4Data
12D5Data
13D6Data
14D7Data
15AAnode (+5VDC)
16KCathode (Ground)

Arduino Setup:

To program, edit, or update the firmware within the Arduino Nano, it is necessary to attach a USB connection from computer. The serial connection is made to update settings, configure the Arduino IDE (Sketch)
The conventional structured programming setup applies to this project as with any other. The top of the program specifies libraries to support physical objects or devices in the project such as the DHT sensor and the LCD display in this case. Above the void set up procedure block, relevant variables are declared by data type (integer, float, etc). The void setup initiates devices, Arduino functions, or GPIO pins. The loop functions are the procedure itself that iterates to execute the main process by which the program operates.
To set up and program the Nano, it is necessary to select it under the Board option from the Tool menu. The Port option within the Tools menu may require selection or setup as COM1 – COM5 (or some COM#) to establish a connection to a computer for programming and to run the Serial Monitor under this same Tools menu selection.
To install relevant external device libraries (such as a temperature sensor, or display), it might be necessary to add the device to the Arduino Sketch folder on its host computer (usually C:\Users\[name]\Documents\Arduino\libraries).
An example to install or update a device library from the Manage Libraries selection of the Tools Menu option, provides a dialog box to search by library name or description. In this example, “DHT” is keyed in to find the temp & humidity sensor for installation.
Once the Arduino Sketch IDE is set up and configured with the correct board, serial COM connection, and relevant libraries, the code becomes operable and the serial monitor confirms proper use and setup (if/as applicable).

Code Setup:

#include <DHT.h>
#include <LiquidCrystal.h>
int rs=7;
int en=8;
int d4=9;
int d5=10;
int d6=11;
int d7=12;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);

int sensePin=2;
DHT HT(sensePin,Type);
float humidity;
float tempC;
float tempF;
int setTime=500;
int dt=1000;

void setup() {
Serial.begin(9600);
HT.begin();
delay(setTime);
lcd.begin(16,2);
}

void loop() {
humidity=HT.readHumidity();
tempC=HT.readTemperature();
tempF=HT.readTemperature(true);

lcd.setCursor(0,0);
lcd.print(“Temp F= “);
lcd.print(tempF);
lcd.setCursor(0,1);
lcd.print(“Humidity= “);
lcd.print(humidity);
lcd.print(“%”);
delay(500);
lcd.clear();

Serial.print(“Humidity: “);
Serial.print(humidity);
Serial.print(” Temperature: “);
Serial.print(tempC);
Serial.print(“C “);
Serial.print(tempF);
Serial.println(“F “);
}


Liquid Crystal Display Setup, Control & Calculator

A common Arduino system typically includes a display of some type. This project was to set up a 16×2 LCD display to an Arduino unit and run it with simple messages that render it available for inputs or computational processing. It produces an informational output of its own, or to correspond to another event controlled by a wider system.

While the LCD display takes up several digital GPIO pins, there are several more remaining to build additional system functions. As either inputs or outputs, the display can read sensor data and trigger a relay, an alarm, or other device as specified. The potentiometer in the project as illustrated in the schematic below controls the LCD character block brightness.
Aside from any additional inputs, controls, or outputs, the LCD can display processes that run within the Arduino unit. Even as depicted here such as a counter or a calculator.

The physical connections between the Arduino and LCD display are through direct jumper connections between GPIO pins to data, control, power, and ground. The potentiometer is simply for character illumination intensity.

The digital GPIO pins that interface to the LCD connect to its data pins. R/W is strapped low to ground.

Arduino 16×2 LCD System Schematic

1602A LCD Display Pinout

PinSymbolFunction
1VSSGround
2VDD+5VDC
3V0Contrast
4RSRegister
5R/WRead/Write
6EEnable
7D0Data
8D1Data
9D2Data
10D3Data
11D4Data
12D5Data
13D6Data
14D7Data
15AAnode (+5VDC)
16KCathode (Ground)

Program & Functional Operation:



Code Setup:

#include <LiquidCrystal.h>
int rs=7;
int en=8;
int d4=9;
int d5=10;
int d6=11;
int d7=12;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);

void setup() {
lcd.begin(16,2);
}

void loop() {
lcd.setCursor(0,0);
lcd.print(“Counter:”);
lcd.setCursor(0,1);
lcd.print(“Hello James”);
for (int j=1;j<=10;j=j+1){
lcd.setCursor(9,0);
lcd.print(j);
delay(500);
}
lcd.clear();
}

Arduino Setup:

Calculator Setup:

#include <LiquidCrystal.h>
int rs=7;
int en=8;
int d4=9;
int d5=10;
int d6=11;
int d7=12;

float firstNum;
float secNum;
float answer;

String op;

LiquidCrystal lcd(rs,en,d4,d5,d6,d7);

void setup() {
lcd.begin(16,2);
Serial.begin(9600);
}

void loop() {

lcd.setCursor(0,0);
lcd.print(“Input 1st Number”);
while (Serial.available()==0){
}
firstNum=Serial.parseFloat();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Input 2nd Number”);
while (Serial.available()==0){
}
secNum=Serial.parseFloat();

lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Operator(+,-,*,/)”);
while (Serial.available()==0){
}
op=Serial.readString();

if (op==”+”){
answer=firstNum+secNum;
}
if (op==”-“){
answer=firstNum-secNum;
}
if (op==””){
answer=firstNumsecNum;
}
if (op==”/”){
answer=firstNum/secNum;
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print(firstNum);
lcd.print(op);
lcd.print(secNum);
lcd.print(” = “);
lcd.print(answer);
lcd.setCursor(0,1);
lcd.print(“Thank You”);
delay(10000);
lcd.clear();
}