Smart Overhead Door Opener (2)
Step 2.1. Program Garage Opener Remote
Follow the directions to program the remote. If the remote has more than one button remember which one was programmed. I programmed the large button.
Step 2.2. Prep the Remote
Take the case off the remote. For mine I slid a small flathead screw driver in the slot between the two halves and twisted the screwdriver and it popped open. Remove the remote PCB from the case (middle picture on left).
My remote has three buttons. None of them are needed. Snip off the three buttons from the remote PCB
Use a voltmeter to determine the positive and negative terminals. For my remote, the battery housing is positive and the negative terminal is under the battery.
Snip off the 3V battery holder. On my remote, I soldered a wire between two positive (+) battery terminals on the battery
Find the push button's pad that has a trace on the PCB board running to the remote's chip (see middle image, where I added the word Trace and some lines in white. One lead from the push button should go to the chip. The pad for the trace needs to be soldered to a GPIO pin.
Solder remote wires as follows:
remote push button: yellow = RPi0 GPIO 23
red = RPi0 3.3V
black = RPi0 ground
Wait until the RPi0 is mounted to attached the Remote's wires to the RPi0
The image on the bottom left is after the battery and buttons have been snipped off and the wires have been soldered on
The soldered wires don't make a strong mechanical connection, so add a drop of hot glue over the wires. Hot glue won't conduct electricity.
Step 2.3. Mount Raspberry Pi 0 (RPi0) and Remote
The plexiglas sheet was prepared in Step 1.16
The Remote is mounted first (image on left).
Insert M2.5 nylon standoffs, screws and nuts to hold the remote PCB in place.
Using M2.5 nuts. screws and hex standoffs, mount the Raspberry Pi to the plexiglas
Slide the plexiglas into the case. Let the camera ribbon cable hang out
The poor image on the bottom left shows three "wings in the yellow box.
Slide the plexiglas with the RPi0 and Remote into the left slot
Ensure everything fits: Put the wall plate with button in place and ensure it is flush with the wall
Attach the Remote's wires to the RPi0 as indicated in the Step above
Step 2.4. Setup Raspberry Pi
In the directions in the link, use the long USB to USB-C for the Power Supply. Use a 5.2V USB wart on the outlet end.
After this step, you will have a Raspberry Pi Zero WH setup with the following:
♣your-ip-address♣
♣hostname♣
♣your-password♣
For this project, I skipped the ssh hardening
Be sure to power off the RPi0 with the command:
$ sudo shutdown -h 0
Step 2.5. Add Camera to RPi0
Camera
If there is a small red protector strip on the Raspberry Pi camera slot, then remove it.
Attach the ribbon cable to the camera and RPi0
Do not Force. Very gently loosen camera connectors, insert the camera's ribbon cable and gently push the connectors back in. The RPi0 will need a smaller connector.
Step 2.6. Open Terminal and Login
Step 2.7. Configure uncomplicated firewall
ufw was setup Run the following commands:
$ sudo ufw status
$ sudo ufw allow from 192.168.1.0/24 to any port 8765
$ sudo ufw allow from 192.168.1.0/24 to any port 80
$ sudo ufw deny 443/tcp
$ sudo ufw deny 80/tcp
$ sudo ufw allow from 192.168.1.0/24 to any port 22
$ sudo ufw allow from 192.168.1.0/24 to any port 7 # allows ping from my LAN
$ sudo ufw status
This configuration allows MotionEye to work within my LAN (192.168.1.0/24) but not from outside of it (i.e., no one on the internet should be able to access your camera)
I had to delete several firewall rules. Run this command to see your firewall rules (mine are shown):
$ sudo ufw status numbered
Status: active
To Action From
-- ------ ----
[ 1] 22/tcp LIMIT IN Anywhere
[ 2] 443/tcp DENY IN Anywhere
[ 3] 80/tcp DENY IN Anywhere
[ 4] Anywhere ALLOW IN 192.168.0.0/24
[ 5] 8765 ALLOW IN 192.168.1.0/24
[ 6] 80 ALLOW IN 192.168.1.0/24
[ 7] 22 ALLOW IN 192.168.1.0/24
[ 9] 7 ALLOW IN 192.168.1.0/24
[10] 22/tcp (v6) LIMIT IN Anywhere (v6)
[11] 443/tcp (v6) DENY IN Anywhere (v6)
[12] 80/tcp (v6) DENY IN Anywhere (v6)
[13] 22 (v6) DENY IN Anywhere (v6)
And then to delete one of the firewall rules in brackets [N], run the command
$ sudo ufw delete N
Until it looks like the above
Note: MotionEye streams video on port 8081, which might need to be allowed on ufw from my LAN
Get the script and run it. The script installs all of the needed packages and python modules.
$ cd ~/.
$ wget https://raw.githubusercontent.com/dumbo25/security-camera/main/motioneye.sh
$ sudo bash motioneye.sh
MotionEye and MotionEye OS are so wonderful that I encourage donations to keep this work going.
MotionEye uses systemd. So, it starts and runs on boot and restarts on failure.
If required, here are the steps that are supposed to update MotionEye to the latest version. I installed motionEye version 4.2.2. So, I have not successfully updated yet. To update run:
$ sudo pip install motioneye --upgrade
$ sudo systemctl restart motioneye
Wait a few minutes for Raspberry Pi to reboot
Open a browser and enter one of the following in the URL box:
http://♣your-ip-address♣:8765/
http://♣hostname♣:8765/
Login with admin and no password
Setup camera
Local MMAL Camera
VideoCore Camera
Note: if the camera above doesn't work, you can add (camera1 drop down) or delete (trash can icon) cameras and try again
Step 2.12. Script and cron to check disk space usage
Videos are only kept for 7 days and only shot when there is motion. However, it is still possible for all the disk space to be used relatively quickly*.
The script checks if a threshold of disk usage is being approached, and it will automatically delete the oldest files.
Get the script
$ wget https://raw.githubusercontent.com/dumbo25/security-camera/main/disk-usage.sh
And a add crontab
$ sudo crontab -e
and add a line at the end:
*/10 * * * * sudo /usr/bin/bash /home/pi/disk-usage.sh >/dev/null 2>&1
Step 2.13. Add Low-Profile push button
I removed the low-profile push button from the wall plate. And previously, I removed the four screws from the push button.
I used three female to female jumper wires. I cut off one female connector from all three wires. The black and blue wires I stripped about 1/8 inch. the red wire was stripped about 3/4 inch. I soldered the wires as shown in the diagram.
The wires connect to the Raspberry Pi as follows:
blue = GPIO 25
red = GPIO 5V
black = GPIO ground
Step 2.14. Connect Raspberry Pi to Sensor Wires
In Step 1.11, pins were attached to the sensor wire. Now, the sensor wires are attached to the Raspberry Pi Zero (RPi0)
I used physical pin 17 for 3.3V and GPIO 15. Attach either wire to either pin. If it doesn't work flip the pins around.
Note: It was not clear to me on the SECO-LARM, which was ground and which was Vcc.
Get a test script on the Raspberry Pi, run the commands:
$ cd /usr/local/bin
$ sudo wget https://raw.githubusercontent.com/dumbo25/garage-door/main/usr/local/bin/state.py
$ sudo chmod +x state.py
$ cd ~/. # return to /home/pi
The garage door should be fully opened or closed before running the script
$ python /usr/local/bin/state.py
If the script returns open, when the door is opened or closed, then switch the sensor wires (GPIO 3.3V and GPIO 15)
*** STOPPED HERE ***
Use Arial instead of Lato font
Step 2.15. Mount Camera to Wall Plate
The camera has 9x16 field of view. The image on the left shows the wrong way to mount the camera. The ribbon cable of the camera should not be mounted towards the side of the wall plate. The ribbon cable should be parallel with the long side of the wall plate.
My doorbell button is very close to one side of my garage. I need a 30 degree angle so the whole garage door opening is captured by the camera.
At the same time, the camera must be perfectly horizontally and pointing through the hole.
The best way to do this is use some blue tac to hold the camera in place, while watching the video stream. Once it is all correct, add the hot glue. Try not to hold it in place.