Introduction: Arduino Mega + 2.4 TFT LCD Shield + DHT11 Temperature and Humidity Displaying

Picture of Arduino Mega + 2.4 TFT LCD Shield + DHT11 Temperature and Humidity Displaying

Today, I am going to show you how to use 2.4" TFT LCD shield display for Arduino MEGA board so as to show us temperature and humidity value of the related environment which means that where is your DHT11 temperature and humidity sensor, there is a display to show that everything about the status.

The need list:

1. Arduino MEGA

2. 2.4" TFT LCD Shield from red colored mcufriend's

3. DHT11

4. Necessary tiny bread board and tiny colored connection cables

Note: To learn that how to use 2.4" TFT LCD shield with Arduino MEGA, check my previous instructable.

Step 1: Assembly

Picture of Assembly

Put the 2.4" TFT LCD shield onto Arduino MEGA with its suitable pins directly to Arduino.

DHT11's second pin is which we need, put this data pin to Arduino MEGA's Pin number 17

You may use tiny bread board and tiny cables to make connections.

Step 2: Upload the Code

You can download the codes below. Copy these codes and paste them to Arduino IDE.

On Arduino IDE Tools >> Device >> Arduino MEGA and programmer as AVRISP mkII

Find your related COM port number from your computer's device manager, new Arduino IDE understands automatically.

The rar files are libraries which you need to import to Arduino Library. (Extract to use)

Step 3: Get the Results

Picture of Get the Results

The main algoritm is taking the recent temperature and humidity values from related environment which the sensor has located, we see the results on the display. Since the display is multicolored, I add colored response when it is hot or cold. These are:

if (DHT.temperature > 30){
tft.setTextColor(RED); }else if (DHT.temperature > 27 || DHT.temperature < 30) { tft.setTextColor(YELLOW); } else if(DHT.temperature < 27 || DHT.temperature > 10){ tft.setTextColor(BLUE); } else if (DHT.temperature <10){ tft.setTextColor(CYAN); } else { tft.setTextColor(GREEN); }

This means that:

1. If temperature is high from 30 celcius degree, make the displayed temperature line as red.

2. If temperature is above 27 below 30, make the displayed temperature line as yellow.

3. If temperature is above 10 below 27, make the displayed temperature line as blue.

4. If temperature is below 10, make the displayed temperature line as cyan.

5. If none of these first four statement comes true, just make it green. (This is for using else statement in the code on purpose)


That's all !

Step 4: BONUS: Let's Save the Values to the SD Card

Picture of BONUS: Let's Save the Values to the SD Card

I haven't got a small SD Card reader shield for Arduino boards as SPI, but I have got ethernet shield which is Arduino Mega compatible. This shield has sd card reader slot. My idea is saving humidity and temperature values to the sd card with using ethernet shield's sd card slot.

So, Combine Arduino MEGA and Ethernet Shield. Then, add the TFT LCD Shield, also add DHT11 as mentioned on first steps of this instructable.

Download the code for Arduino IDE below.Upload it to your Arduino MEGA. You may close your computer's Bluetooth connection in order not to get any errors while you upload the code by Arduino IDE program.

You need to format your sd card as FAT32 or FAT to use for Ardunio. Please check my sd card status while I use actively from attachment. You need a SD Card reader with usb cable attached to your pc to see the text file inside.


ImranK103 (author)2017-10-04

Hey sir good days
Verry good ieda and knowledge you share thanks for that
Sir sory to disturb you but i want something about this project
Sir this Arduino is only for measuring temperature or humidity?
Or we can control humidity and temperature by this Arduino using som relays if it is possible sir give advice how to up wire and circuit?
Can we use any old mobile Lcd for display?

mur7 (author)2017-01-30

Nice project worked in first attempt thank you !

Bay Yolal (author)mur72017-01-30

That's very nice :)

paulm171 (author)2016-09-18

This works on my LGDP4535 2.4 TFT from Mcufriend but the screen is reversed, any pointers as to fixing this. Any help would be appreciated!

Bay Yolal (author)paulm1712016-09-18

You may code to fix this.

JayA73 (author)2016-08-29

can i use this sketch in arduino uno?

Bay Yolal (author)JayA732016-08-29

Of course. Modify the library as not mega buy uno.

JayA73 (author)Bay Yolal2016-08-29

great thanks !

Lintang_Wisesa (author)2016-08-02

Is it work on 2,4" TFT LCD shield with ILI9341 controller? until now, I have to wire it manually (to Mega) w/ a lot of jumper wire.

Bay Yolal (author)Lintang_Wisesa2016-08-02

I hope it will work without lots of cables from now on.

About This Instructable




Bio: Living in Istanbul, answering your questions :)
More by Bay Yolal:How to use Raspberry Pi 3 Model B+ V1.2 For The First Time!How to knit baby booties in only one hour! Ta-Da!How to Extract Walnut
Add instructable to: