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.
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)
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 !
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.