lmarzen / esp32-weather-epd

A low-power E-Paper weather display powered by an ESP32 microcontroller. Utilizes the OpenWeatherMap API.
GNU General Public License v3.0
2.49k stars 196 forks source link
display eink embedded epaper esp32 weather

ESP32 E-Paper Weather Display

This is a weather display powered by a wifi-enabled ESP32 microcontroller and a 7.5in E-Paper (aka E-ink) display. Current and forecasted weather data is obtained from the OpenWeatherMap API. A sensor provides the display with accurate indoor temperature and humidity.

The project draws ~14μA when sleeping and an estimated average of ~83mA during its ~15s wake period. The display can be configured to update as frequently as desired. When the refresh interval is set to 30 minutes, the device will run for >6 months on a single 5000mAh battery. The project displays accurate battery life percentage and can be recharged via a USB-C cable connected to a wall adapter or computer.

There are configuration options for everything from location, time/date formats, units, and language to air quality index scale and hourly outlook graph bounds.

The hourly outlook graph (bottom right) shows a line indicating temperature and shaded bars indicating probability of precipitation (or optionally volume of precipitation).

Here are two examples utilizing various configuration options:

Contents

Setup Guide

Hardware

7.5inch (800×480) E-Paper Display

DESPI-C02 Adapter Board

FireBeetle 2 ESP32-E Microcontroller

BME280 - Pressure, Temperature, and Humidity Sensor

3.7V Lipo Battery w/ 2 Pin JST Connector

Stand/Frame

Wiring

Pin connections are defined in config.cpp.

If you are using the FireBeetle 2 ESP32-E, you can use the connections I used or change them how you would like.

I have included 2 wiring diagrams. One for the Waveshare HAT rev2.2 and another using the recommended DESPI-C02.

IMPORTANT: The Waveshare E-Paper Driver HAT has two physical switches that MUST be set correctly for the display to work.

IMPORTANT: The DESPI-C02 adapter has one physical switch that MUST be set correctly for the display to work.

Cut the low power pad for even longer battery life.

Configuration, Compilation, and Upload

PlatformIO for VSCode is used for managing dependencies, code compilation, and uploading to ESP32.

  1. Clone this repository or download and extract the .zip.

  2. Install VSCode.

  3. Follow these instructions to install the PlatformIO extension for VSCode: https://platformio.org/install/ide?install=vscode

  4. Open the project in VSCode.

    a. File > Open Folder...

    b. Navigate to this project and select the folder called "platformio".

  5. Configure Options.

    • Most configuration options are located in config.cpp, with a few in config.h. Locale/language options can also be found in locales/locale_**.cpp.

    • Important settings to configure in config.cpp:

      • WiFi credentials (ssid, password).

      • Open Weather Map API key (it's free, see next section for important notes about obtaining an API key).

      • Latitude and longitude.

      • Time and date formats.

      • Sleep duration.

      • Pin connections for E-Paper (SPI), BME280 (I2C), and battery voltage (ADC).

    • Important settings to configure in config.h:

      • Units (Metric or Imperial).
    • Comments explain each option in detail.

  6. Build and Upload Code.

    a. Connect ESP32 to your computer via USB.

    b. Click the upload arrow along the bottom of the VSCode window. (Should say "PlatformIO: Upload" if you hover over it.)

    • PlatformIO will automatically download the required third-party libraries, compile, and upload the code. :)

    • You will only see this if you have the PlatformIO extension installed.

    • If you are getting errors during the upload process, you may need to install drivers to allow you to upload code to the ESP32.

OpenWeatherMap API Key

Sign up here to get an API key; it's free. https://openweathermap.org/api

This project will make calls to 2 different APIs ("One Call" and "Air Pollution").

Here's how to subscribe and avoid any credit card changes:

Error Messages and Troubleshooting

Low Battery

