Completely Refactory Code for a Clock, Weather Station, Calendar, With 3.5" TFT Display and NodeMCU 8266

by giano2002 in Circuits > Arduino

76 Views, 3 Favorites, 0 Comments

Completely Refactory Code for a Clock, Weather Station, Calendar, With 3.5" TFT Display and NodeMCU 8266

IMG_20250310_151547.jpg
Photo_5.jpg
20250218_175548.jpg
Photo_5.jpg

I have completely renewed my clock, calendar, weather station project, published some time ago, using, instead of the Arduino mega board, a NodeMCU 8266 board and a TFT display, always 3.5”, but SPI and ILI9488 driver.

This hardware modification involves not only a reduction in space, but also a reduction in overall costs, accompanied by an increase in speed and, above all, the possibility of connecting to the Internet, via the WiFi network of the board.

Supplies

List of materials used


1. 1 NodeMCU esp8266

2. 1 TFT display 3.5”, SPI with ILI9488 driver

3. 1 PNP Transistor

4. 1 NO push button (to switch On display)

5. 1 NC push button (multi function)

6. 1 BME280 sensor

7. 1 1K resistor

8. 1 10K resistor

9. 1 AC-DC module

10. 1 pcb board

11. 1 connector for display

12. 1 plastic box about 12x10x4 cm.

SOFTWARE

MAIN FEATURES:

1. Time, day, month and year, from the Internet;

2. Automatic change between solar time and summer time;

3. Time zone change with a button;

4. Change display language with a button;

5. Temperature, humidity, pressure, internal and external (from Thingspeak station);

6. Minimum and maximum values ​​of the day;

7. Change of external weather station with a button;

8. Automatic shutdown during night hours;

9. Display refresh every 10 minutes, with a bar that dynamically indicates the remaining time;

10. Also added the ability to insert multiple WIFI networks into the code.


For this new project I had to make many changes to the original code and I also introduced many new features, which I illustrate below.

I would like to point out that I have also implemented several solutions with the help of various AI tools accessible for free. In using these tools I had to work hard, because in the development of the codes, together with a considerable capacity, unthinkable only a year ago, they have many gaps and require extreme patience to achieve (and not always) the desired results.

That said, first of all, since I can connect the NodeMCU board to the Internet, I wanted to use the temperature, humidity and pressure data that my weather station - installed outside my home - sends every 2 minutes or so to the Thingspeak site.

So, the TFT display now shows the Temperature, Humidity and Atmospheric Pressure, both external and internal (with the BME280 sensor). In addition, it also displays the respective Minimum and Maximum values ​​recorded in 24 hours.

A clock, with indication of the day, date, month and year, could not be missing.

Finally, in a special window of the display, the heat index is also displayed (obviously, only when the temperature and humidity exceed the thresholds of 27 degrees and 40%).

Having wanted to maintain the periodic refresh function of the display, I added a horizontal bar, which dynamically shortends and change colour, as the ten minutes established for the refresh pass, and a special, small circle, which counts the minutes remaining to the countdown.

In addition to the refresh every ten minutes, the device resets at midnight, zeroing all the stored data, and the display turns off at midnight and 3 minutes, to turn on again at 6:30. Obviously, these times can be changed at will.

Even during the hours in which the display is off, the device continues to function normally and it is possible to turn on the display temporarily by pressing the NO button, located on the back of the cabinet.

Finally, all information on the display can be indicated in 4 other languages, as well as Italian, using the button on the back.

Seven more time zones have been added, in addition to the Central European one (Europe, America, Australia), which can be easily selected, always using the usual button on the back.

As for the external weather data, I used my two weather stations that send data to Thingspeak. To do so, always using the same button on the back, you can choose to display the temperature, humidity and pressure data between two different weather stations from Thingspeak (obviously, only if the respective API keys and IDs of the stations have been indicated on the code).

The weather values ​​are displayed in a larger size for the external station, and smaller, in a special box, for those detected by the internal sensor.

But I also created another sketch too, that does exactly the opposite. That is, it displays the sensor values ​​in a larger size and those of the external station, smaller, in the display window. In this case, also the Minimum and Maximum values ​​are those detected in the 24 hours inside the house.

A necessary warning: to use the TFT_eSPI.h library, which manages the display, it is necessary to make small changes to the setup files of the same, to enable the ILI9488 driver used by the display. I attach the modified files of the library, to facilitate those who want to realize the project.

After downloading the entire TFT_eSPI library into the Libraries folder of your IDE, replace the files contained in that folder with the ones I attach (TFT_config.h; User_Setup.h; User_Setup_Select.h).

To achieve the three functions above (change language; change time zone; change external weather stations) using a single button, many changes to the code were required, with many attempts and tests. The new code is now available and working.

How to Read the Display

The attached PDF file contains explanations of everything that appears on the display.

Downloads

Hardware

Photo_2.jpg
photo_1.jpg
Photo_3.jpg
Photo_4.jpg

For the hardware, as I mentioned at the beginning, I used the NodeMCU 8266 board, the 3.5” TFT display, SPI and ILI9488 driver (which uses the TFT_eSPI.h library) and the BME280 sensor (you can also use the BMP280 sensor or other models, if you don’t need to measure internal humidity, or another sensor. In these cases, you will need to modify the relevant section of the code).

I placed the board and display on a pre-drilled base, on which I soldered a connector to easily insert the display and I made the necessary connections between the socket and the NodeMCU board, as well as those to connect the transistor (which is used to turn the display on and off), the two buttons (one to light the led display when it is Off and the secon to change the language) and the power module, 220V ac-5V dc, 1000 mA.

I attach the connection diagram between the board, display, transistor, buttons and power module.

The whole thing is enclosed in a plastic box, 80x125x34 cm., on which I had to open a window of the same size as the display used (the most delicate part of the project, not having other possibilities, such as a 3D printer to make the custom cabinet).

FUTURE DEVELOPMENTS

The project could be further improved for other solutions.

But to make such additions and modifications requires a programming ability that I do not have and not even the various Ai that I have been able to test.

I hope, therefore, that there is someone online who can try these new implementations.

I attach some photos of my creation.

Upload File Via OTA

The OTA upload function has also been implemented in the code.

In order to upload the code via OTA, of course, it is essential to first upload, with the cable connected to the USB socket of the NodeMCU board, the BasicOTA code, available among the Examples in the Arduino IDE, in which the SSID and Password of your WiFi network must be indicated. After uploading this file, read the IP address assigned to the board opening the Serial monitor (to do so, after open the Serial monitor, just unplug and plug again the cable on USB port of your PC). The IP address will be used to select it as the port on which to upload the code of this device, via OTA.

Using the NC Push Button

HOW TO USE THE NC BUTTON

The NC button has two functions, with a long or short press.

First, you choose, with a long press, between Language; Time-zone; Weather station to display, and releasing the button on the choise made.

Each choice will be indicated with the red symbol: Lng, Tmz, API.

Subsequently, after choosing one of the three categories, with a shorter press, you select the options provided.

For example, if you want to change the language, after selecting the Lng category, you will choose the language, briefly pressing the button in sequence, stopping on the preferred language.

Once the preferred option has been selected, releasing the button will save the choice and to confirm, the countdown bar will flash quickly.