{"id":30891161,"url":"https://github.com/dondfx/automated-light-controller","last_synced_at":"2025-09-08T18:04:09.844Z","repository":{"id":312584179,"uuid":"1047976130","full_name":"dondfx/automated-light-controller","owner":"dondfx","description":"🔆 Smart light controller with state recovery after power outage.","archived":false,"fork":false,"pushed_at":"2025-08-31T17:37:43.000Z","size":1342,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-31T18:32:21.644Z","etag":null,"topics":["arduino","automatic-control","embedded","platformio","vscode"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dondfx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-31T16:42:23.000Z","updated_at":"2025-08-31T17:40:00.000Z","dependencies_parsed_at":"2025-08-31T18:32:25.076Z","dependency_job_id":"d1a6d426-6028-4a3f-8a81-1b74e41c804b","html_url":"https://github.com/dondfx/automated-light-controller","commit_stats":null,"previous_names":["dondfx/automated-light-controller"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dondfx/automated-light-controller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dondfx%2Fautomated-light-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dondfx%2Fautomated-light-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dondfx%2Fautomated-light-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dondfx%2Fautomated-light-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dondfx","download_url":"https://codeload.github.com/dondfx/automated-light-controller/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dondfx%2Fautomated-light-controller/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274225611,"owners_count":25244544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","automatic-control","embedded","platformio","vscode"],"created_at":"2025-09-08T18:03:28.342Z","updated_at":"2025-09-08T18:04:09.836Z","avatar_url":"https://github.com/dondfx.png","language":"C","readme":"# 🔆 Automated Light Controller\n\n[![PlatformIO CI](https://github.com/dondfx/automated-light-controller/actions/workflows/platformio.yml/badge.svg)](https://github.com/dondfx/automated-light-controller/actions/workflows/platformio.yml)\n\nA power-resilient embedded light controller with RTC-based scheduling and intelligent state restoration.\n\n---\n\n## 📘 Overview\n\nThis 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.\n\nIt also supports manual override via a physical button, with safety debounce and interrupt delay logic.\n\n---\n\n## ✅ Features\n\n- ⏰ **RTC-Based Scheduling**  \n  Turns lights ON and OFF based on pre-programmed ON/OFF times.\n\n- 💾 **EEPROM State Retention**  \n  Recovers last known state across power outages, ensuring consistent behavior.\n\n- 💡 **Manual Override**  \n  Allows toggling light manually via a push-button (INT1 external interrupt).\n\n- 🔄 **Graceful Recovery**  \n  If the light was manually turned OFF before an outage, it stays OFF upon power restoration — even if the RTC schedule says otherwise.\n\n- ✨ **PWM LED Indicator**  \n  Fading red LED provides visual feedback or heartbeat during idle state.\n\n- 🔌 **Fully Modular AVR Codebase**  \n  Professionally split `.h`/`.c` structure for portability and readability.\n\n---\n\n## 🧠 How It Works\n\n1. **RTC Module** tracks real-time and triggers two alarms:  \n   - Light ON time  \n   - Light OFF time  \n\n2. **EEPROM** stores the latest manual or automated ON/OFF event with a timestamp.\n\n3. **Upon boot**, the system:\n   - Initializes timers, RTC, and interrupts.\n   - Reads the last known state from EEPROM.\n   - Compares stored timestamp with current time.\n   - Sets light state accordingly.\n\n4. **Manual button press** toggles the light and temporarily disables further interrupts (with a re-enable delay via timer logic).\n\n---\n\n## ⚙️ Hardware Requirements\n\n- **Microcontroller**: ATmega328P  \n- **RTC Module**: DS3231  \n- **LED/PWM Driver**: For visual indicators\n- **Push Button**: Connected to INT1 (PD3)  \n- **Relay/Triac**: For switching the actual light/load  \n- **EEPROM**: Internal to ATmega328P\n\n---\n\n## 📂 Project Structure\n\n```\nautomated-light-controller/\n├── assets/ # Device preview\n├── include/ # All header files\n├── src/ # Source (.c) files\n├── platformio.ini # PlatformIO project config\n├── README.md # This file\n└── LICENSE # MIT License\n```\n\n---\n\n## 🛠️ Build \u0026 Flash\n\nThis project uses [PlatformIO](https://platformio.org/).\n\n```bash\n# Install dependencies\nplatformio init --board ATmega328P\n\n# Build the project\nplatformio run\n\n# Upload to device\nplatformio run --target upload\n\nOr open in VSCode + PlatformIO IDE and press ▶️ Build \u0026 Upload.\n```\n\n## 🔧 **Configuration**\n\n  - EEPROM-backed logic remembers manual overrides across power failures.\n  - Easily updated through serial/I2C in future versions.\n\n## 📸 Screenshots\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/device_preview.png\" alt=\"Device Preview\" width=\"500\"/\u003e\n\u003c/p\u003e\n\n🪪 License: MIT © Lakmal Weerasinghe","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdondfx%2Fautomated-light-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdondfx%2Fautomated-light-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdondfx%2Fautomated-light-controller/lists"}