This repository contains two main Python scripts for Raspberry Pi automation:
room_snapshots.py: Take a snapshot with the Pi camera and email it.ultrasonic_wol.py: Use an ultrasonic sensor to trigger Wake-on-LAN for a PC.
Purpose:
Captures a photo using the Raspberry Pi camera and sends it via email as an attachment.
Features:
- Uses the
picamera2library for image capture. - Rotates the image 180° after capture.
- Sends the image as an email attachment using Gmail SMTP.
- Can also send log files by email (see code comments).
Setup:
- Install dependencies:
pip install pillow sudo apt install python3-picamera2
- Set your Gmail app password in the environment:
export EMAIL_PASSWORD='your_app_password'
- Edit the sender and receiver emails in the script if needed.
Usage:
python3 room_snapshots.pyBy default, this will take a snapshot and email it.
Purpose:
Uses an HC-SR04 ultrasonic sensor to detect proximity and send a Wake-on-LAN (WoL) magic packet to wake up a PC.
Features:
- Measures distance using GPIO pins.
- Sends a WoL packet using
etherwakewhen an object is detected within a set distance. - Includes a cooldown period to avoid repeated triggers.
Setup:
- Connect the HC-SR04 sensor to your Raspberry Pi (TRIG: GPIO 23, ECHO: GPIO 24 by default).
- Install
etherwake:sudo apt-get install etherwake
- Edit the MAC address and network interface in the script as needed.
Usage:
sudo python3 ultrasonic_wol.pyRequires sudo for GPIO and WoL packet sending.
- Both scripts are intended for use on a Raspberry Pi.
- Make sure to enable the camera interface and I2C/SPI as needed via
raspi-config. - For email functionality, you may need to use an app password if your Gmail account has 2FA enabled.