First we need to listen for interactions with the button plugged on GPIO port 17
. Then, when the button has a HIGH
value (represented as a binary 1
), we invoke raspistill
via the pi-camera-connect
module to take a picture, store it locally and upload to Cloudinary. With that done, a message is sent to a private Discord channel through a Webhook that will show who's at the door.
Here's how its arranged:
The parts list is:
- Raspberry Pi Zero W
- Pi Camera Module
- 1K resistor
- Push button
- Some wires
- Breadboard
- NodeJS 14, with the following modules:
- onoff: GPIO interaction
- pi-camera-connect:
raspistill
andraspivid
wrapper written in Typescript - cloudinary: easy image upload to the cloud
- pino: low overhead logger
- node-fetch: HTTP requests with Fetch API, used to send POST requests to Discord webhook
- dotenv: store sensitive credentials on environment variables
It is expected that your Pi is already configured with Raspberry Pi OS (or any other compatible Linux distro) and has SSH and Camera enabled.
Also, the deploy script will connect to the Pi using the address pizero.local
and user pi
, so make sure it's properly mapped on your machine's hosts
file (or on your router). In case you want to use any other address, just edit the script and be happy :)
To deploy the code, do the following:
# 1. Upload the code with rsync:
$ ./scripts/deploy.sh
# 2. SSH into your Pi
$ ssh pi@pizero.local
# 3. Navigate to project directory
$ cd ~/dev/rpi-smart-doorbell
# 4. Install dependencies
$ npm install
# 5. Run program on background, sending logs to a file
$ npm start &>> /tmp/doorbell.log &
# 6. (OPTIONAL) Watch the logs with Tail:
$ tail -f /tmp/doorbell.log
WIP