This Arduino tutorial shows how to connect it with Nokia 5110 (Nokia 3310) LCD and DHT11 digital temperature and humidity sensor. The Nokia 5110 LCD has maximum resolution of 84 x 48 pixel.
Temperature and humidity values are displayed on the Nokia 5110 LCD screen.
To see how to interface Arduino with Nokia 5110 LCD, visit the following post:
Interfacing Arduino with Nokia 5110 LCD
And for interfacing Arduino with DHT11 sensor, see the post below:
Arduino interfacing with DHT11 sensor and LCD
Hardware Required:
- Arduino board
- Nokia 5110 (3310) LCD module
- DHT11 (RHT01) sensor
- 5 x 3.3k ohm resistor
- 5 x 2.2k ohm resistor
- 4.7k ohm resistor
- Breadboard
- Jumper wires
Interfacing Arduino with Nokia 5110 LCD and DHT11 sensor circuit:
Project circuit diagram is shown below.
The Nokia 5110 which is shown in the circuit diagram has 8 pins (from left to right): RST (reset), CE (chip enable), DC (or D/C: data/command), Din (data in), Clk (clock), VCC (3.3V), BL (back light) and Gnd (ground).
The Nokia 5110 LCD works with 3.3V only (power supply and control lines). The LCD module is supplied with 3.3V which comes from the Arduino board (VCC pin of the LCD is connected to Arduino 3V3 pin), BL pin is also connected to 3.3V.
All Arduino UNO board output pins are 5V, connecting a 5V pin to the Nokia 5110 LCD may damage its controller circuit.
To connect the Arduino to the LCD module, I used voltage divider for each line which means there are 5 voltage dividers. Each voltage divider consists of 2.2k and 3.3k resistors, this drops the 5V into 3V which is sufficient.
The DHT11 sensor has 4 pins (from left to right):
VCC: connected to Arduino 5V pin
Data pin: connected to Arduino analog pin 0 (A0)
Not connected pin
GND: connected to Arduino GND pin.
Interfacing Arduino with Nokia 5110 LCD and DHT11 sensor code:
The following Arduino code requires 3 libraries from Adafruit Industries:
The first library is a driver for the Nokia 5110 LCD (PCD8544 controller) which can be installed from Arduino IDE library manager (Sketch —> Include Library —> Manage Libraries …, in the search box write “nokia” and install the one from Adafruit).
The second library is Adafruit graphics library which can be installed also from Arduino IDE library manager.
The third library is for the DHT11 sensor, also it can be installed from the library manager.
The previous 3 libraries can also be installed manually, download links are below:
Adafruit Nokia 5110 LCD library —-> direct link
Adafruit graphics library —-> direct link
Adafruit DHT library —-> direct link
After the download, go to Arduino IDE —> Sketch —> Include Library —> Add .ZIP Library … and browse for the .zip file (previously downloaded).
The same thing for all library files.
So, the code uses 4 libraries, they are included as shown below:
1 2 3 4 | #include <SPI.h> // include SPI library #include <Adafruit_GFX.h> // include adafruit graphics library #include <Adafruit_PCD8544.h> // include adafruit PCD8544 (Nokia 5110) library #include <DHT.h> // include DHT library code |
Rest of code is described through comments!
Full Arduino code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /* * Interfacing Arduino with Nokia 5110 LCD and DHT11 sensor. * This is a free software with NO WARRANTY. * http://simple-circuit.com/ */ #include <SPI.h> // include SPI library #include <Adafruit_GFX.h> // include adafruit graphics library #include <Adafruit_PCD8544.h> // include adafruit PCD8544 (Nokia 5110) library #include <DHT.h> // include DHT library code // Nokia 5110 LCD module connections (CLK, DIN, D/C, CS, RST) Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3); #define DHTPIN A0 // DHT11 data pin is connected to Arduino analog pin 0 #define DHTTYPE DHT11 // DHT11 sensor is used DHT dht11(DHTPIN, DHTTYPE); // configure DHT library char temperature[] = "00.0 C"; char humidity[] = "00.0 %"; void setup() { delay(1000); // wait 1 second // initialize the display display.begin(); // initialize the DHT library dht11.begin(); // you can change the contrast around to adapt the display // for the best viewing! display.setContrast(50); display.clearDisplay(); // clear the screen and buffer display.drawFastHLine(0, 23, display.width(), BLACK); display.setTextSize(1); display.setTextColor(BLACK, WHITE); display.setCursor(6, 0); display.print("TEMPERATURE:"); display.setCursor(15, 28); display.print("HUMIDITY:"); display.display(); } // main loop void loop() { // read humidity byte RH = dht11.readHumidity(); // read temperature in degree Celsius byte Temp = dht11.readTemperature(); // update temperature and humidity arrays temperature[0] = Temp / 10 + '0'; temperature[1] = Temp % 10 + '0'; humidity[0] = RH / 10 + '0'; humidity[1] = RH % 10 + '0'; // print temperature display.setCursor(24, 12); display.print(temperature); // print humidity display.setCursor(24, 40); display.print(humidity); // print degree symbol ( ° ) display.drawRect(50, 12, 3, 3, BLACK); // now update the display display.display(); delay(1000); // wait 1 second } // end of code. |
The following video shows Proteus simulation of the project (note that simulation circuit is not the same as real hardware circuit, hardware circuit diagram is shown above):
Proteus simulation file download link is below, use version 8.6 or later to open it:
Arduino with Nokia 5110 LCD and DHT11 sensor Proteus simulation
Discover more from Simple Circuit
Subscribe to get the latest posts sent to your email.
Arduino: 1.8.9 (Linux), Board: “Arduino/Genuino Uno”
In file included from /home/swede/Arduino/libraries/DHT_sensor_library/DHT_U.cpp:15:0:
/home/swede/Arduino/libraries/DHT_sensor_library/DHT_U.h:36:29: fatal error: Adafruit_Sensor.h: No such file or directory
#include
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
So it won’t compile, any ideas ?
Make sure that you’ve properly installed all the required libraries: Adafruit PCD8544 driver, Graphics library and DHT library!
This tutorial really helped me get started with the PCD8544, so I want to help you.
You need the following adafruit libraries:
* PCD8544 https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library
* GFX https://github.com/adafruit/Adafruit-GFX-Library
* DHT https://github.com/adafruit/DHT-sensor-library
* Unified Sensor https://github.com/adafruit/Adafruit_Sensor
* Circuit Playground https://github.com/adafruit/Adafruit_CircuitPlayground
Install: “Adafruit_BusIO” and “Adafruit Unified Sensor” from library manager.