Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Raspberry Pi Garage Door Opener with Live Video Streaming – Step‑by‑Step Guide

This guide extends two foundational projects – the Raspberry Pi Garage Door Opener and the PiMyLifeUp Raspberry Pi Webcam Server. It adds a magnetic door‑status sensor and displays the live video feed directly on the control page.

Step 1: Complete the Prerequisite Instructables

Before proceeding, follow the instructions in the two referenced projects. This ensures your Pi is configured with a GPIO‑controlled relay and a webcam streaming server.

Step 2: Update the Web Page Style

Edit the stylesheet located at /var/www/css/style.css:

nano /var/www/css/style.css

Replace its contents with the snippet below, substituting YOUR_PI_IP with your Raspberry Pi’s local address:

html, body {
    margin: 0;
    padding: 0;
    background: #263238;
    background-image: url("https://YOUR_PI_IP:8081/videostream.cgi");
    background-size: 980px 735px;
    background-repeat: no-repeat;
    text-align: left;
}
div.awrap {
    position: fixed;
    height: 150px;
    left: 110px;
    top: 792px;
    width: 760px;
    text-align: left;
}
a {
    display: inline-block;
    border-radius: 15px;
    border: 2px solid #263238;
    width: 760px;
    height: 150px;
    background: #B5B1B1;
    box-shadow: inset 0 0 10px #000;
    -webkit-tap-highlight-color: rgba(255,255,255,0);
}
a:active {
    background: #263238;
    box-shadow: inset 0 0 50px #000;
}

Step 3: Modify the Index Page

Adjust /var/www/index.php to include the button that triggers the garage relay. (Insert your own PHP logic here.)

Step 4: Create the Relay Service Script

Create /etc/init.d/garagerelay with the following content:

#!/bin/bash
# /etc/init.d/garagerelay – Control the garage door relay

case "$1" in
    start)
        echo "Starting Relay"
        # GPIO 0 drives the relay; 1 = off
        /usr/local/bin/gpio write 0 1
        /usr/local/bin/gpio mode 0 out
        # GPIO 2 (BCM 27) reads the magnetic sensor with pull‑up
        /usr/local/bin/gpio mode 2 in
        /usr/local/bin/gpio mode 2 up
        ;;
    stop)
        echo "Stopping GPIO"
        ;;
    *)
        echo "Usage: /etc/init.d/garagerelay {start|stop}"
        exit 1
        ;;
esac
exit 0

Make the script executable and register it to start at boot:

sudo chmod 755 /etc/init.d/garagerelay
sudo update-rc.d garagerelay defaults

Step 5: Configure Motion to Start at Boot

Set up the Motion service:

sudo nano /etc/init.d/cam_motion

Insert the following:

#!/bin/sh
# /etc/init.d/cam_motion – Start Motion for the Pi camera

case "$1" in
    start)
        echo "Starting Camera Motion"
        nohup /home/pi/mmal/motion -n -c /home/pi/mmal/motion-mmalcam.conf &>/dev/null &
        ;;
    stop)
        echo "Stopping Camera Motion"
        killall motion
        ;;
    *)
        echo "Usage: /etc/init.d/cam_motion {start|stop}"
        exit 1
        ;;
esac
exit 0

Make the script executable and enable it at boot:

sudo chmod 755 /etc/init.d/cam_motion
sudo update-rc.d cam_motion defaults
sudo reboot

Final Notes

After reboot, your Pi will stream live video from the camera, overlay the door status, and expose a single button that toggles the garage relay. For deeper troubleshooting, consult the documentation of the original opener and the webcam server guide.

Manufacturing process

  1. How to Read Temperature with a DS18B20 on Raspberry Pi 2
  2. Measuring Temperature on Raspberry Pi with Maxim 1‑Wire Sensors and DS2482 I2C Bridge
  3. Accurate Temperature Monitoring in a Server Closet with Raspberry Pi
  4. Lightning Detection with Raspberry Pi and AS3935: A Practical Guide
  5. Build a Raspberry Pi Webcam Robot – Step‑by‑Step Video Streaming Guide
  6. Build a Self‑Balancing Segway with Raspberry Pi
  7. gatoBot: Raspberry Pi Zero W Web‑Controlled Robot with Live Video Streaming
  8. Enable Phone Calls on Arduino UNO Using Twilio & Yaler – Call My Arduino Project
  9. Build a Sleek Nixie Tube Clock in a Custom MDF Wood Enclosure Using Arduino
  10. C64 Retro Controller: Arduino Nano Interface