From 5f9731b8e8b8c5905b0f30ec964294755f1704ff Mon Sep 17 00:00:00 2001 From: Kshitij Date: Sat, 19 Oct 2024 21:00:53 +0530 Subject: [PATCH] Added some instructions and made improvements to them. --- README.md | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b506ff..8785375 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,80 @@ -IoT Mini Project - 2024 +# IoT Mini Project - 2024 + +This mini project uses picamera to detect motion, upon detecting motion, it sends notification to devices subscribed to the channel using ntfy.sh --- + +## 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: +```shell +git clone https://git.kska.io/notkshitij/iot-mini.git +``` + +2. Change current working directory: +```shell +cd ./iot-mini +``` + +3. Run `setup.sh`: +```shell +./setup.sh +``` + + +4. Setup firewall on Raspberry Pi: +```shell +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 +``` + +5. Setup Wireguard: + - Generate bcrypt password hash by running: + ```shell + docker run -it ghcr.io/wg-easy/wg-easy wgpw + ``` + + This will return a `PASSWORD_HASH` + + - Create a file in the current directory called `.env` + + - Add the following values in `.env` file: + ```env + PASS='' + 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 + ``` + +8. Create and run the containers: +```shell +docker compose up -d +``` + +9. Check if ntfy.sh is setup correctly: + - Visit `: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. + +10. In ntfy.sh dashboard, in the left menu at the bottom, click on `Subscribe to topic`, and specify the topic name: `motion-sensing` + +> [!NOTE] +> Make sure you're in the directory where you cloned this repo while running all these commands.