🛠 Complete Use Case: Weather Dashboard with M5Stack PaperDIY
Objectifs
This tutorial guides you through creating a functional weather dashboard. You will learn to initialize the ESP32-S3 core module, establish a WiFi connection, fetch data via an API, display information on the 4.7-inch e-paper screen, and save the latest data to the MicroSD card. This project illustrates the synergy between wireless connectivity, low-power display, and local storage of the PaperDIY kit.
Matériel nécessaire
- M5Stack PaperDIY Complete Kit (pre-assembled)
- FAT32 formatted MicroSD card
- USB-C cable for programming
- Computer with Arduino IDE installed
M5GFXandM5Unifiedlibraries installedArduinoJsonlibrary for data parsing
Étapes
- Environment Configuration: In Arduino IDE, select the 'M5Stack-ATOMS3' or 'M5Stack-CoreS3' board depending on your configuration, then choose the COM port corresponding to the PaperDIY.
- System Initialization: In the
setup()function, callM5.begin()to initialize the e-paper display and the ESP32-S3 core module. Configure the display in 16-level grayscale mode for better readability. - WiFi Connection: Use the
WiFi.hlibrary to connect to your local network. Insert your SSID and password credentials. Verify the connection with awhile(WiFi.status() != WL_CONNECTED)loop. - Data Retrieval: Use the
HTTPClientlibrary to send a GET request to a free weather API (like OpenWeatherMap). Parse the JSON response withArduinoJsonto extract temperature and conditions. - Display on Screen: Clear the screen with
M5.Display.clear(). UseM5.Display.drawString()to display the temperature and condition text. Remember to callM5.Display.update()to refresh the e-paper screen. - MicroSD Backup: Initialize the SD card with
M5.SDCard.begin(). Open adata.txtfile in write mode (FILE_WRITE) and write the current weather data to preserve it during power outages.
Vérification
After uploading, the screen should display the updated temperature and weather conditions. Insert the MicroSD card into a computer to verify that the data.txt file contains the latest recorded data. If the display remains blank, check that the 8-bit parallel interface is correctly initialized by the library.
Pour aller plus loin
Explore the deep sleep mode of the ESP32-S3 SoC to extend the battery life of the 140mAh battery. You can also add a physical button to force a manual update or use Bluetooth 5.0 LE to configure WiFi without code.
Other tutorials for this board
Code examples for this board
gpio_led_button_control.inoC++ (Arduino)epaper_hello_world.inoC++ (Arduino)wifi_scanner.inoC++ (Arduino)sd_card_logger.inoC++ (Arduino)ble_beacon.inoC++ (Arduino)gpio-button-led.inoC++ (Arduino)