Arduino and 3.5 Inch (320x480) TFT LCD (ILI9488) SPI Interface With DHT22 Temperature / Humidity Measurement

Introduction: Arduino and 3.5 Inch (320x480) TFT LCD (ILI9488) SPI Interface With DHT22 Temperature / Humidity Measurement


Nowadays, the beautiful TFT LCD screens are getting cheaper and using it in an embedded design, makes it more user friendly.

In this instructable, explains connecting the 320x480, 3.5Inch TFT LCD, with ILI9488 driver and SPI interfacing into Arduino. The LCD can be connected to the Arduinos SPI bus. It needs minimum number of port pins (4).

The DHT22 (AM2302) is a high precision temperature sensor module, provide calibrated temperature and humidity which is connected to digital IO pin of Arduino.

The DHT22 provides the temperature in Celsius format. The Arduino program converts the temperature into Fahrenheit, Kelvin and Rankine, and sends via serial port also displays on TFT LCD.

Parts and components

Arduino Uno board = 1 No

DHT22 (AM2302) = 1 No

320x480 TFT LCD (SPI interface, ILI9488 LCD controller) = 1 No

10K Resistor = 1No

Step 1: SChematic

The TFT LCD (3.5 inch, 320x480 pixel, ILI9488 LCD controller), is used for this instructable.

The LCD is easily interfaced with Arduino SPI bus, and it needs minimum of four Digital IO lines.

The ILI9488 LCD Controller is a 16.7M single-chip SoC driver for a-Si TFT liquid crystal display panels with a resolution of 320(RGB) x 480 dots.

The ILI9488 is comprised of a 960-channel source driver, a 480-channel gate driver, 345,600 bytes GRAM for graphic data of 320 (RGB) x 480 dots, and power supply circuit.

The LCD operates at 3.3 Volt Logic.

Arduino SPI port is connected to the LCD ( D13- SCLK, and D11 – MOSI).

Arduino Digital IO pin D9 and D10 is connected to RS and CS pin of LCD.

DHT22 digital temperature / humidity sensor delivers temperatures between -40°C and +80°C and humidity between 0% to 100%. The temperature accuracy is ±0.1°C (maximum).

The DHT22 data pin is connected with Arduino digital IO pin, and pulled up to Vcc, via 10K ohm resistor.

DHT22 (AM2302) outputs calibrated digital data signal. Every DHT22 sensor of this model is temperature compensated and calibrated in accurate calibration chamber and the calibration-coefficient is saved in internal OTP memory.

The sensor supports long transmission distance.

Arduino reads the temperature and humidity at 2 second interval and sends to the serial port as well as displays on LCD screen.

The conversion formula for Celsius to other scale are given below.

Fahrenheit:- T(°F) = T(°C) × 9/5 + 32

Kelvin:- T(K) = T(°C) + 273.15

Rankine:- T(°R) = (T(°C) + 273.15) × 9/5

Step 2: Software

Install Adafruit GFX and Adafruit ILI9341 device libraries.

Adafruit ILI9341 library is best suitable for the ILI9488 device.

Adafruit ILI9341 library is modified for adopting ILI9488 LCD controller.

Only, the Height and Width parameters at Adafruit_ILI9341.h file is modified to

#define ILI9341_TFTWIDTH 320

#define ILI9341_TFTHEIGHT 480

And at the Adafruit_ILI9341.cpp file, at the function Adafruit_ILI9341::begin(void), the following lines are modified for adapting ILI9488 device (320x480 pixels).

writecommand(ILI9341_DFUNCTR); // Display Function Control




Included DHT library offers the read interface for the sensor.

Arduino reads the temperature and humidity values at 2 seconds interval.

The temperature is in Celsius format, which is converted into Fahrenheit, Kelvin and Rankine format by the software.

A two column five row, multi colored table is drawn by using Arduino GFX lib, for displaying the temperature and humidity.

Converted four formats of temperature are send to the serial port and also displayed on the TFT LCD.

//Experiment of 3.5 Inch LCD (320x480), ILI9488 SPI Interface driver
//And experiment of DHT22 digital temperature / humidity sensor //Adafruit ILI9341 library is modified for ILI9488 (320x480)

// DHT22 Data line connected to Arduino digital IO 2

// LCD MOSI to Arduino digital IO D11 // LCD SCLK to Arduino digital IO D13 // LCD CS to Arduino digital IO D10 // LCD RS / DS to Arduino digital IO D9

// Name:- M.Pugazhendi // Date:- 01stSep2016 // Version:- V0.1 // e-mail:-

//Include Libraries #include <DHT.h> #include "SPI.h" #include "Adafruit_GFX.h" #include "Adafruit_ILI9341.h"

//Constants #define SERIAL_DEBUG

// DHT22 #define DHTPIN 2 #define DHTTYPE DHT22

// For the LCD shield, these are the default. #define TFT_DC 9 #define TFT_CS 10

// Initialize LCD // Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

// If using the breakout, change pins as desired //Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

// Initialize DHT sensor for normal 16mhz Arduino DHT dht(DHTPIN, DHTTYPE);

//Variables float hum; //Stores humidity value float temp; //Stores temperature value float converted = 0.00;