This error screen appears once the battery voltage has fallen below LOW_BATTERY_VOLTAGE (default = 3.20v). The display will not refresh again until it detects battery voltage above LOW_BATTERY_VOLTAGE. When battery voltage is between LOW_BATTERY_VOLTAGE and VERY_LOW_BATTERY_VOLTAGE (default = 3.10v) the esp32 will deep-sleep for periods of LOW_BATTERY_SLEEP_INTERVAL (default = 30min) before checking battery voltage again. If the battery voltage falls between LOW_BATTERY_SLEEP_INTERVAL and CRIT_LOW_BATTERY_VOLTAGE (default = 3.00v), then the display will deep-sleep for periods VERY_LOW_BATTERY_SLEEP_INTERVAL (default = 120min). If battery voltage falls below CRIT_LOW_BATTERY_VOLTAGE, then the esp32 will enter hibernate mode and will require a manual push of the reset (RST) button to begin updating again.


WiFi Connection

This error screen appears when the ESP32 fails to connect to WiFi. If the message reads "WiFi Connection Failed" this might indicate an incorrect password. If the message reads "SSID Not Available" this might indicate that you mistyped the SSID or that the esp32 is out of the range of the access point. The esp32 will retry once every SLEEP_DURATION (default = 30min).


API Error

This error screen appears if an error (client or server) occurs when making an API request to OpenWeatherMap. The second line will give the error code followed by a descriptor phrase. Positive error codes correspond to HTTP response status codes, while error codes <= 0 indicate a client(esp32) error. The esp32 will retry once every SLEEP_DURATION (default = 30min).

In the example shown to the left, "401: Unauthorized" may be the result of an incorrect API key or that you are attempting to use the One Call v3 API without the proper account setup.


Time Server Error

This error screen appears when the esp32 fails to fetch the time from NTP_SERVER_1/NTP_SERVER_2. This error sometimes occurs immediately after uploading to the esp32; in this case, just hit the reset button or wait for SLEEP_DURATION (default = 30min) and the esp32 to automatically retry. If the error persists, try selecting closer/lower latency time servers or increasing NTP_TIMEOUT.


Licensing

esp32-weather-epd is licensed under the GNU General Public License v3.0 with tools, fonts, and icons whose licenses are as follows:

Name License Description
Adafruit-GFX-Library: fontconvert BSD License CLI tool for preprocessing fonts to be used with the Adafruit_GFX Arduino library.
pollutant-concentration-to-aqi GNU Lesser General Public License v2.1 C library that converts pollutant concentrations to Air Quality Index(AQI).
GNU FreeFont GNU General Public License v3.0 Font Family
Lato SIL OFL v1.1 Font Family
Montserrat SIL OFL v1.1 Font Family
Open Sans SIL OFL v1.1 Font Family
Poppins SIL OFL v1.1 Font Family
Quicksand SIL OFL v1.1 Font Family
Raleway SIL OFL v1.1 Font Family
Roboto Apache License v2.0 Font Family
Roboto Mono Apache License v2.0 Font Family
Roboto Slab Apache License v2.0 Font Family
Ubuntu font Ubuntu Font Licence v1.0 Font Family
Weather Themed Icons SIL OFL v1.1 (wi-**.svg) Weather icon family by Lukas Bischoff/Erik Flowers.
Google Icons Apache License v2.0 (battery**.svg, visibility_icon.svg) Battery and visibility icons from Google Icons.
Biological Hazard Symbol CC0 v1.0 (biological_hazard_symbol.svg) Biohazard icon.
House Icon MIT License (house.svg) House icon.
Indoor Temerature/Humidity Icons SIL OFL v1.1 (house_**.svg) Indoor temerature/humidity icons.
Ionizing Radiation Symbol CC0 v1.0 (ionizing_radiation_symbol.svg) Ionizing radiation icons.
Phosphor Icons MIT License (wifi**.svg, warning_icon.svg, error_icon.svg) WiFi, Warning, and Error icons from Phosphor Icons.
Wind Direction Icon CC BY v3.0 (meteorological_winddirection**deg.svg) Meteorological wind direction icon from Online Web Fonts.