From Hover to SecureLogin: My Raspberry Pi Automation Journey
By Mayank Deshpande ·

Why I Started Automating
Living in silence just got too boring. My Raspberry Pi was gathering dust, so I decided to put it to good use. What started as a simple radio-on-hover project soon spiraled into a series of automations that made my daily life more efficient, fun, and a little bit magical. Each project taught me something new—about hardware, software, and even myself.
The foundational steps—like turning on my PC with a wave or getting a room snapshot from thousands of kilometers away—eventually led to my proudest creation: SecureLogin, a full-stack authentication and monitoring solution. Here's how it all came together.
Project Highlights & Anecdotes
Automatic Radio Based on Hover
Using Python and playerctl, I set up my Raspberry Pi to play Third Rock Radio whenever I hovered my feet below an ultrasonic sensor. The app never closed, so the radio was always just a wave away—instantly energizing my room.
PC Power Control & Room Snapshot
My workspace is tight, and the PC power button is hard to reach. With Wake-on-LAN and an ultrasonic sensor, I could turn on my PC with a simple hover—or even from thousands of kilometers away via SSH. The first time my PC powered up remotely, I was mesmerized. Later, I added a Pi camera and a frontend app to take room snapshots and email them to myself for peace of mind.

SecureLogin: The Next Level
A Modern, Full-Stack Solution
SecureLogin is a robust authentication and monitoring app built with React (TypeScript), Vite, Tailwind CSS, Shadcn/UI, and a Python backend running on my Raspberry Pi. It features secure email-based login, room surveys, live camera integration, and a responsive, mobile-friendly UI.


- Secure login with email verification
- Room survey modals and data storage
- Live camera feed and snapshot functionality
- Central dashboard for activity and status
- Mobile-friendly, modern design
- Notifications and real-time feedback
Building SecureLogin was a blast—from Figma UI design to Python backend coding, and integrating AI tools for prompt engineering. It's my brainchild, but it stands on the shoulders of all my earlier Pi projects.
Code Highlight: Ultrasonic Sensor + Wake-on-LAN
Here's the Python code that made the magic happen—triggering my PC to power on with a simple hover. (Click to expand!)
Show Python Code
import RPi.GPIO as GPIO
import time
import subprocess
# --- Configuration ---
TRIG_PIN = 23
ECHO_PIN = 24
PC_MAC_ADDRESS = "d8:bb:c1:0f:89:f3" # Replace with your PC's MAC address
WAKE_INTERFACE = "eth0" # Network interface on Pi for WoL, usually eth0 or wlan0
DETECTION_DISTANCE_CM = 30 # Trigger if hand is closer than this (in cm)
COOLDOWN_PERIOD_S = 10 # Seconds to wait after sending a WoL packet
# --- GPIO Setup ---
GPIO.setmode(GPIO.BCM) # Use Broadcom pin numbering
GPIO.setwarnings(False)
GPIO.setup(TRIG_PIN, GPIO.OUT)
GPIO.setup(ECHO_PIN, GPIO.IN)
def measure_distance():
"""Measures distance using the HC-SR04 sensor with corrected timeouts."""
# Send a 10us pulse to TRIG
GPIO.output(TRIG_PIN, True)
time.sleep(0.00001)
GPIO.output(TRIG_PIN, False)
timeout_start_time = time.time()
# --- Loop 1: Wait for the echo pulse to start (ECHO goes HIGH) ---
while GPIO.input(ECHO_PIN) == 0:
pulse_start_time = time.time()
if pulse_start_time - timeout_start_time > 0.1:
return float('inf')
# --- Loop 2: Wait for the echo pulse to end (ECHO goes LOW) ---
while GPIO.input(ECHO_PIN) == 1:
pulse_end_time = time.time()
if pulse_end_time - pulse_start_time > 0.1:
return float('inf')
pulse_duration = pulse_end_time - pulse_start_time
distance = (pulse_duration * 34300) / 2
return distance
def send_magic_packet():
try:
print(f"Sending WoL packet to {PC_MAC_ADDRESS} via {WAKE_INTERFACE}...")
subprocess.run(["sudo", "etherwake", "-i", WAKE_INTERFACE, PC_MAC_ADDRESS], check=True)
print("WoL packet sent.")
return True
except subprocess.CalledProcessError as e:
print(f"Error sending WoL packet: {e}")
return False
except FileNotFoundError:
print("Error: 'etherwake' command not found.")
return False
print("Ultrasonic Wake-on-LAN script started.")
print(f"Monitoring for objects closer than {DETECTION_DISTANCE_CM} cm.")
try:
last_wake_time = 0
while True:
dist = measure_distance()
print(f"Measured Distance = {dist:.1f} cm")
if dist < DETECTION_DISTANCE_CM:
current_time = time.time()
if (current_time - last_wake_time) > COOLDOWN_PERIOD_S:
print("Object detected close!")
if send_magic_packet():
last_wake_time = current_time
print(f"Cooldown active. Waiting {COOLDOWN_PERIOD_S} seconds.")
else:
print("Object detected, but in cooldown period.")
time.sleep(0.5)
except KeyboardInterrupt:
print("Measurement stopped by User")
finally:
GPIO.cleanup()
Poke the Pins: The Circuit, Simulated
That script you just scrolled past is wired to real pins — GPIO23 firing the trigger, GPIO24 listening for the echo. Here's the same circuit as a toy: wave your "hand" closer than 30 cm and watch the Pi wake the PC, cooldown and all. No breadboards were melted in this simulation.
How These Projects Changed My Life
These automations made my life easier and more enjoyable. I could control my PC and music with a wave, save energy, and even check on my room from anywhere. The sense of empowerment and fun was real—especially when I realized I was actually producing value and improving my quality of life.
Learning to use AI tools efficiently is an art. As a fullstack engineer, diving into controller programming and hardware was a fascinating new world. There were mishaps (like a melted breadboard!), but every challenge was a lesson.
Tips for Getting Started
- Look for small gaps in your daily life—start automating from there.
- Don't be afraid to experiment and make mistakes (just double-check your wiring!).
- Use resources like GitHub, YouTube, and forums for inspiration and troubleshooting.
- Start with simple projects and build up your skills and confidence.
- Most importantly, have fun and enjoy the process of creating value for yourself!
What's Next?
I'm planning to integrate lights-on-hover next! For now, I use a button to turn on the PC and an old phone with Google Assistant for radio, but the hover sensor will soon control my lights—after my GMAT break, of course.