Discord Security Camera With an ESP32
Introduction: Discord Security Camera With an ESP32
Use an ESP32 Cam and a passive infrared (PIR) sensor to create a motion-activated security camera that will post a photo to a Discord channel, where you have access to create a webhook.
We'll build out the test circuit, using a breadboard and jump wire. We'll then build a wiring harness using Dupont connectors to allow for easy connections to the development board and PIR sensor.
We'll then use our choice of a wall or ceiling-mounted 3D printed case to contain our parts and our camera.
The ceiling-mounted camera makes use of an inexpensive decoy camera that can be purchased online.
Supplies
* Breadboard
* Jump Wire
* Arduino Nano
* External Wireless Antenna
* 5.5 x 2.1 mm DC power jack
* ESP32 Cam
* Passive Infrared (PIR) Sensor
* 5v Power Supply
* Extra wire
* Dupont connect kit and crimper
* Dummy Camera
Step 1: Programming the ESP32 Cam With an Arduino
Set the ESP32Cam into flash mode and wire it to an Arduino, to allow for programming of the ESP32.
For this step, we'll need the ESP32Cam, an Arduino Nano, and jump wires.
Make sure the ESP32 Board Manager URL has been added to your preferences:
* https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Use the diagram above as a reference when wiring with your breadboard.
Step 2: Connect the PIR Sensor to the ESP32 Cam
Connect the passive infrared (PIR) sensor to the ESP32 Cam. For the initial setup, you'll want to connect to the PIR sensor to 5V, Ground, and the center data pin to GPIO 15 on the ESP32 cam as seen in the wiring diagram.
Step 3: Download the Code and Dependencies
The source code for the project can be found on Github:
* Discord Spycam: https://github.com/WillMakesTV/discord-spycam
Additionally, we'll need to use the CertToESP8266 Python script from the HTTPS for Makers project.
And since we're using a Python script, we'll also need to make sure that Python is installed.
Step 4: Create a SSL Certificate for Discord.com
Once you have verified that Python has been installed, download the HTTPS for Makers from Github and extract it to a folder on your computer.
To generate an SSL certificate, we’ll need to visit Discord.com.
From the address bar, next to the domain name, click the Lock and then select “Certificate”.
1. 977
Select the Details tab, then select “Copy to File” to open the export wizard.
2. Click Next, then select the Base64 Encoded option.
3. On the next step, select the extracted folder of the HTTPS for Makers download and save it as "discord-cert.cer".
If everything worked as expected, then you should see a message that the export was successful.
Step 5: Use CerttoESP32 to Format SSL Certificate
Now we’ll want to edit the CerttoESP32 Python script found in the HTTPS for Makers project that we downloaded; to update the filename variable to the one we exported from Discord.com.
Once we’ve saved the script, using the command prompt or terminal, change directories to the HTTPS for Makers project and run the CerttoESP32 script.
This will format our certificate in a way that we can use with the ESP32.
Using the Command Prompt on Windows or a terminal on macOS/Linux, change to the directory where the CerttoESP32 script is located and run the script.
If everything worked as expected, you should see the output in the command prompt or terminal with a formatted SSL certificate.
Step 6: Configure the Discord Spycam Project
Extract the Discord Spycam project downloaded from Github. Note that you may be prompted to rename the project directory to "discord-spycam" if downloaded via a zip file from Github, so changing the directory name initially is recommended.
Copy arduino_secrets.h.example to arduino_secrets.h within the project directory and open discord-spycam.ino.
In the arduino_secrets.h file, update the SECRET_DISCORD_CERT variable to match the output in the command prompt/terminal from running the CertToESP8266.py script. 977