Introduction: ESP8266/ESP32 Weather Station With TFT LCD(s)
Hello!
In this short instructable i would like present my second Esp8266 WS project. Since i posted my first ESP project i wanted to make myself a second one. So i had some free time to rework an old source code to fit my needs.
So if you don't mind i will present it.
Step 1: The Weather Station
The WS still uses the openweathermap API key to download the weather data and display it on the screen.
A little coding was needed because in that form it could not display the weather icons i wanted.
Step 2: Materials
Parts needed for WS:
- Nodemcu V3 ESP8266
- 1.8 inch TFT LCD with ST7735 driver IC
- F-F wires
- Source code
- Arduino IDE
- SPIFFS support
- Openweathermap API key
Step 3: Software
For this project i am providing the source code and the bitmap images needed, download it from my github page: https://github.com/Lacybad/ESP8266-ST7735-weather-...
The library i have used is the TFT_eSPI created by Bodmer.
All you have to do: Download the correct libraries, compile it and upload it to the board, upload the bitmap images with SPIFFS to ESP and connect with lcd.
I have used 24 bit 100 X100 bitmap images, but you can use any other icons. The ones i used have downloaded from https://www.flaticon.com
Attachments
Step 4: LCD Pinout
The pinout is the following:
// Display SDO/MISO to NodeMCU pin D6 (or leave disconnected if not reading TFT)
// Display LED to NodeMCU pin VIN (or 5V, see below)
// Display SCK to NodeMCU pin D5
// Display SDI/MOSI to NodeMCU pin D7
// Display DC (RS/AO)to NodeMCU pin D3
// Display RESET to NodeMCU pin D4 (or RST, see below)
// Display CS to NodeMCU pin D8 (or GND, see below)
// Display GND to NodeMCU pin GND (0V)
// Display VCC to NodeMCU 5V or 3.3V
For reduced backligh you can use a 10K potentiometer or use another GPIO pin. As for myself i usually connect backlight pin to TX pin. I know it is not a very good idea or very healthy for ESP, but it is working that way.
Step 5: WS in Action
After you have done everything correctly you can see that the weather station is connecting to the internet and downloading the weather data.
The different parameters are separated in different loops.
What you see is the actual weather description, temperature, humidity, wind speed, visibilty in meters, air pressure, wind angle , cloud coverage in percentage (%).
As for a bonus between 9 PM and 7 AM the display turns inverse to simbolise night time.
Step 6: Some Important Tips
As you all know the are a few variants of the 1.8" TFT on the internet. With the genuine Adafruit lcd-s there are usually no problems. But when using fake ones(usually from Aliexpress) you have to make some adjustments.
Bodmers TFT_eSPI library is very awsome and rich funcionality. And the best part is that he made it to handle the pixel offsets depending on wich kind of 1.8" TFT you are using.
In order to overcome this issue i am suggesting the following:
Go to library folder and edit User_Setup.h file. Uncomment #define ST7735_DRIVER and comment the others.
Then uncomment the tft height an width. And then in my case(REDTAB) uncomment for eg: #define ST7735_REDTAB. After this save it for the moment and compile sketch and upload to board. To be sure i have defined the parameters in the sketch too.This is a bit long procedure, cause you have to compile and upload the sketch every time to board untill the offset is gone, but it is worth the experimenting. For editing the h. files i strongly suggest Wordpad. Images included.
Step 7: Done
After doing everything correctly you can enjoy this little gadget. I have tried pairing the bitmap images with the weather codes as good as i could, but i am still testing it at the moment.
Basically i just made it for myself, but after a day i thought i will share it. Maybe someone will like it more than me.
Thank you for reading my instructable,hope you will find it useful and use it as you like.
Have a nice day!
Step 8: A Small Update
After a few days i thought i will remake this WS in a new form.
Changes : ESP32 Uno R3
Parallel ILI9340/41 TFT LCD
New icons
1 extra option
Pls edit User_setup.h file in TFT_eSPI library accordingly in sketch. Pls uncomment them and comment out other option or otherwise it will not work.
You have to connect GPIO 35 to 15 , GPIO 33 to 34, GPIO 32 to 36 because they are only input pins and then our display will not work( see picture).
Source code is available on github.
17 Comments
6 months ago on Step 7
error in code
Compilation error: no return statement in function returning non-void [-Werror=return-type]
2 years ago
Hello!
I've tried it many times to compile, but always get the error 'timeClient' was not declared in this scope.'
I also tried an empty library and different versions of NTPClient. I am using a Wemos D1 Mini ESP8266. Hardware is fine, it works with other code.
Does anybody know what I'm doing wrong?
Reply 2 years ago
Copy the sketch to a new tab and without saving try to compile, then the data upload can be done in the original window.Its because it was written in an older IDE version, this trick can be done.
Reply 2 years ago
It works. Great. Many Thanks.
2 years ago
Hello I tried your method of code on a similar project of mine except for I am not using bitmaps. My problem is the code crashes after sometime. Gives panic error in Arduino COM terminal. Also esp does a watch dog reset. I am using D1 mini. Please help. From what I can interpret it's a memory overflow problem. Any solution you can suggest?
Reply 2 years ago
Hello!
I am using the cheapest Nodemcu V3/ESP32 .I have not noticed any crashing in the past months with the code. This could be an issue with the API data refreshing/downloading or the internet connection 🤔 For me it is working fine.
Reply 2 years ago
Yes the problem is with connection regarding weather API I guess. I found another project for reference (by nullboundary on github) and used their method. Now it's working fine.
Reply 2 years ago
This looks cool, minimal style is my favorite :)
I had no time lately to play with arduino/esp. I will try to fix the connection error in the code as soon as possible.
Nice work, respect! :)
Reply 2 years ago
Thank You!
edit: I added a LDR for auto brightness, a buzzer for hourly beep, and a push button to set if watch is being powered by battery or adapter and also to toggle LCD backlight. Might try adding function to set alarm using server mode.
Question 3 years ago
I am new to programming ESP8266, I want to create one of these with Air Quality Index, which I don't think is available from OpenWeatherMap. Do you have any suggestions for how I might be able to do that?
Answer 3 years ago
https://github.com/jackmax/AccuWeatherLibrary/tree/master/examples/AccuWeather_API_Example
Answer 3 years ago
https://aqicn.org/api/
https://aqicn.org/json-api/doc/
https://www.hackster.io/arkhan/esp8266-aqi-display-25bba7
Hello there!
This is a good point. I am redesigning this WS to display AQI from api key, but dont have free time for now. To start pls take a look on this tutorial.
Reply 3 years ago
This is great, thank you! I was originally looking at redesigning from scratch using the AccuWeather API, which provides AQI data, but this seems like it would be easier. Now I just need to get my head around programming the ESP and getting it to play nice with the display!
Reply 3 years ago
I was thinking about Accuweathe API at first, but since i use OWM from the beginning i rested the case. I would like to see your WS someday 😀 Hope i could help you a bit.
Question 3 years ago on Step 3
Hello,
a question regarding the libraries in the header. Shall each (like "NTPClient.h") and others be added in the library? If yes, where I can find it?
And how can the graphic files be uploaded on the Arduino??
Many thanks and regards
Ailt
Answer 3 years ago
Replied.
3 years ago
Hello!
First of all you need to add the ESP8266/32 addon to your arduino IDE. I provide you a link where is a detailed tutorial of the installation for the ESP 8266/32. I recomend that the ESP8266 addon version to V.2.4.0. a,d ESP32 addon to only 1.0.1.
https://randomnerdtutorials.com/how-to-install-esp8266-board-arduino-ide/
The libraries i have used can be found on the internet, search in google like me.For example the NTP Client library can be found here: https://github.com/arduino-libraries/NTPClient . Only download from github.
SPIFFS:https://www.instructables.com/id/Using-ESP8266-SPIFFS/ or if you don't want to suffer with it later, i can send you the spiffs support files(even via email) for IDE that i use and works. The graphic files can only uploaded by spiffs, but first you need to compile and upload sketch to esp8266/32.