This project utilizes Raspberry Pi for processing and Pi Camera to detect motion. Upon detecting motion, it sends a notification to the user via ntfy.sh. If the user is not on the same network as the Raspberry Pi, notifications are sent over a VPN using a WireGuard tunnel. Both ntfy and WireGuard run within their own separate Docker containers, and everything runs locally.
Go to file
Kshitij a43b2ac81a
Made several changes to README file.
- Changed project name to PiDetectify
- Updated description
- Added note in description about the project
- Changed git clone link
- Changed current working directory name
- Consistent line spacing
- Added horizontal line at the end
2024-11-19 23:22:15 +05:30
Archive Gave execution perms to setup.sh and moved old motion_detection.py to Archive 2024-10-19 21:04:05 +05:30
ABOUT.md Added description for projct. 2024-10-19 21:53:02 +05:30
crd.txt Removed last credits from docker-setup and added most imp part in setup.sh lol 2024-10-19 21:15:07 +05:30
docker-compose.yaml Added wireguard tunnel config in docker-compose and removed docker compose up from setup.sh 2024-10-19 20:59:40 +05:30
docker-setup.sh Removed last credits from docker-setup and added most imp part in setup.sh lol 2024-10-19 21:15:07 +05:30
LINKS.md Added links for generating hash and repo link in links.md 2024-10-19 21:19:36 +05:30
main.py fixed rpi-ip variable. 2024-10-19 21:44:29 +05:30
README.md Made several changes to README file. 2024-11-19 23:22:15 +05:30
setup.sh Removed last credits from docker-setup and added most imp part in setup.sh lol 2024-10-19 21:15:07 +05:30

PiDetectify

This project utilizes Raspberry Pi for processing and Pi Camera to detect motion. Upon detecting motion, it sends a notification to the user via ntfy.sh. If the user is not on the same network as the Raspberry Pi, notifications are sent over a VPN using a WireGuard tunnel. Both ntfy and WireGuard run within their own separate Docker containers, and everything runs locally.

Note

I created this for my college project. I do not plan on adding more features to it. If you encounter any bugs, feel free to create an issue (I am more active on KSKA Git than GitHub.)


Prerequisites:

  1. Raspberry Pi (only tested on 3B+, should work on 2/4/5 as well)
  2. Pi Camera
  3. Internet connection
  4. Raspberry Pi OS 64-bit

Important

USE 64-BIT OS FOR FASTER PROCESSING.

Steps to setup

  1. Clone this repository:
git clone https://git.kska.io/notkshitij/PiDetectify.git
  1. Change current working directory:
cd ./PiDetectify
  1. Run setup.sh:
./setup.sh
  1. Setup firewall on Raspberry Pi:
sudo apt install -y ufw
sudo ufw default allow outgoing
sudo ufw default deny incoming
sudo ufw allow 22 # for ssh
sudo ufw allow 80 # for ntfy
sudo ufw allow 51821/tcp # wireguard tcp
sudo ufw allow 51820/udp # wireguard udp
sudo ufw status numbered
sudo ufw enable
sudo systemctl start ufw
sudo systemctl enable ufw
  1. Setup Wireguard:

    • Generate bcrypt password hash by running:
    docker run -it ghcr.io/wg-easy/wg-easy wgpw '<PASSWORD_HERE>'
    

    This will return a PASSWORD_HASH. For addition information, checkout their guide.

    • Create a file in the current directory called .env

    • Add the following values in .env file:

    PASS='<PASSWORD_HASH generated here>'
    IP=<PUBLIC IP>
    
    # Inside single quotations, paste the password hash for PASS variable
    # Get your public IP by using something like http://ip.me, and paste your public IP there
    
  2. Create and run the containers:

docker compose up -d
  1. Check if ntfy.sh and wireguard tunnel is setup correctly:

    • Visit <RASPBERRYPI-IP>:80 from a browser. Make sure Raspberry Pi and the other device are on the same network. On Raspberry Pi, you can visit localhost:8080

    • If you see a dashboard, it implies Docker and ntfy.sh were setup correctly.

    • Visit <RASPBERRYPI-IP>:51821, enter the password which you specified in the beginning (NOT the password hash, the password).

    • Add new clients to remotely connect and receive notifications.

  2. In ntfy.sh dashboard, in the left menu at the bottom, click on Subscribe to topic, and specify the topic name: motion-sensing

  3. Lastly, run the main.py file to view motion detection window on screen and send notifications on detecting motion:

python3 main.py

Note

Make sure you're in the directory where you cloned this repo while running all these commands.