Home Mini Surveillance Camera Made with ESP32S3
Project Origin
I was scrolling through videos and saw someone use only an ESP32 development board plus a camera to implement a home surveillance camera, viewing the camera feed over the network.
Such a cool thing — when I went to learn more about it and wanted to get it for free, I found that they were either selling courses or requiring you to buy their stuff..... Great, no one has a tutorial, so I'll write one! I happen to have a development board under review, so why not give it a try?
Preparation
- Use an ESP32 development board;
- Use an FPC-style OV2640 camera;
- Install the Arduino IDE environment on the computer for programming the ESP32 development board;
- Use Oray Peanut Shell on the computer to set up intranet penetration, so that the camera data can be viewed from the external network;
Project Execution
The execution of this project will be divided into two parts: the hardware part and the software part.
1. Hardware Part
1.1 Development Board Introduction
My development board is the LCSC ESP32S3 development board, which is currently under review at LCSC.
1.2 Camera Introduction
The camera used is an FPC-style OV2640 camera. Purchase link:
https://detail.tmall.com/item.htm?_u=62t4uge5a6f6&id=624606735663&spm=a1z09.2.0.0.5a9d2e8dIZHkK5
Because the camera is in FPC form, we also need to consider how to drive it, so we designed a peripheral driver circuit specifically for this development board to drive this camera. I won't go into the principle here — you can just copy it. 😜
2. Software Part
You need to install the Arduino IDE for programming.
2.1 Introduction to Arduino
Arduino is an open-source hardware and software platform for building and controlling various physical devices and interactive projects. It consists of a software development environment based on open-source code. The Arduino programming language is a simple and easy-to-understand language based on C/C++. The simplicity, flexibility, readily available resources, and rich application areas of Arduino make it a popular and widely used development platform. Both beginners and professional developers can gain the ability to rapidly develop and innovate with it.
2.2 Installing Arduino IDE
Open the Arduino IDE official website's software download page, and select the corresponding system and system bitness to download. Here I choose the latest Windows 10 64-bit environment.
On the new page that pops up, you can choose to download directly, or donate and download.
Run the installer and just keep clicking Next. (It is recommended not to save it in the C drive when setting the installation path.)
Download the esp32 offline installation tool.
Select the installation path. Note that it must be placed in the arduino device package directory of the corresponding user. The following is the installation path for Arduino IDE V2.2.1:
C:\Users\{Username}\AppData\Local\Arduino15\packages\Taking the username "win" as an example:
C:\Users\win\AppData\Local\Arduino15\packagesAfter installation, close all arduino windows to ensure that arduino has been closed. Reopen arduino, and open the Boards Manager. You will see that esp32-arduino has been installed successfully.
Change the Chinese display. Open the Arduino IDE preferences. 【File】->【Preferences】.
In the preferences interface, select Chinese (Simplified) for the language.
If the IDE is not updated, close the IDE and reopen it.
2.3 Source Code Introduction and Verification
I have uploaded the source code to Baidu Netdisk. Feel free to download it if needed:
Link: https://pan.baidu.com/s/1QEUrwIl7IBxbApNx-Ka9qg?pwd=1234 Extraction code: 1234
Workflow
Initialize debug serial port -> Initialize camera -> Initialize Wi-Fi -> Output the IP address for displaying image data
- Initialize debug serial port
In embedded systems, the debug serial port is very common and important. Later, our BUG debugging and inspection will also rely on the data it outputs for analysis.
- Initialize camera
The source code contains settings for the camera pins. If your camera baseboard schematic uses different pins from mine, you can modify the code to switch to any pin. However, please note that I tested and found that GPIO45 and GPIO46 of the ESP32S3 development board cannot be used where there are pull-up resistors, otherwise the development board will not work properly!
- Initialize Wi-Fi
The source code contains Wi-Fi settings. The purpose of this Wi-Fi is to allow the ESP32S3 development board to connect to it, so that the development board can output image data to the network via Wi-Fi. Later, we just need to copy the IP address output during serial debugging and open it in a browser to see the camera feed.
Please enter the Wi-Fi account and password that the development board will connect to in the source code. The Wi-Fi must have network access.
- Compile and download
After modifying the Wi-Fi and camera, connect the development board, and follow these parameters:
Select our board as ESP32S3 Dev Module;
Select our port number. Here we select CH340K's COM36;
The port number of each computer may not be the same. You can determine which port is the ESP32S3 development board's port by plugging and unplugging the development board.
Click the download button, and it will automatically compile and download;
When the following figure appears, it means the download is successful. If the download fails, please verify that the correct download port is selected.
2.4 Camera Verification Test
Open the serial debugging assistant. If you don't have a debugging assistant, you can use the serial assistant that comes with arduino. However, you must select the correct port.
After downloading the code, press the RESET button on the development board once to reset. If there is no button, power cycle the development board.
If everything goes smoothly, an IP address will be displayed on the serial debugging assistant. (The "not connected" here is because I unplugged the development board to take photos.)
Use your phone or computer to connect to the Wi-Fi we set in the code — you must connect! After connecting, open a browser, enter this IP address, and then navigate to it. Everyone's IP address should be different. If successful, you will enter the webpage shown below. (Note! This is currently a test, on a local area network. If you disconnect from this data-transmitting Wi-Fi, it will no longer work.)
Click Start Stream on the page to start image transmission. If all goes well, you should see the camera feed.
3. Intranet Penetration
Intranet penetration can turn our local area network (intranet) into the internet (external network), so that we only need a URL to view the camera feed anytime, anywhere. You can use a software for this: download Oray Peanut Shell on your computer. Download link: https://hsk.oray.com/.
This software requires payment to enable the intranet penetration function. I'm also just learning about this. If any expert knows of free resources, please let this newbie know (covering mouth and crying).
Add a new intranet penetration mapping. (A webpage will pop up.)
Enter the following parameters in the pop-up interface.
After completion, power on the development board. Note! Do not connect to other Wi-Fi networks, otherwise the IP address will change. After powering on, click Diagnostics to see whether the intranet penetration is successful. If successful, it will look like this:
If there are no issues, we can proceed to the external network test. Click the external network domain name.
Or enter the domain name on the webpage. If the following interface appears, it means our surveillance camera is complete!