Introduction: ESP32 Video Surveillance - Very Easy
ESP32 Video Surveillance - quick, easy, cheap
ESP32-Cam + WemosD1 R32 + 3.5'' TFT Display
The ESP32-CAM is very popular. No wonder: it is cheap (~6 $ / ~7 €), relatively easy to program and it has a good wifi range with the possibility to connect an external antenna.
With another ESP32-WROOM and a TFT display we get an additional large number of different applications: Surveillance camera, door viewer, car rear view camera, baby monitor, 3D printer monitor, bird house monitor. I'm sure you can think of more.
(Almost) just Plug & Play! Just solder 3 wires and you have two devices that can do your surveillance.
But beware: the ESP32-Wroom can't manage a real video stream after all. We therefore send jpg images in quick sequence (~ 1-2 frames per second/ 1-2 fps). This is usually enough for surveillance.
This project requires a certain level of experience. Depending on which microcontroller you use, please find out about the setup. An excellent site is
Supplies
ESP32-cam (7-13€) (eventually with programmer, 8-13€)
or FTDI unit
ESP32-WROOM R32 (7-10€)
TFT Display Shield 3.5'' (or 2.8'') (17-36€) [should have pins like in the picture!]
3 short wires
Step 1: What Is So Special?
The special thing about this project is that - apart from soldering three wires - you don't have to do much on the hardware. No wire jam, no searching for connections. Plug the ESP32 and the display together, upload the software on both devices, connect the power supplies - and you're done.
Step 2: Transmitter: ESP32-CAM
Those who are not yet familiar with an ESP32-cam will find everything here: https://randomnerdtutorials.com/projects-esp32-cam/
I have ordered an ESP32 cam with programming unit. So I can just plug the camera in via USB and program it. But this is also well possible with a FTDI circuit. I use the Arduino IDE to transfer the file ESP32-cam.ino to the camera. The file app_httpd.cpp must be in the same folder.
Don't forget to change the SSID/password of your own wifi in the sketch.
After starting, you will get the web address of the camera, in my case http://192.168.2.58. Now you can get pictures by typing http://192.168.2.58/capture in your browser.
Now everything is actually ready. You can now operate the camera together with the programming unit (needs a little more power).
If the camera doesn't need to be programmed anymore, it can be operated nicely via the pins 5V and GND. You can make a simple connection from an old USB cable and now you can use any USB source. Simply connect 5V and GND to the ESP32-cam.
Attachments
Step 3: Receiver: ESP32-Wroom / R32
For setting up the R32 there is a good Instructable by MichaelV269
The TFT display shield fits beautifully on the Wemos D1 R32.
However, we still have to do a bit of soldering. Three of the connections on the board still have to be connected with wires to the corresponding pins on the same board (see picture).
- GPIO15 - GPIO36
- GPIO33 - GPIO34
- GPIO32 - GPIO38
Transfer the file ESP32-display.ino to the Wemos D1 R32. The file settings.h mus be in the same folder.
Don't forget to change the SSID/password of your own wifi in settings.h.
How to get the TFT Library:
https://github.com/Bodmer/TFT_eSPI: Code (green Button) --> Download ZIP
Arduino IDE: Sketch --> Include Library --> Add .ZIP Library --> [click on file]
Here is the short way setting up the TFT display:
After soldering and downloading the program has to be adapted according to the display size used.
If you also use the 3.5'' display, download the file User_SetupILI9341.h and rename it to User_Setup.h.
Now this file must be copied to the right place: Arduino IDE: File --> Preferences. Here you see the Address of your libraries.
My address is C:\Program Files (x86)\Arduino\User, so I go to C:\Program Files (x86)\Arduino\User\libraries\TFT_eSPI-master.
The file User_Setup.h contains the pin numbers of the different displays on different microcontrollers. In the section ....
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP ######
for example the pins for our display and ESP DevKit R32 are enabled.
This also works with a 2.8'' display [User_SetupILI9486.h], I'm still working on the image size.
Step 4: Test Image
The following messages are displayed:
- Connecting to wifi
- Streaming ...
- Stream not found
If the stream stops (and you don't see it because your cat sleeps anyway), a small blue square will appear in the left upper corner.
Step 5: Alternative: Camera and Display Have Their Own Wifi - Soon
Of course, you don't have to integrate the video surveillance into your WIFI network, the two devices can build their own network and act independently of an existing network.
To do this, you only need to change the sketch of the display ESP from Station (STA) to AccessPoint (AP). Please make sure that the SSID and password of both devices match.
Step 6: Power Consumption
ESP32-cam: 130 mA
ESP+Display: 270 mA
Okay, a Raspberry Pi would be better and faster, but the low energy consumption of the ESP is unbeatable! And you don't waste time booting an OS.
Step 7: Thank You
Many thanks to Bodmer and Rui Santos with their libraries and tutorials. They did a great work!