https://github.com/dondfx/automated-light-controller
🔆 Smart light controller with state recovery after power outage.
https://github.com/dondfx/automated-light-controller
arduino automatic-control embedded platformio vscode
Last synced: 8 months ago
JSON representation
🔆 Smart light controller with state recovery after power outage.
- Host: GitHub
- URL: https://github.com/dondfx/automated-light-controller
- Owner: dondfx
- License: mit
- Created: 2025-08-31T16:42:23.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-08-31T17:37:43.000Z (8 months ago)
- Last Synced: 2025-08-31T18:32:21.644Z (8 months ago)
- Topics: arduino, automatic-control, embedded, platformio, vscode
- Language: C
- Homepage:
- Size: 1.28 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🔆 Automated Light Controller
[](https://github.com/dondfx/automated-light-controller/actions/workflows/platformio.yml)
A power-resilient embedded light controller with RTC-based scheduling and intelligent state restoration.
---
## 📘 Overview
This project is an AVR-based automated light controller designed to toggle lighting circuits (such as gate or outdoor lights) based on real-time clock (RTC) schedules. It ensures lights are switched ON/OFF at user-defined times and intelligently recovers their state after power failures using EEPROM storage.
It also supports manual override via a physical button, with safety debounce and interrupt delay logic.
---
## ✅ Features
- ⏰ **RTC-Based Scheduling**
Turns lights ON and OFF based on pre-programmed ON/OFF times.
- 💾 **EEPROM State Retention**
Recovers last known state across power outages, ensuring consistent behavior.
- 💡 **Manual Override**
Allows toggling light manually via a push-button (INT1 external interrupt).
- 🔄 **Graceful Recovery**
If the light was manually turned OFF before an outage, it stays OFF upon power restoration — even if the RTC schedule says otherwise.
- ✨ **PWM LED Indicator**
Fading red LED provides visual feedback or heartbeat during idle state.
- 🔌 **Fully Modular AVR Codebase**
Professionally split `.h`/`.c` structure for portability and readability.
---
## 🧠 How It Works
1. **RTC Module** tracks real-time and triggers two alarms:
- Light ON time
- Light OFF time
2. **EEPROM** stores the latest manual or automated ON/OFF event with a timestamp.
3. **Upon boot**, the system:
- Initializes timers, RTC, and interrupts.
- Reads the last known state from EEPROM.
- Compares stored timestamp with current time.
- Sets light state accordingly.
4. **Manual button press** toggles the light and temporarily disables further interrupts (with a re-enable delay via timer logic).
---
## ⚙️ Hardware Requirements
- **Microcontroller**: ATmega328P
- **RTC Module**: DS3231
- **LED/PWM Driver**: For visual indicators
- **Push Button**: Connected to INT1 (PD3)
- **Relay/Triac**: For switching the actual light/load
- **EEPROM**: Internal to ATmega328P
---
## 📂 Project Structure
```
automated-light-controller/
├── assets/ # Device preview
├── include/ # All header files
├── src/ # Source (.c) files
├── platformio.ini # PlatformIO project config
├── README.md # This file
└── LICENSE # MIT License
```
---
## 🛠️ Build & Flash
This project uses [PlatformIO](https://platformio.org/).
```bash
# Install dependencies
platformio init --board ATmega328P
# Build the project
platformio run
# Upload to device
platformio run --target upload
Or open in VSCode + PlatformIO IDE and press ▶️ Build & Upload.
```
## 🔧 **Configuration**
- EEPROM-backed logic remembers manual overrides across power failures.
- Easily updated through serial/I2C in future versions.
## 📸 Screenshots
🪪 License: MIT © Lakmal Weerasinghe