# ESP32 E-Paper Weather Clock

An ESP32-powered desk clock using a Waveshare 4.26" e-paper display that shows the current date, time, weather conditions, and a temperature forecast graph.

![Front view](images/front.jpg)

## Features

- **Real-time clock** - NTP-synced time display with partial refresh for smooth updates
- **Current weather** - Temperature fetched from OpenWeatherMap API
- **Tomorrow's forecast** - Min/max temperature and rain probability
- **24-hour temperature graph** - Smooth Catmull-Rom spline interpolation
- **Low power display** - E-paper only uses power when updating
- **Auto-refresh** - Weather updates every 30 minutes, full display refresh on date change

## Hardware Requirements

- ESP32 development board
- Waveshare 4.26" e-paper display module (GDEQ0426T82, 800x480 resolution)

### Pin Mapping

| Signal | ESP32 GPIO |
|--------|------------|
| CS     | 5          |
| DC     | 17         |
| RST    | 4          |
| BUSY   | 16         |
| SCK    | 18         |
| MOSI   | 23         |

## Dependencies

Install these libraries via Arduino Library Manager:

- **GxEPD2** - E-paper display driver
- **Adafruit GFX Library** - Graphics primitives (required by GxEPD2)
- **ArduinoJson** - JSON parsing for weather API responses

## Setup

1. **Copy the configuration template:**
   ```
   cp config.h.example config.h
   ```

2. **Get an OpenWeatherMap API key:**
   - Sign up at [openweathermap.org](https://openweathermap.org/api)
   - Get a free API key (Current Weather and 5-day forecast)

3. **Edit `config.h` with your settings:**
   ```c
   const char* ssid = "YourWiFiNetwork";
   const char* password = "YourWiFiPassword";
   const char* weatherApiKey = "your_api_key_here";
   const float latitude = 51.5074;   // Your latitude
   const float longitude = -0.1278;  // Your longitude
   ```

4. **Configure your timezone** in `ESP32WaveshareEPaperCalendar.ino`:
   ```c
   const char* time_zone = "GMT0BST,M3.5.0/1,M10.5.0";  // Example: UK
   ```
   Find your timezone string: [POSIX Timezone Database](https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv)

## Build & Upload

### Arduino IDE

1. Open `ESP32WaveshareEPaperCalendar.ino`
2. Select your ESP32 board from Tools > Board
3. Select the correct port from Tools > Port
4. Click Upload

### Arduino CLI

```bash
arduino-cli compile --fqbn esp32:esp32:esp32 ESP32WaveshareEPaperCalendar
arduino-cli upload -p COM3 --fqbn esp32:esp32:esp32 ESP32WaveshareEPaperCalendar
```

## 3D Printed Enclosure

![Back view showing enclosure](images/back.jpg)

The `models/` folder contains 3D printable parts for a desk stand enclosure:

| File | Description |
|------|-------------|
| `body.obj` | Main frame that holds the e-paper display |
| `foot.obj` | Stand legs for tabletop positioning |
| `espbrace.obj` | Mounting bracket to secure the ESP32 on the back |

Print with PLA or PETG. The parts glue together and hold the display at a comfortable viewing angle.

## License

MIT License - see [LICENSE](LICENSE) for details.
