A GPS-synchronized 24-hour LED clock that automatically displays sunrise and sunset times for your location. Built with ESP32 and WS2812B addressable LEDs.
Erick's Sun Clock in action - GPS-synchronized LED display showing the 24-hour cycle
- π°οΈ GPS Time Sync: Automatically sets time and timezone based on your GPS location
- π Sunrise/Sunset Display: Shows daily sunrise and sunset times as colored arcs
- π Location Aware: Works anywhere in the world - no hardcoded locations
- πΆ WiFi Fallback: Falls back to internet time sync when GPS unavailable
- π‘ 24-Hour LED Display: Each LED represents one hour of the day
- π Auto Brightness: Adjusts brightness based on time of day
- π Captive Portal: Easy WiFi setup through mobile device
- π OTA Updates: Update firmware wirelessly
You'll need these components (total cost ~$25-35):
| Component | Quantity | Estimated Price | Notes |
|---|---|---|---|
| ESP32-C3 SuperMini | 1 | $3-5 | Main microcontroller |
| WS2812B LED Ring 24-pixel | 1 | $8-12 | Addressable RGB LEDs |
| NEO-6M GPS Module | 1 | $8-15 | GPS receiver |
| 220Ξ© Resistor | 1 | $1-2 | LED data line protection |
| Breadboard Jumper Wires | 1 set | $3-5 | For connections |
| Mini Breadboard | 1 (optional) | $2-3 | For cleaner wiring |
USB-C
βββββββ
1 β 5V β GND 2
3 β G3 β G10 4
5 β G2 β G1 6
7 β G20 β G21 8
9 β G6 β G7 10
11 β G5 β G4 12
13 β G9 β G8 14
15 β G19 β G18 16
βββββββ
LED Ring β ESP32:
- VCC (5V) β Pin 1 (5V)
- GND β Pin 2 (GND)
- DIN β 220Ξ© resistor β Pin 14 (GPIO8)
GPS Module β ESP32:
- VCC β Pin 1 (5V)
- GND β Pin 2 (GND)
- TX β Pin 7 (GPIO20) - ESP32 RX
- RX β Pin 8 (GPIO21) - ESP32 TX
- Mount the LED ring on your project surface
- Connect power: Wire 5V and GND from ESP32 to both LED ring and GPS
- Connect LED data: LED ring DIN β 220Ξ© resistor β GPIO8
- Connect GPS serial: GPS TXβGPIO20, GPS RXβGPIO21
- Double-check connections before powering on
- Arduino IDE or Arduino CLI
- ESP32 board support package
- Download and install Arduino IDE
- Open Arduino IDE
- Go to File β Preferences
- Add this URL to "Additional Board Manager URLs":
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json - Go to Tools β Board β Boards Manager
- Search for "ESP32" and install "ESP32 by Espressif Systems"
Go to Tools β Manage Libraries and install:
Adafruit NeoPixelby Adafruit
- Download this project (Clone or download ZIP)
- Copy
.env.exampleto.env - Edit
.envwith your WiFi credentials:WIFI_SSID_1="YourWiFiName" WIFI_PASSWORD_1="YourPassword"
- Update the Arduino sketch with your WiFi details (see Configuration section)
Edit the WiFi credentials in sun_clock.ino:
// Update these with your network credentials
WiFiNetwork networks[] = {
{"YOUR_WIFI_SSID_1", "YOUR_PASSWORD_1"},
{"YOUR_WIFI_SSID_2", "YOUR_PASSWORD_2"}, // Optional backup networks
{"YOUR_WIFI_SSID_3", "YOUR_PASSWORD_3"},
{"YOUR_WIFI_SSID_4", "YOUR_PASSWORD_4"}
};If you need to change pins, edit these constants:
#define LED_PIN 8 // GPIO pin for LED ring
#define BRIGHTNESS 100 // LED brightness (0-255)- Connect ESP32 to your computer via USB-C
- Select board: Tools β Board β ESP32C3 Dev Module
- Select port: Tools β Port β (your ESP32 port)
- Open
sun_clock.inoin Arduino IDE - Upload (Ctrl+U or Upload button)
- Board: "ESP32C3 Dev Module"
- Flash Size: "4MB"
- Partition Scheme: "Default 4MB with spiffs"
- Power on - ESP32 will show a startup animation
- GPS search - Yellow spinning dots indicate GPS satellite search
- WiFi connection - Blue pattern during WiFi connection
- Time sync - Green flash when time is synchronized
- Current hour: Bright white LED
- Sunrise arc: Orange/yellow LEDs before and during sunrise
- Daylight: Blue background LEDs during day
- Sunset arc: Orange/red LEDs before and during sunset
- Night: Dim blue/purple LEDs
| Pattern | Meaning |
|---|---|
| Yellow spinning dots | GPS searching for satellites |
| Blue chase | Connecting to WiFi |
| Green flash | Time synchronized successfully |
| Red flash | Error (check serial monitor) |
| White LED | Current hour |
| Colored arcs | Sunrise/sunset times |
- Red flashing on GPS: Normal - searching for satellites
- No GPS fix: Try outdoors or near window, GPS needs clear sky view
- GPS takes long: First fix can take 5-15 minutes, subsequent fixes are faster
- Can't connect: Check SSID and password in code
- No internet: Check router connection
- Captive portal: If WiFi fails, ESP32 creates "SunClock-Setup" network
- No LEDs: Check 5V power connection and 220Ξ© resistor
- Wrong colors: Check LED ring wiring (DIN pin)
- Some LEDs work: Power supply may be insufficient
- Upload failed: Check USB cable and ESP32 connection
- Board not found: Install ESP32 board package
- Compilation errors: Install Adafruit NeoPixel library
Connect at 115200 baud to see debug output:
=== Sun Clock Starting ===
GPS initialized on Serial1 (GPIO20/21)
Searching for WiFi networks...
GPS: Searching for satellites...
- GPS Location: Gets your exact latitude/longitude from satellites
- Sunrise Calculation: Calculates sunrise/sunset times for your location and date
- Time Zones: Automatically determines timezone from GPS coordinates
- LED Mapping: Maps 24 hours to 24 LEDs, with current time as bright white
- Solar Display: Shows sunrise/sunset as colored arcs on the LED ring
- Change colors: Modify sunrise/sunset colors in the code
- Add seasons: Different color schemes for different times of year
- Weather integration: Add weather API for cloud cover
- Multiple timezones: Show time in different zones
- Alarm clock: Add buzzer for sunrise alarm
- Microcontroller: ESP32-C3 (WiFi + Bluetooth)
- GPS Protocol: NMEA (GPRMC sentences)
- LED Protocol: WS2812B addressable RGB
- Time Sync: GPS primary, NTP fallback
- Astronomy: Real sunrise/sunset calculations
- Memory: ~30% flash, ~15% RAM usage
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Adafruit for the excellent NeoPixel library
- ESP32 community for hardware support
- All the makers who will improve this project!
- Issues: Use GitHub Issues for bugs and feature requests
- Discussions: Use GitHub Discussions for questions
- Documentation: Check this README first
Made with β€οΈ for the maker community
Don't forget to star β this repo if you found it useful!