Spy Camera (Video, Audio & Network Stream) With ESP32-Cam
2023-03-13 | By M5Stack
License: General Public License Bluetooth / BLE Wifi Arduino
* Thanks for the source code and project information provided by @M. Mahdi K. Kanan
This project is an “ESP32 WiFi Camera Microphone (Spy Camera)”. Arduino source code (.ino) with Chain Network feature is based on the “ESP32 WebApp Builder” project. The “Chain Network” is a local network in which the devices one by one are connected to each other.
The Spy Camera project uses the “AI Thinker ESP32-CAM” module which has a 2MP Camera, 10 I/O pins, an on-board chip LED and one MicroSD slot to store the images and videos. With its tiny sized camera and 240MHz CPU, it is able to provide a fair quality images and video frames and also a network online stream.
You can either use a “Sound Sensor” (or similar) or the suggested circuit as the audio input.
The ADC input (for the audio circuit) is GPIO 33 which is originally connected to the red on-board LED.
This project contains three folders ESP32CamMicProgram (the Arduino source code) and PCB-SCH-BOM.
The project is available in the following links:
SpyCam Project (Video&Audio Recorder) Source Code, PCB and Schematic Plans (ESP32-Cam) – Rev 1.3
Arduino ESP32-CAM CCTV, WiFi IP Camera Source Code – Rev 1.3
Uploading the spy camera project
First open one of the files with Arduino program, then set the settings as the following image (Board and Flash Frequency).
- The “Board” must be set on one of the ESP32 Modules before doing anything.
- The start-up CPU speed has been set to 160MHz.
- For the “download mode”, use a jumper for connecting “IO 0” to the GND.
Then turn on the ESP32 module in the “download mode” (GPIO0 connected to GND) and upload the program with using an USB2Serial module.
ESP32 Spy Camera PCB
The PCB files are in the PCB-SCH-BOM folder:
The Chain Network
The “Chain Network” is a local network which the devices one by one are connected to each other (Series). In the chain network, the first device is the master of the network. The starter (either the master or the last joined module) is directly connected to the WebApp. It sends the command to the next device, and the next device sends it to the next one till the last device. The last device response will be sent to the first device and finally to the WebApp via the middle devices.
You can join up to 8 cameras, either with “ESP32 Spy Camera” firmware (Audio and Video recorder) rev 1.3 or “ESP32 IPCam” firmware (which does not have the audio record feature) rev 1.3 in a chain network and see the online stream of the Cameras.
- In the current revision, the online stream is available for only 2 devices in the network, but the file access is available for all the devices.
The ESP32 Spy Camera Web Application
Plug the power and turn on the circuit and the module in “normal mode”.
Then the LED will blink once (in case of everything is ok). Then you’ll be able to see the module’s hot spot SSID via the WiFi networks with your PC or smart phone.
The default SSID is WiCardCamMic and the default password is 12345678. Connect and go to 192.168.4.1 with a PC or smart phone web browser (Chrome or Firefox).
Here’s the web UI:
Right after loading the page, the module starts recording and buffering automatically.
Currently the online stream is without audio, but this feature will be added in the future.
Tap on the video image and the image will scale to full width and original size.
There’s an audio signal scope under the screen which shows the received audio signal.
There are two buttons under the scope, with “CAPTURE”, the module will take and save the shot, and “LIGHT”, the on-board chip LED flashlight will turn on and off.
When using the “Chain Network” feature, if you join multiple ESP32-Cams to the network, you’ll be able to see an online stream of all the joined cameras at the same time.
Also, you’ll be able to see an online video stream of all the joined cameras in the “Streams” page:
With a click on each image, the “Capture” and “Light” buttons will appear and by double clicking on each image, you can enlarge and see the selected camera stream in higher quality.
By tapping or clicking on the “menu button” (top-right), the menu items will be appeared:
- Do not open two pages at the same time. The module can handle only one page at a time.
- The WiFi signal strength takes effect on the module capability and the video streams.
- The ESP32 module is weak and the arduino ESP32 compiler (rev 1.0.6) still needs to be updated, so when the module’s access point (hotspot) is turned off (by connecting the module to a modem and turning the temporary hotspot button on in the settings page), the device has a better performance.
The responsive WebApp
This web application is also compatible with cell phone and mobile device browsers: 📷
The menus
The Web Application is divided to 3 menus. The menus can be selected by clicking on the menu button.
“Streams” refers to the “Online Stream” page, “Memory” refers to the file manager and “Settings” refers to the settings page.
The File Manager
In the “Memory” page, you can see the saved images (.jpg format) and the recorded videos.
The videos save in “.jp5” format and in the current firmware revision, you can only play the videos in this page.
Also, you can access another device’s memory in this page with setting the “Target” device in the settings page.
There are 3 buttons under the image:
- File name (direct link) button.
- Next file button
- Remove button
The left button under the image (blue button) shows the file name and has the direct link of file (you can right click on it and copy the link).
The middle button shows the next file.
And the right button, removes the file.
You can download the images by tap or click on the image.
By clicking on the play button (middle of the JP5 file image), the video will be downloaded and played along with the audio, and you can pause the video by tapping or clicking on the image.
- Downloading the videos may take a while depending on the video data length and the WiFi signal strength.
The Settings menu
The web application’s settings menu has been divided to 5 parts:
- Modem Configuration
- Device Hotspot Configuration
- Camera Configuration: In this section:
- You can set the device’s network channel. The channel must be a number between 0-7 and the devices can’t have the same channel.
- The “Quality” of online stream and recording which can be Low (320*240), Medium (640*480) or High (800*600).
- The “Record Time” can be 10Sec, 30Sec, 1Min, 2Min or 4Minutes.
- The “Motion Detector Sensitivity” is the internal image processing sensitivity for motion detecting and can be Off, Low, Medium or High.
- The “PIR Input” switch enables and disables reading getting record command from “GPIO 3”.
- The “Flash Light” switch turns on and off the on-board chip power LED during the recording. The internal image processing sensitivity also depends on the scene light and objects.
- Local Network Configuration
- Local Network Map. With the target feature in this section you can access both IPCam and Spy Camera (rev 1.3) memories and play the.JP4 and.JP5 videos.
The Spy Camera project is available in the following links:
SpyCam Project (Video&Audio Recorder) Source Code, PCB and Schematic Plans (ESP32-Cam) – Rev 1.3
Arduino ESP32-CAM CCTV, WiFi IP Camera Source Code – Rev 1.3
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum