Comments on: ESP32 CYD with LVGL: Weather Station (Description, Temperature, Humidity) https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Thu, 05 Jun 2025 21:08:07 +0000 hourly 1 https://wordpress.org/?v=6.8.1 By: Stp https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/#comment-1055046 Thu, 05 Jun 2025 21:08:07 +0000 https://randomnerdtutorials.com/?p=161726#comment-1055046 In reply to Jan Pieter Duhen.

No, I have several CYD with 2 USB ports.

There is no code in this sketch to enable the backlight.

They forgot to enable the backlight! Schoolboy error.

Add this to your header section (at the top):

#define BACKLIGHT_PIN 21 // Screen backlight LED

Note – change the number if your board uses a different pin, but this is most common for all CYD

Next add this to the Setup section:

// Set up hardware pins
pinMode(BACKLIGHT_PIN, OUTPUT);
digitalWrite(BACKLIGHT_PIN, HIGH);

Sorted!

]]>
By: Owen https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/#comment-1044361 Wed, 14 May 2025 19:24:35 +0000 https://randomnerdtutorials.com/?p=161726#comment-1044361 In reply to Ryan.

Thanks for sharing, your post helped me with solving the same issue mentioned by @John Gerrard.

]]>
By: Tom Greenhaw https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/#comment-1029437 Mon, 21 Apr 2025 15:08:46 +0000 https://randomnerdtutorials.com/?p=161726#comment-1029437 In reply to Scott.

It sounds like you don’t have the LVGL libraries installed to include all the font sizes needed for this program. I would go through the complete installation process outlined in https://randomnerdtutorials.com/lvgl-cheap-yellow-display-esp32-2432s028r/. Check especially that you have the correct lv_conf.h file in the C:\Arduino\libraries folder and that you have the lv_font_montserrat .c files in C:\Arduino\libraries\lvgl\src\font folder. Replace the c:\Arduino for the path on your computer of course.

