Comments on: ESP32 TFT with LVGL: Weather Station (Description, Temperature, Humidity) https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Wed, 30 Jul 2025 16:44:34 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Mark Edwards https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/#comment-1076338 Wed, 30 Jul 2025 16:44:34 +0000 https://randomnerdtutorials.com/?p=162168#comment-1076338 In reply to Carlos.

Here is a code extract – let me know if you need more information.

void get_weather_data() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
// Construct the API endpoint
String url = String(“http://api.open-meteo.com/v1/forecast?latitude=” + latitude + “&longitude=” + longitude + “&current=temperature_2m,relative_humidity_2m,is_day,precipitation,rain,weather_code,wind_speed_10m,wind_direction_10m” + temperature_unit + “&timezone=” + timezone + “&forecast_days=1”);
// Added wind speed and direction to API call.

later in the code:

//******************************
wind_speed = String(doc[“current”][“wind_speed_10m”]);
wind_len = wind_speed.length();
if (wind_len > 4) {
wind_speed = wind_speed.substring(0,4);
}

wind_direction = String(doc["current"]["wind_direction_10m"]);
wind_angle = wind_direction.toInt();
if ((wind_angle > 337.5)||(wind_angle <= 22.5)) {wind_cardinal =" N";}
if ((wind_angle > 22.5)&&(wind_angle <= 67.5)) {wind_cardinal =" NE";}
if ((wind_angle > 67.5)&&(wind_angle <= 112.5)) {wind_cardinal =" E";}
if ((wind_angle > 112.5)&&(wind_angle <= 157.5)) {wind_cardinal =" SE";}
if ((wind_angle > 157.5)&&(wind_angle <= 202.5)) {wind_cardinal =" S";}
if ((wind_angle > 202.5)&&(wind_angle <= 247.5)) {wind_cardinal =" SW";}
if ((wind_angle > 247.5)&&(wind_angle <= 292.5)) {wind_cardinal =" W";}
if ((wind_angle > 292.5)&&(wind_angle <= 337.5)) {wind_cardinal =" NW";}

//then I just added these to the display code
in void lv_create_main_gui(void) I added:
//********************************
text_label_wind_speed = lv_label_create(lv_screen_active());
lv_label_set_text(text_label_wind_speed, String(” ” + wind_speed + “km”).c_str());
lv_obj_align(text_label_wind_speed, LV_ALIGN_CENTER, 60, -17);
lv_obj_set_style_text_font((lv_obj_t*) text_label_wind_speed, &lv_font_montserrat_22, 0);

And finally added the following to static void timer_cb(lv_timer_t * timer){

lv_label_set_text(text_label_wind_speed, String(" " + wind_speed + " km" + wind_cardinal).c_str());

]]>
By: Carlos https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/#comment-1075957 Tue, 29 Jul 2025 13:44:31 +0000 https://randomnerdtutorials.com/?p=162168#comment-1075957 In reply to Mark Edwards.

Hi Mark, I made some changes on mine as well but would be interested in adding wind, any chance you can share your source code with me? Thank you.

]]>
By: Luis https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/#comment-1022979 Fri, 04 Apr 2025 04:09:36 +0000 https://randomnerdtutorials.com/?p=162168#comment-1022979 The Interrupt PIN selected (GPIO 36) for T_IRQ is not a good choice. It will behave unreliably because only TOUCH pins are mapped to the ESP32 hardware MUX. You should select from available TOUCH0 to 9 inputs, respectively GPIO # 4,0,2,15,13,12,14,27,33,32

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/#comment-1016111 Thu, 13 Mar 2025 10:23:57 +0000 https://randomnerdtutorials.com/?p=162168#comment-1016111 In reply to Ben.

That’s great.
Thank you so much.
Regards,
Sara

]]>
By: Ben https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/#comment-1015739 Wed, 12 Mar 2025 01:48:18 +0000 https://randomnerdtutorials.com/?p=162168#comment-1015739 As Paul McWhorter would say: BOOM!

This works perfectly on my ESP-32 WROOM.

Thank you so much, Sara. I’ve only been programming Arduino projects for about 2 months, and during that time I’ve learned to ignore all the noise out there and come straight to you when I have an issue. You don’t just provide the answers, you teach your readers how and why things work. As someone who is eager to learn, I am grateful to have found you! Keep doing what you’re doing, and I will keep practicing so that some day I can become you!

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/#comment-1015215 Mon, 10 Mar 2025 05:54:13 +0000 https://randomnerdtutorials.com/?p=162168#comment-1015215 In reply to hide yoko.

You’re probably inserting the location in a wrong format.
Regards,
Sara

]]>
By: Mark Edwards https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/#comment-1013579 Wed, 05 Mar 2025 14:42:55 +0000 https://randomnerdtutorials.com/?p=162168#comment-1013579 In reply to Bruno.

Nice

]]>
By: Bruno https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/#comment-1013513 Wed, 05 Mar 2025 10:55:29 +0000 https://randomnerdtutorials.com/?p=162168#comment-1013513 It’s working :

#define GPIO21 21 //black screen
int prevState = LOW; //touch

In the loop :
….
// Screen ON or OFF when touch
if (touchscreen.tirqTouched() && touchscreen.touched()) {
int currState = digitalRead(GPIO21);
if(currState != prevState)
{
digitalWrite (GPIO21, LOW);
}
else { digitalWrite (GPIO21, HIGH);
prevState = currState;
}
}

]]>
By: Bruno https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/#comment-1013187 Tue, 04 Mar 2025 08:21:58 +0000 https://randomnerdtutorials.com/?p=162168#comment-1013187 Thank’s I will try…

]]>
By: Mark Edwards https://randomnerdtutorials.com/esp32-tft-lvgl-weather-station/#comment-1013023 Mon, 03 Mar 2025 20:17:03 +0000 https://randomnerdtutorials.com/?p=162168#comment-1013023 If you look at the code from one of the other tutorials you should be able to do this.

https://randomnerdtutorials.com/cheap-yellow-display-esp32-2432s028r/

This has code for using the touch screen and adding the required library (XPT2046_Touchscreen.h) as well as the initialization code.

Touch detection is below…
if (touchscreen.tirqTouched() && touchscreen.touched())

And you can toggle the screen off and on by toggling the backlight I believe – Backlight Pin is GPIO 21.

]]>