Series: Tried Using Touch Panel TFT Display GT-SP with Arduino

Displaying DHT11 Sensor Module Values on Touch Screen

Displaying DHT11 Sensor Module Values on Touch Screen

Hello everyone, I’m @kissaten, a beginner in electronics. In this series, I’m explaining the process of connecting a 7-inch touch display (GT-SP series “GTWV070S3A00P”) to an Arduino and working on various projects.

This time, I took on a project where I connected the DHT11 temperature and humidity sensor module to an Arduino, retrieved its data, and displayed the temperature and humidity on the screen.

Please note that this article is a continuation of the previous one (“Controlling an LED Connected to Arduino from a Touch Screen”). If you haven’t seen the previous content yet, you can check it out here.

This GIF shows temperature and humidity changes by touching the sensor.

Connecting the Temperature and Humidity Sensor Module DHT11

To receive data from the temperature and humidity sensor module DHT11, we will add DHT11 to the previous circuit. The DHT11 we are using this time is a module. Connect the GND, 5V, and DATA pins to the corresponding pins on the Arduino. For this setup, we connected the DATA pin to D10 on the Arduino, but depending on the DHT11 module you have, the wiring positions may vary, so please verify it.

(Wiring between GT-SP and Arduino is omitted. If you need detailed information, please refer to the previous articles.)

Picture by [Fritzing (CC BY-SA)]

Creating a Project for Writing on a Touch Screen

Explanation:

On the page labeled “PAGE_0,” we will create four text objects named “TEXT_0” through “TEXT_3.” In “TEXT_0,” we’ll insert the heading “Temperature,” and in “TEXT_2,” we’ll add the heading “Humidity.” “TEXT_1” will be used to display temperature, while “TEXT_3” will be used to display humidity values.

These text objects serve as the receiving end to display values sent from Arduino. Therefore, no event actions need to be configured for them.

Creating an Arduino Program

Building upon the previous articles, we will create the following program:

Please note that to use the DHT11 sensor, you’ll need two libraries. You can download the ZIP files for each library from their respective pages by clicking on “CODE > DOWNLOAD ZIP.” After downloading, install these libraries in the Arduino IDE by going to “Sketch > Include Library > Add .ZIP Library.”

https://github.com/adafruit/Adafruit_Sensor
https://github.com/adafruit/DHT-sensor-library

Interpreting the Program

To enable the use of the DHT11 sensor, we perform library and pin setup at the beginning of the program.

We retrieve the temperature using dht.readTemperature() and the humidity using dht.readHumidity(). Regarding dht.readTemperature(true), it returns the temperature in Celsius (°C) by default but switches to Fahrenheit (°F) if specified as “true.”
After receiving these values, we append units and display them on the text objects.

The delay(2000) within the program is inserted because the DHT11 requires a 2-second interval for accurate readings. For more details, please refer to the DHT11 specifications.

Execution Result

We were able to display the humidity and temperature obtained from the DHT11 on the text objects. Displaying sensor values like this is a frequently used feature, in my opinion.

 

Next, we will use the values obtained in this session to add various decorations to the GT-SP.