//Arduino setup void setup() { #ifdef SERIAL_DEBUG Serial.begin(9600); Serial.println("ILI9341 Test!"); Serial.println("DHT22 temperature / humidity sensor Test"); #endif //Initialize TFT LCD tft.begin();

//Initialize the DHT sensor dht.begin(); #ifdef SERIAL_DEBUG // read diagnostics (optional but can help debug problems) uint8_t x = tft.readcommand8(ILI9341_RDMODE); Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX); x = tft.readcommand8(ILI9341_RDMADCTL); Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX); x = tft.readcommand8(ILI9341_RDPIXFMT); Serial.print("Pixel Format: 0x"); Serial.println(x, HEX); x = tft.readcommand8(ILI9341_RDIMGFMT); Serial.print("Image Format: 0x"); Serial.println(x, HEX); x = tft.readcommand8(ILI9341_RDSELFDIAG); Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); #endif

//Rotate the screen to right direction tft.setRotation(1);

//Print the headers printHeader(); }

//Main loop void loop(void) {

//Read data and store it to variables hum and temp hum = dht.readHumidity(); temp= dht.readTemperature(); printTemperatureHumidity();

//Delay 2 Seconds delay(2000); }

//Print headers unsigned long printHeader(void ) { tft.fillRect(0,0,240, 64,ILI9341_GREEN); tft.fillRect(0,64,240, 64,ILI9341_RED); tft.fillRect(0,128,240, 64,ILI9341_CYAN); tft.fillRect(0,192,240, 64,ILI9341_YELLOW); tft.fillRect(0,256,240, 64,ILI9341_ORANGE);

unsigned long start = micros(); tft.setTextColor(ILI9341_BLACK); tft.setTextSize(3); // tft.setCursor(50,0+20); tft.print("CELCIUS");

// tft.setCursor(50,64+20); tft.print("FAHRENHEIT"); // tft.setCursor(50,128+20); tft.print("KELVIN");

// tft.setCursor(50,192+20); tft.print("RANKIN");

// tft.setCursor(50,256+20); tft.print("HUMIDITY"); return micros() - start; }

//Print temperature and humidity unsigned long printTemperatureHumidity() { tft.fillRect(241,0,240, 64,ILI9341_CYAN); tft.fillRect(241,64,240, 64,ILI9341_YELLOW); tft.fillRect(241,128,240, 64,ILI9341_ORANGE); tft.fillRect(241,192,240, 64,ILI9341_GREEN); tft.fillRect(241,256,240, 64,ILI9341_RED); //tft.fillScreen(ILI9341_BLUE); unsigned long start = micros(); tft.setTextColor(ILI9341_BLACK); tft.setTextSize(4);

#ifdef SERIAL_DEBUG Serial.print("Celsius = "); Serial.print(temp); //Print degree symbol Serial.write(176); Serial.println("C"); #endif tft.setCursor(250,0+20); tft.print(temp); tft.print(" "); tft.print((char)247); tft.println("C");

//Fahrenheit //T(°F) = T(°C) × 9/5 + 32 converted = ( temp * 1.8 ) + 32; #ifdef SERIAL_DEBUG Serial.print("Fahrenheit = "); Serial.print(converted); //Print degree symbol Serial.write(176); Serial.println("F"); #endif tft.setCursor(250,64+20); tft.print(converted); tft.print(" "); tft.print((char)247); tft.println("F");

//Kelvin //T(K) = T(°C) + 273.15 converted = temp + 273.15; #ifdef SERIAL_DEBUG Serial.print("Kelvin = "); Serial.print(converted); Serial.println(" K"); #endif tft.setCursor(250,128+20); tft.print(converted); tft.print(" "); tft.println("K");

//Rankine //T(°R) = (T(°C) + 273.15) × 9/5 converted = temp + 273.15; converted = (converted * 1.8); #ifdef SERIAL_DEBUG Serial.print("Rankin = "); Serial.print(converted); //Print degree symbol Serial.write(176); Serial.println("R"); #endif tft.setCursor(250,192+20); tft.print(converted); tft.print(" "); tft.print((char)247); tft.println("R");

//Humidity #ifdef SERIAL_DEBUG Serial.print("Humidity ="); Serial.println(hum); #endif tft.setCursor(250,256+20); tft.print(hum); tft.print(" "); tft.println("%"); return micros() - start; }

Step 3: Conclusion

The project is successfully completed with Arduino UNO, 320x480 TFT LCD and DHT22 module.

The converted temperature, and LCD display, Serial Port screen are given below.

Be the First to Share


    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Super-Size Speed Challenge

      Super-Size Speed Challenge
    • Audio Challenge 2020

      Audio Challenge 2020

    8 Discussions


    1 year ago

    Does it work with esp8266 Nodemcu or what should be changed / added in the sketch?
    Thank you


    3 years ago

    Please below the link for LCD

    G S Mounik
    G S Mounik

    Reply 1 year ago

    The link u have provided says that it is for RASPBERRY PI.....So will it work for arduino UNO?


    Reply 1 year ago

    Yes It will work. Its a serial SPI LCD.

    G S Mounik
    G S Mounik

    Question 1 year ago on Step 2

    Is the lcd readable under sunlight?


    3 years ago

    Great explained! Congrats