Renewed WiFi Real Time Clock/Calendar/Weather Station Project, With TFT 3.5” LCD Display and NodeMCU ESP 8266 OTA

by giano2002 in Circuits > Arduino

71 Views, 0 Favorites, 0 Comments

Renewed WiFi Real Time Clock/Calendar/Weather Station Project, With TFT 3.5” LCD Display and NodeMCU ESP 8266 OTA

Display_1.jpg

I have completely revised my project presented in February 2023, using a slightly larger display, 3.5”, a NodeMCU8266 board, instead of Arduino Mega and a BME280 sensor. The whole thing is simpler and also cheaper.

This time, thanks to the WiFi of the NodeMCU8266 board, I eliminated the RTC module, to generate the clock and calendar, using NTP instead, and I added the functionality to display, in addition to the Temperature, Humidity and Pressure data, collected with the BME280 sensor in the internal environment where my project is placed, also the Temperature and Humidity data collected from the Thingspeak site, to which they are sent from my weather station positioned outside my home (or any other station whose Passkey and ID can be known).

In this way, in a single screen it is possible to know: A) the exact time (with automatic change between summer time and winter time),; B) the day, month and year; C) the interna temperature, humidity and atmospheric pressure, related to sea level, with the respective minimum and maximum values ​​recorded in 24 hours; D) as well as the external temperature and humidity; E) the Heat index.



Supplies

Interno_1.jpg
Interno_2.jpg
Interno_3.jpg
DIsplay_2.jpg
Backlight handle.png

Material used

1 NodeMCU8266 board;

1 3.5” 480x320 TFT display, with SPI interface and ili9488 driver (https://it.aliexpress.com/item/32954240862.html?spm=a2g0o.order_list.order_list_main.82.2bfb3696rlPQ7n&gatewayAdapt=glo2ita);

1 BME280 sensor;

1 plastic box 80x125x32 mm. (https://it.aliexpress.com/item/1005006900224809.html?spm=a2g0o.order_list.order_list_main.70.2bfb3696rlPQ7n&gatewayAdapt=glo2ita);

1 pre-drilled base, to solder an 8-pin connector, in which to insert the display;

Various bolts and nuts.


Connections

The SPI version of TFT display has a 14-pin connector, necessary if you also want to use the touch screen. In this case I did not use it and, therefore, only 8 pins are needed, which must be connected to the NodeMCU board as follows:

TFT Pin to NodeMCU8266

1- Vcc +3.3V

2- G Gnd

3- CS D8

4- Rst D4

5- DC/RS D3

6- SDI/MOSI D7

7- SCK D5

8- LED +3.3V

The BME280 sensor must be connected to the NodeMCU as follows:

Vcc +3.3V

Gnd Gnd

SCL D1

SDA D2

The most delicate thing from the hardware point of view was to make the frame for the display on the plastic box. I used the Dremel, with a small circular saw. The work is not perfect, but I can be satisfied. Of course, those who have the possibility of using a 3D printer could make a custom container.

The photos I attach can help to understand how the project was made.

Update

I made a hardware modification to be able to turn off the display LEDs after midnight and turn them back on in the morning and also to be able to temporarily turn them on when they are off.

To make this modification, simply interrupt the connection between the "LED" pin of the display and the +3.3V of the board and insert the small circuit that can be seen in the attached photo. All you need is a diode, a resistor, a low-power NPN transistor and a N.O. button. You also need to make a few additions to the code, to manage the interruption of the display LEDs.

Finally, I added the instructions to the code needed to be able to perform future updates via OTA. Of course, to take advantage of this mode, before uploading this code to the NodeMCU board, you must first upload the sketch, "Basic OTA", downloaded from the Arduino examples (after adding the SSID and PW of your WiFi to the sketch).

After uploading this code, open the serial and press reset on the board: you should read the IP address assigned by the router, which will be used to upload my sketch, after looking for the Port, from Arduino IDE Tools, and choosing the one with the assigned IP address.

Software

For the software part, I left the initial basic project unchanged, but I had to rewrite many parts, since the exact time is taken from the Internet, with automatic conversion between legal and solar; the weather data is taken from Thingspeak; and a different library is used to connect the SPI display to the NodeMCU board.

About the NodeMCU8266 board, you have to be careful and use only the board manager in version 2.7.4. Other more recent versions generate errors.

The libraries needed for the project are:

BME280I2C.h

TimedAction.h

SPI.h

Wire.h

TFT_eSPI.h

NTPClient.h

ESP8266WiFi.h

WiFiUdp.h

Timezone.h

ArduinoJson.h

To be able to use the 3.5” SPI ili9488 display, it is essential to make a few changes to the TFT_eSPI library.

In particular, inside the TFT_eSPI folder, you need to open the User_Setup_Select.h file and uncomment the line:

#include <User_Setups/Setup20_ILI9488.h>

Then you need to open the User_Setup.h file and uncomment the line:

#define ILI9488_DRIVER.

To make it easier, I'm attaching the two files of the library, with the changes already made.

I'm not a programming expert, so to write my sketch I asked Copilot and Gemini for help. To more experienced programmers, the code may seem a bit inelegant and redundant. However, I can say that it works and I hope that those who have the patience to read it will want to get their hands on it and make improvements and then share them.