ESP32-2432S028 LVGL Weather Station

Hi Everyone, two problems for me to discuss here, the first one I solved (by re-coding from the 183 ‘thoughts’ associated with the RandomNerdTutorial for this Weather Station project and looked like a very similar coding issue to the one solved by Boris…using String::String(const char *cstr = “”) so that the working code looks like this:-

//Non Working Code
          ////temperature = String(doc["current"]["temperature_2m"]);
          ////humidity = String(doc["current"]["relative_humidity_2m"]);
          ////is_day = String(doc["current"]["is_day"]).toInt();
          ////weather_code = String(doc["current"]["weather_code"]).toInt();

          // Working Code
          temperature = String((const char *)doc["current"]["temperature_2m"]);
          humidity = String((const char *)doc["current"]["relative_humidity_2m"]);
          is_day = doc["current"]["is_day"].as<int>();
          weather_code = doc["current"]["weather_code"].as<int>();

My second problem is this:

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.12.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20017.241212+sha.dcc1105b 
 - tool-esptoolpy @ 2.40900.250804 (4.9.0) 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- lvgl @ 9.5.0
|-- ArduinoJson @ 7.4.3
|-- TFT_eSPI @ 2.5.43
|-- Weather
|-- HTTPClient @ 2.0.0
|-- WiFi @ 2.0.0
Building in release mode
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  19.2% (used 63068 bytes from 327680 bytes)
Flash: [===Error: The program size (1748989 bytes) is greater than maximum allowed (1310720 bytes)
===*** [checkprogsize] Explicit exit, status 1
====]  133.4% (used 1748989 bytes from 1310720 bytes) 

I can’t see any issues or reports from people using the Arduino IDE? So in this case is my solution going to be using ESPConnect to repartition app0 (set at 1.3MB) and app1 (set at 1.3MB) I’m assuming I have to increase partition app0 size by decreasing app1 size.

The build process doesn’t report any other errors apart from the Flash: program size.

Thanks for any advice in advance.

You can solve this problem by setting a different partition table. If you don’t use OTA updates, you don’t need two app partitions. Just one big one. See documentation:

https://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables

e.g.

board_build.partitions = huge_app.csv

Hi Max, thanks for this it’s made interesting reading following the espressif threads to the github page on partition tables especially the piece on OTA (now I understand how my phone updates!).

A question please if I may, is my understanding correct that huge_app.csv comes from ‘Creating custom Tables’ and the platformio developers have kindly provided this option as I didn’t see it as an option on this page:

https://github.com/espressif/esp-idf/tree/master/components/partition_table

I’ll implement the board_build.partition option and let you know how it works.

Cheers!

Here’s my build result after implementing:-

board_build.partitions = huge_app.csv

Flash memory increased to:-

Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  19.2% (used 63068 bytes from 327680 bytes)
Flash: [======    ]  55.6% (used 1748989 bytes from 3145728 bytes)
Building .pio\build\esp32dev\firmware.bin
esptool.py v4.9.0
Creating esp32 image...
Merged 27 ELF sections
Successfully created esp32 image.
=============================================== [SUCCESS] Took 111.03 seconds ===============================================
 *  Terminal will be reused by tasks, press any key to close it. 


No, you’re looking at the pre-given partition tables from ESP-IDF there, but you’re using the Arduino framework.

The available partition tables are thus at https://github.com/espressif/arduino-esp32/tree/2.0.17/tools/partitions, where huge_app.csv already exists.

Of course you can set it to a filepath or filename of your own liking and create the file yourself, but you don’t need to do that when that file is pregiven.

“Non Working” means fails at compile-time or run-time?

“Non Working” as seen by myself means failed at compile-time.

What’s the ‘educational link’ or thread for a novice like myself to determine how to get to knowing

board_build.partitions = huge_app.csv exists when experiencing the problem I did?

Can you please recommend a structured path to read through so much associated documentation to help me increase my ‘awareness’.

At present with this project I’m left with a blank screen on successful compile-time and run-time, but I’m learning through previous posts that it’s probably due to incorrect library versions and their associated header file settings.

Many thanks Max for all your help, I’m actually enjoying getting to grips with this.

In general, the documentation page for “Espressif 32” PlatformIO options should be read here:

https://docs.platformio.org/en/latest/platforms/espressif32.html

Which in turn links to the Espressif documentation like https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html.

Though other explanations like https://tutoduino.fr/en/partition-esp32-arduino-en/ might be easier to read.

From your project’s dependency graph, you’re using LVGL and TFT_eSPI on an ESP32. That’s quite complicated. I would recommend you to try and get the bare screen working first with only TFT_eSPI before putting a GUI layer on top like LVGL. The most important thing with TFT_eSPI is that you configure your screen parameters correctly: That means screen type, features, GPIO pins on which the screen is physically connected (usually SPI pins and some extra pins like reset or backlight activation). Sometimes, for well-known boards, you can include a pre-written configuration file and be done. See documentation:

https://github.com/Bodmer/TFT_eSPI/wiki/Installing-on-PlatformIO

Finally, displays can be power hungry and sometimes the issue is insufficient power or bad or long cables. Try to keep cables short and make sure they have a good connection.

Once LVGL comes in the mix, memory can also be a concern. It will want to allocate huge buffers for screen buffers, GUI objects, internal objects, et cetera. Make sure to understand your lvgl config file and your available RAM. Some ESP32 boards have a PSRAM chip, which expands the memory. That must be enabled specifically. It’s always a good idea to keep a watch on the serial logs at the maximum verbosity to catch such errors.

Hi Max, a HUGE thank you for this, I’ll take note of everything you mentioned.

However I’ve done the basic things first and have TFT screens using TFT_eSPI working and used some LVGL examples as well. This is the FIRST time I’ve tried connecting a ESP32 to my home WiFi….and it looks like that’s the issue :person_facepalming: as I get this message from the setup()

--- Terminal on COM3 | 115200 8-N-1
--- Available filters and text transformations: debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
.
Connected to Wi-Fi network with IP Address: XXX.XXX.X.XXX (I removed the actual numerics)
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x4008a003  PS      : 0x00060130  A0      : 0x80112dc7  A1      : 0x3ffb1ff0  
A2      : 0x3ffc7c20  A3      : 0x00000000  A4      : 0x00000001  A5      : 0x0000000a  
A6      : 0x3ffd46c4  A7      : 0x00000001  A8      : 0x00000000  A9      : 0x00000000  
A10     : 0x00000001  A11     : 0x00140013  A12     : 0x3ffb206c  A13     : 0x00000013  
A14     : 0x3ffd49fc  A15     : 0x3ffd46f4  SAR     : 0x0000001d  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x4008ab69  LEND    : 0x4008ab79  LCOUNT  : 0xfffffffc  


Backtrace: 0x4008a000:0x3ffb1ff0 0x40112dc4:0x3ffb2010 0x40112eea:0x3ffb2030 0x400d2fa5:0x3ffb2050 0x400d3201:0x3ffb21d0 0x400d368d:0x3ffb2220 0x40114fee:0x3ffb2290


ELF file SHA256: 825f0caf89027dfa

Rebooting...
ets Jul 29 2019 12:21:46

Browsing the BT Community for ESP32 connections draws a blank on this issue, so I think I need to converse with BT directly. Hey Ho life is but a challenge!

LoadProhibited with an exception virtual address of 0x00000000 means that something tried to dereference a null pointer. Null pointers are usually returend when a memory allocation fails (out of RAM) or there’s some corruption bug.

What you need to do to decode the backtrace is to compile in debug mode and add the monitor filter for the decoder. The decoder will kick in when it sees the Backtrace: line and decode it to the actual chain of function calls that led up to this crash. So you can easily see the cause of the crash.

See documemtation:

So you would just add

build_type = debug
monitor_filters = esp32_exception_decoder

and use Upload and Monitor again.

When the cause has been identified and removed, the build_type can be removed again. Debug builds are slow after all, but good for debugging.

If I had to take a guess, that’s because of a misconfigured lv_conf.h trying to allocate more memory than is available on your board, or PSRAM is not enabled although physically present on your board. If you don’t have a PSRAM board, you have to carefully consider memory restrictions.

1 Like

This mornings progress….

  1. I rebuilt a working NEO-6M GPS with TFT & LVGL project and confirmed on a separate ESP32 and TFT (SPI) display that all worked.

  2. I rebuilt a working CYD (ESP32 2432S028) that uses TFT-eSPI to display the touchscreen sensor and x - y coordinates.

  3. I compared using espConnect that both ESP boards are type ESP32-DOWD-V3 (revision 3).

  4. I compared both projects platformio.ini files and noticed the separate ESP32 for the NEO-6M GPS is this:

[env:esp32doit-devkit-v1]

platform = espressif32

board = esp32doit-devkit-v1

framework = arduino

monitor_speed = 115200

lib_deps =

bodmer/TFT_eSPI@^2.5.43

lvgl/lv_demos@^9.3.0

mikalhart/TinyGPSPlus@^1.1.0

The CYD (ESP32 2432S028) project platformio.ini file is this:

[env:esp32dev]

platform = espressif32

board = esp32dev

framework = arduino

monitor_speed = 115200




lib_deps = 

    ; XPT2046 Touchscreen library - using GitHub URL ensures latest version

    https://github.com/PaulStoffregen/XPT2046_Touchscreen.git

    ; TFT_eSPI library by Bodmer

    bodmer/TFT_eSPI@^2.5.43
  1. I tried both versions in my ESP CYD_WiFi_Weatherstation project making sure that in TFT_eSPI the User_Setup.h file was consistently correct across all 3 projects, with the same results that the screen is now flashing White and Black.
  2. I reviewed the serial monitor data and noticed that it was reporting the board was systematically rebooting as it tried to WiFi connect?
  3. I’ve commented out this part of the setup() code:
// Connect to Wi-Fi

  ////WiFi.begin(ssid, password);

  ////Serial.print("Connecting");

  ////while (WiFi.status() != WL_CONNECTED) {

    ////delay(500);

    ////Serial.print(".");

  ////}

  ////Serial.print("\nConnected to Wi-Fi network with IP Address: ");

  ////Serial.println(WiFi.localIP());

I then rebuilt the project and now I have a display showing the colour image from this part of the code:

void get_weather_description(int code) {

  switch (code) {

    case 0:

      if(is_day==1) { lv_image_set_src(weather_image, &image_weather_sun); }

      else { lv_image_set_src(weather_image, &image_weather_night); }

      weather_description = "CLEAR SKY";

      break;

I’ll now rerun the project using this platformio.ini file with and without the WiFi part and report back on the difference:

[env:esp32dev]

platform = espressif32

board = esp32dev




;[env:esp32doit-devkit-v1]

;platform = espressif32

;board = esp32doit-devkit-v1




framework = arduino

monitor_speed = 115200

board_build.partitions = huge_app.csv

build_type = debug

monitor_filters = esp32_exception_decoder

lib_deps = 

    bodmer/TFT_eSPI@^2.5.43

    bblanchon/ArduinoJson@7.0.4

    lvgl/lv_demos@^9.3.0

In my novice understanding it’s pointing to a WiFi code issue if I can generate a nice display.

Here are my results:

First I manually changed the numeric value to select different weather images and they all worked and displayed as expected when the WiFi part of the code was commented out in setup();

This was the serial monitor output:

Building in debug mode

Serial Monitor Output WITHOUT WiFi code in setup(); i.e. COMMENTED OUT

--- Terminal on COM3 | 115200 8-N-1

--- Available filters and text transformations: debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time

--- More details at https://bit.ly/pio-monitor-filters

--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H

ets Jul 29 2019 12:21:46

 

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

configsip: 0, SPIWP:0xee

clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

mode:DIO, clock div:2

load:0x3fff0030,len:1184

load:0x40078000,len:13232

load:0x40080400,len:3028

  #0  0x40080400 in _init at ??:?

 

entry 0x400805e4

LVGL Library Version: 9.5.0

Not connected to Wi-Fi

Not connected to Wi-Fi

Building in debug mode

Serial Monitor Output WITH WiFi code in setup();

// Connect to Wi-Fi

  WiFi.begin(ssid, password);

  Serial.print("Connecting");

  while (WiFi.status() != WL_CONNECTED) {

    delay(500);

    Serial.print(".");

  }

This is the actual serial monitor output:

--- Terminal on COM3 | 115200 8-N-1
--- Available filters and text transformations: debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
ets Jul 29 2019 12:21:46
 
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13232
load:0x40080400,len:3028
  #0  0x40080400 in _init at ??:?
 
entry 0x400805e4
LVGL Library Version: 9.5.0
Connecting.
Connected to Wi-Fi network with IP Address: ***.***.*.***
Request information:
{"latitude":53.5,"longitude":-2.5,"generationtime_ms":0.22220611572265625,"utc_offset_seconds":0,"timezone":"GMT","timezone_abbreviation":"GMT","elevation":46.0,"current_units":{"time":"iso8601","interval":"seconds","temperature_2m":"°C","relative_humidity_2m":"%","is_day":"","precipitation":"mm","rain":"mm","weather_code":"wmo code"},"current":{"time":"2026-06-28T07:00","interval":900,"temperature_2m":17.9,"relative_humidity_2m":74,"is_day":1,"precipitation":0.00,"rain":0.00,"weather_code":3}}
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
 
Core  1 register dump:
PC      : 0x4008a003  PS      : 0x00060130  A0      : 0x8012a2e7  A1      : 0x3ffb1e40 
  #0  0x4008a003 in memmove at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/string/memmove.c:75
 
A2      : 0x3ffc7c3c  A3      : 0x00000000  A4      : 0x00000001  A5      : 0x3ffbdb8c 
  #0  0x3ffc7c3c in ?? at src/main.cpp:44
 
A6      : 0x00000019  A7      : 0x1fffffff  A8      : 0x00000000  A9      : 0x00000000 
A10     : 0x00000001  A11     : 0x3ffb206c  A12     : 0x00000190  A13     : 0x0000000a 
A14     : 0x00000000  A15     : 0x0000007b  SAR     : 0x0000001d  EXCCAUSE: 0x0000001c 
EXCVADDR: 0x00000000  LBEG    : 0x4008ab69  LEND    : 0x4008ab79  LCOUNT  : 0xfffffffc 
 
 
Backtrace: 0x4008a000:0x3ffb1e40 0x4012a2e4:0x3ffb1e60 0x4012a40a:0x3ffb1e80 0x400d6515:0x3ffb1ea0 0x400d8469:0x3ffb21d0 0x400d8973:0x3ffb2220 0x4012c50e:0x3ffb2290
  #0  0x4008a000 in memmove at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/string/memmove.c:66
  #1  0x4012a2e4 in String::move(String&) at C:/Users/derek/.platformio/packages/framework-arduinoespressif32/cores/esp32/WString.cpp:237
  #2  0x4012a40a in String::operator=(String&&) at C:/Users/derek/.platformio/packages/framework-arduinoespressif32/cores/esp32/WString.cpp:277
  #3  0x400d6515 in get_weather_data() at src/main.cpp:108 (discriminator 7)
  #4  0x400d8469 in lv_create_main_gui() at src/main.cpp:286
  #5  0x400d8973 in setup() at src/main.cpp:377
  #6  0x4012c50e in loopTask(void*) at C:/Users/derek/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:42
 
 
 
 
 
ELF file SHA256: 763b8b2545f022e3
 
Rebooting...
ets Jul 29 2019 12:21:46
 
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13232
load:0x40080400,len:3028
  #0  0x40080400 in _init at ??:?
 
entry 0x400805e4
LVGL Library Version: 9.5.0
Connecting..
Connected to Wi-Fi network with IP Address: ***.***.*.***
Request information:
{"latitude":53.5,"longitude":-2.5,"generationtime_ms":0.29456615447998047,"utc_offset_seconds":0,"timezone":"GMT","timezone_abbreviation":"GMT","elevation":46.0,"current_units":{"time":"iso8601","interval":"seconds","temperature_2m":"°C","relative_humidity_2m":"%","is_day":"","precipitation":"mm","rain":"mm","weather_code":"wmo code"},"current":{"time":"2026-06-28T07:00","interval":900,"temperature_2m":17.9,"relative_humidity_2m":74,"is_day":1,"precipitation":0.00,"rain":0.00,"weather_code":3}}
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
 
Core  1 register dump:
PC      : 0x4008a003  PS      : 0x00060130  A0      : 0x8012a2e7  A1      : 0x3ffb1e40 
  #0  0x4008a003 in memmove at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/string/memmove.c:75
 
A2      : 0x3ffc7c3c  A3      : 0x00000000  A4      : 0x00000001  A5      : 0x3ffb1d50 
  #0  0x3ffc7c3c in ?? at src/main.cpp:44
 
A6      : 0x00000001  A7      : 0x3ffb0320  A8      : 0x00000000  A9      : 0x00000000 
A10     : 0x00000001  A11     : 0x00000001  A12     : 0x80000020  A13     : 0x00000007 
A14     : 0x00000005  A15     : 0x00000001  SAR     : 0x0000001b  EXCCAUSE: 0x0000001c 
EXCVADDR: 0x00000000  LBEG    : 0x4008ab69  LEND    : 0x4008ab79  LCOUNT  : 0xfffffffc 
 
 
Backtrace: 0x4008a000:0x3ffb1e40 0x4012a2e4:0x3ffb1e60 0x4012a40a:0x3ffb1e80 0x400d6515:0x3ffb1ea0 0x400d8469:0x3ffb21d0 0x400d8973:0x3ffb2220 0x4012c50e:0x3ffb2290
  #0  0x4008a000 in memmove at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/string/memmove.c:66
  #1  0x4012a2e4 in String::move(String&) at C:/Users/derek/.platformio/packages/framework-arduinoespressif32/cores/esp32/WString.cpp:237
  #2  0x4012a40a in String::operator=(String&&) at C:/Users/derek/.platformio/packages/framework-arduinoespressif32/cores/esp32/WString.cpp:277
  #3  0x400d6515 in get_weather_data() at src/main.cpp:108 (discriminator 7)
  #4  0x400d8469 in lv_create_main_gui() at src/main.cpp:286
  #5  0x400d8973 in setup() at src/main.cpp:377
  #6  0x4012c50e in loopTask(void*) at C:/Users/derek/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:42
 
ELF file SHA256: 763b8b2545f022e3
 
Rebooting...
ets Jul 29 2019 12:21:46

Result is a flashing screen with image 65 (Rain Heavy Intensity…usual for NW England!) as board reboots.

This is the smoking gun. The bug is in the get_weather_data() function. It tries to move or create some String from another String that internally has a null pointer as content.

What’s the content of that function? Specifically line 108 in src/main.cpp?

Oooppps…I’d better post the whole of that function code as it’s in one of my previous posts above (I think it’s post 5 and post 6), I’m sure you’ll see the issue I’ve tried to solve Max.

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" + temperature_unit + "&timezone=" + timezone + "&forecast_days=1");

    http.begin(url);

    int httpCode = http.GET(); // Make the GET request




    if (httpCode > 0) {

      // Check for the response

      if (httpCode == HTTP_CODE_OK) {

        String payload = http.getString();

        Serial.println("Request information:");

        Serial.println(payload);

        // Parse the JSON to extract the time

        JsonDocument doc;

        DeserializationError error = deserializeJson(doc, payload);

        if (!error) {

          const char* datetime = doc["current"]["time"];




          //Non Working Code

          /*[{"resource": "/c:/Users/derek/OneDrive/Documents/PlatformIO/Projects/ESP32 CYD_WiFi_WeatherStation/src/main.cpp",

            "owner": "cpp",

            "severity": 8,

            "message": "call of overloaded 'String(ArduinoJson::V704PB2::detail::enable_if<true, ArduinoJson::V704PB2::detail::MemberProxy<ArduinoJson::V704PB2::detail::MemberProxy<ArduinoJson::V704PB2::JsonDocument&, const char*>, const char*> >::type)' is ambiguous",

            "startLineNumber": 102,

            "startColumn": 64,

            "endLineNumber": 102,

              "endColumn": 64

          }]*/

          ////temperature = String(doc["current"]["temperature_2m"]);

          ////humidity = String(doc["current"]["relative_humidity_2m"]);

          ////is_day = String(doc["current"]["is_day"]).toInt();

          ////weather_code = String(doc["current"]["weather_code"]).toInt();




          // Working Code

          temperature = String((const char *)doc["current"]["temperature_2m"]);

          humidity = String((const char *)doc["current"]["relative_humidity_2m"]);

          is_day = doc["current"]["is_day"].as<int>();

          weather_code = doc["current"]["weather_code"].as<int>();




          Serial.println(temperature);

          Serial.println(humidity);

          Serial.println(is_day);

          Serial.println(weather_code);

          Serial.println(String(timezone));

          // Split the datetime into date and time

          String datetime_str = String(datetime);

          int splitIndex = datetime_str.indexOf('T');

          current_date = datetime_str.substring(0, splitIndex);

          last_weather_update = datetime_str.substring(splitIndex + 1, splitIndex + 9); // Extract time portion

        } else {

          Serial.print("deserializeJson() failed: ");

          Serial.println(error.c_str());

        }

      }

      else {

        Serial.println("Failed");

      }

    } else {

      Serial.printf("GET request failed, error: %s\n", http.errorToString(httpCode).c_str());

    }

    http.end(); // Close connection

  } else {

    Serial.println("Not connected to Wi-Fi");

  }

}

This code may compile but still fail during runtime. Can you replace this with

float temp = doc["current"]["temperature_2m"].as<float>();
int hum = doc["current"]["relative_humidity_2m"].as<int>();

temperature = String(temp, 1);      // e.g. "17.9"
humidity = String(hum);             // e.g. "74"

is_day = doc["current"]["is_day"].as<int>();
weather_code = doc["current"]["weather_code"].as<int>();

Respect Max,

Thank you for everything that’s successfully compiled and runtime and I have an accurate WiFi connected display.

  1. I’ll try to learn what the code difference is and why it works between the three versions.
  2. I hope other ‘Newbies’ read this and pick up the learning thread from the original Randomnerdtutorials example.

Many many thanks Max.