https://github.com/szh/pi-timedlight
A simple Raspberry Pi project to turn on a light during certain times of the day
https://github.com/szh/pi-timedlight
iot pi-zero-w python raspberry-pi
Last synced: about 1 month ago
JSON representation
A simple Raspberry Pi project to turn on a light during certain times of the day
- Host: GitHub
- URL: https://github.com/szh/pi-timedlight
- Owner: szh
- License: gpl-3.0
- Created: 2021-12-23T15:35:22.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-02T15:06:13.000Z (over 4 years ago)
- Last Synced: 2026-03-25T06:53:31.438Z (3 months ago)
- Topics: iot, pi-zero-w, python, raspberry-pi
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pi-timedlight
A simple Raspberry Pi project to turn a LED on and off on a schedule.
Example use case: Put in a toddler's room and set to turn on in the morning and off in the evening.
Toddler can be instructed to go back to bed if they wake up and the light is still off.
Developed for the Pi Zero. Uses 1 LED.
# Installing
On your Pi:
```bash
sudo apt-get update
sudo apt-get install python3-pip python-dev pigpio
sudo pip3 install gpiozero pigpio
nano /etc/rc.local
```
Now add the following text before `exit 0`:
```bash
pigpiod
python3 /home/pi/timedlight.py > /home/pi/log.txt &
```
Run `sudo raspi-config`, go into "Localization Options" and set your timezone.
**Important:** You must make sure that your Pi will sync with a time server on a regular basis.
```bash
sudo timedatectl set-ntp true
sudo nano /etc/systemd/timesyncd.conf
# Uncomment the last two lines:
PollIntervalMinSec=32
PollIntervalMaxSec=2048
# Save the file.
```
Exit and reboot (`sudo reboot`).
Check out comments in the code for configuration options.