The CYD – (C)areful who (Y)ou invite for (D)inner
This post will cover the ESP32 based CYD, commonly know as the Cheap Yellow Display. The earlier post wireless network health scanner code will be repurposed here, (https://www.cloudacm.com/?p=5130).
The hardware platform here is the ESP32-2432S028. It is an ESP32 based development board with an integrated 240 x 320 2.8 TFT display and microSD slot. The board typically ships with a stylus, USB C cable, and 4 pin jumper cable to serial connections.
The code at the bottom of this post will be provided that makes use of the display and memory card for data storage, which was built using the Arduino IDE. The changes made to the repurposed code is the use of the SPI, FS, and SD libraries which was used in earlier ESP32-Cam posts. In addition, the LovyanGFX library will be used to drive the display. The firmware makes use of macros to help with the readability of the code.
const char* FileName = "/DataLogFile.txt";
#define LogData(FileContent) appendFile(SD, FileName, FileContent)
...
LogData("This is data written to the micro SD media");
Added to the code is a function that queries the public internet address if the internet access is successful. The MQTT subscription has been expanded to initiate that query on demand. There is an additional subscription to realtime epoch timestamp data that can be stored on the microSD log file.
The LovyanGFX library (https://github.com/lovyan03/LovyanGFX) is extensive and this demo is extremely simplistic with the intent to gain inroads into its functionality. There is mention online about limitations with the CYD supporting the display, touch control, and SD card module together, see (https://github.com/AndroidCrypto/ESP32_CYD_Display_with_Touch_and_SD_Card). For the sake of ease, touch functions will not be used in this demo.
These sources were referenced in the development of this demo:
https://github.com/lovyan03/LovyanGFX
https://github.com/AndroidCrypto/ESP32_CYD_Display_with_Touch_and_SD_Card
https://github.com/dazzor/photoframe/blob/main/CYDusingLovyanGFX
https://medium.com/@androidcrypto/how-to-use-touch-and-sd-card-at-the-same-time-on-an-esp32-cheap-yellow-display-cyd-45fa55d01ffe
https://randomnerdtutorials.com/esp32-cyd-display-touchscreen-microsd-card/
The hardware is enclosed in a 3D printed case provided by KRO Labs, (https://www.etsy.com/shop/KROLabs).
The CYD firmware was compiled on Arduino IDE ver 1.8.19
Board: ESP32 Dev Module
Library used in this code:
WiFi at version 3.3.8 from Espressif
Network at version 3.3.8 from Espressif
PubSubClient at version 2.8 from https://github.com/knolleary/pubsubclient
ESPping at version 1.0.5 from https://github.com/dvarrel/ESPping
HTTPClient at version 3.3.8 from Espressif
NetworkClientSecure at version 3.3.8 from Espressif
LovyanGFX at version 1.2.21 from https://github.com/lovyan03/LovyanGFX
SPI at version 3.3.8 from Espressif
FS at version 3.3.8 from Espressif
SD at version 3.3.8 from Espressif
Sketch uses 1247519 bytes (39%) of program storage space. Maximum is 3145728 bytes.
Global variables use 52004 bytes (15%) of dynamic memory, leaving 275676 bytes for local variables. Maximum is 327680 bytes.
Code is available here, https://github.com/cloudacm/ESP32-CYD-LovyanGFX-microSD
This post was inspired by many developers of the CYD platform, too many to recall or name here. To give some scale of what the CYD can do this video demonstrates video on the CYD.