For the second issue, I think you need to change your Partition Scheme in the Tools menu to Huge APP.

]]>
By: Scott https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/#comment-1028952 Sun, 20 Apr 2025 00:05:27 +0000 https://randomnerdtutorials.com/?p=161726#comment-1028952 I am at wits end to see nobody having the issues I had and still have 1 I can’t resolve
First it the Font size other than 18 mine will not compile with 22 or 26 or 12 possibly I am using a different version or rev and I am still stuck on this error
CYD_Weather_2.ino.elf section .dram0.bss' will not fit in regiondram0_0_seg’
xtensa-esp-elf/bin/ld.exe: DRAM segment data does not fit.
xtensa-esp-elf/bin/ld.exe: DRAM segment data does not fit.
/../../../../xtensa-esp-elf/bin/ld.exe: region `dram0_0_seg’ overflowed by 5504 bytes
collect2.exe: error: ld returned 1 exit status

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/#comment-1023423 Sat, 05 Apr 2025 09:28:00 +0000 https://randomnerdtutorials.com/?p=161726#comment-1023423 In reply to Tom Greenhaw.

That’s great.
Thanks for sharing this.

Regards,
Sara

]]>
By: Tom Greenhaw https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/#comment-1023180 Fri, 04 Apr 2025 16:07:58 +0000 https://randomnerdtutorials.com/?p=161726#comment-1023180 You can use the following code snippet to dim the backlight display automatically by reading the Light Detecting Resistor (LDR on pin 34) and setting the analog value output on backlight pin 21. I get better sleep this way in my bedroom 🙂

int analogValue = analogRead(LDR_PIN); // Read analog value from GPIO 34
//Serial.print(“LDR Analog Value: “);
//Serial.println(analogValue);
if(analogValue > 10 ) {
analogWrite(BACKLIGHT_PIN, 16);
} else
{
analogWrite(BACKLIGHT_PIN, 256);
}

]]>
By: Tom Greenhaw https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/#comment-1023179 Fri, 04 Apr 2025 16:04:05 +0000 https://randomnerdtutorials.com/?p=161726#comment-1023179 Below is a sketch that plays onboard audio (01.mp3 on the micro usb card) on the CYD. When this is added to the LVGL Weather Station, you’ll see the conflict with the XP2046 touchscreen driver that uses the legacy A/D code. The quality is horrible until you do the audio amp gain mod (https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display/blob/main/Mods/README.md) which entails soldering a 10k resistor.

#include <Arduino.h>
#include <WiFi.h>
#include “AudioFileSourceSD.h”
#include “AudioFileSourceID3.h”
#include “AudioGeneratorMP3.h”
#include “AudioOutputI2S.h”

AudioFileSourceSD *file;
AudioGeneratorMP3 *mp3;
AudioFileSourceSD *source;
AudioOutputI2S *out;
AudioFileSourceID3 *id3;
SPIClass SDSPI(VSPI);

void setup() {
Serial.begin(115200);

Serial.print(“setup”);
Serial.println();

Serial.println();
WiFi.mode(WIFI_OFF);
delay(500);

pinMode(5, OUTPUT);
digitalWrite(5, HIGH);
SDSPI.begin(18, 19, 23); // SDSPI.begin(SCLK, MISO, MOSI);
SDSPI.setFrequency(1000000);
SD.begin(5, SDSPI);

Serial.print(“end setup”);
Serial.println();

}

void playMP3(char *filename) {
file = new AudioFileSourceSD(filename);
id3 = new AudioFileSourceID3(file);
out = new AudioOutputI2S(0,AudioOutputI2S::INTERNAL_DAC);
out->SetOutputModeMono(true);
out->SetGain(0.019);
out->SetRate(44100);
mp3 = new AudioGeneratorMP3();
mp3->begin(id3, out);
while (mp3->isRunning()) {
if (!mp3->loop()) mp3->stop();
}
}

void loop() {
playMP3(“/01.mp3”);
}

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/#comment-1023087 Fri, 04 Apr 2025 10:18:59 +0000 https://randomnerdtutorials.com/?p=161726#comment-1023087 In reply to Tom Greenhaw.

Hi.
That’s probably because the SPI communication for the SD card is interfering with the SPI for the touchscreen.
At the moment, we don’t have a tutorial showing how to use both.
We intend to do that in a near future.

Regards,
Sara

]]>
By: Tom Greenhaw https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/#comment-1022424 Wed, 02 Apr 2025 20:08:49 +0000 https://randomnerdtutorials.com/?p=161726#comment-1022424 This is a great project! I’m a huge fan of your tutorials.

I’ve added to the program to make it a bedside clock that uses the LDR to automatically dim the display in a darkened room. I’ve also added the ability to play an MP3, in my case ocean sounds pink noise to mask ambient noise for better sleep.

Unfortunately I’ve had to resort to using an external Serial MP3 Player that interfaces with the CYD using P1.

Although I have a separate program that successfully plays MP3 files using the CYD SD card reader and Speaker output, it conflicts with the XPT2046_Touchscreen library and throws “AudioFileSourceSD.h: E (545) ADC: CONFLICT! driver_ng is not allowed to be used with the legacy driver”. It would be awesome if we could resolve this with updated libraries because we could not only make something useful, but demonstrate how every feature of the CYD can be used.

BTW, I’m happy to share the sketch for you to use however you like.

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-cyd-lvgl-weather-station/#comment-1019920 Wed, 26 Mar 2025 10:25:53 +0000 https://randomnerdtutorials.com/?p=161726#comment-1019920 In reply to Bernard CARLIGNY.

Hi.
Make sure that you entered valid information on the following variables:
// Replace with the latitude and longitude to where you want to get the weather
String latitude = “41.14961”;
String longitude = “-8.61099”;
// Enter your location
String location = “Porto”;
// Type the timezone you want to get the time for
String timezone = “Europe/Lisbon”;

Regards,
Sara

]]>