/room_projects

Using my raspi for something productive

Primary LanguagePythonMIT LicenseMIT

Room Projects

This repository contains two main Python scripts for Raspberry Pi automation:


Purpose:
Captures a photo using the Raspberry Pi camera and sends it via email as an attachment.

Features:

  • Uses the picamera2 library 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:

  1. Install dependencies:
    pip install pillow
    sudo apt install python3-picamera2
  2. Set your Gmail app password in the environment:
    export EMAIL_PASSWORD='your_app_password'
  3. Edit the sender and receiver emails in the script if needed.

Usage:

python3 room_snapshots.py

By 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 etherwake when an object is detected within a set distance.
  • Includes a cooldown period to avoid repeated triggers.

Setup:

  1. Connect the HC-SR04 sensor to your Raspberry Pi (TRIG: GPIO 23, ECHO: GPIO 24 by default).
  2. Install etherwake:
    sudo apt-get install etherwake
  3. Edit the MAC address and network interface in the script as needed.

Usage:

sudo python3 ultrasonic_wol.py

Requires sudo for GPIO and WoL packet sending.


Notes

  • 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.