Motion-triggered ESP32-based WiFi camera captures intruders
The ESP32-CAM is a small module
you can buy with an onboard ESP32
with WiFi plus a camera. By adding
a small PIR sensor, you can set it up
to take pictures of intruders secretly.
By the nature of the module, very
few I/O pins are free. IO4 is used to
enable an onboard bright LED that
acts as an extra light source for the
camera. GPIO13 is used as the trigger
input pin for taking pictures, either
by pressing pushbutton S1 or when
triggered by the passive infrared (PIR)
motion detector.
When a photo is taken, the program
stamps the time on the filename and
then stores it serially on the onboard
siliconchip.com.au
micro SD card. The ESP32 is then put
into deep sleep mode after taking a picture. GPIO13 is used to trigger wake-up
from deep sleep mode. This allows the
device to be battery-powered, preserving battery power during the idle time
when no picture is being taken.
GPIOs 1 & 3 are used to drive an
I2C serial bus that connects to the
OLED display and the DS3231 realtime clock.
Note that you will need a PIR sensor that can run from 5-9V.
The bottom part of the circuit diagram shows how to configure the
ESP32-CAM to take photos when
motion is detected. The real-time
Australia's electronics magazine
clock is used to timestamp the photos
while the display lets you check that
the camera is working correctly as it
displays status messages each time it
is triggered. The display could be left
out, or unplugged after the unit is set
up, as it will work without it.
As mentioned earlier, the module
is woken up and triggered by pulling
GPIO13 to ground. It’s essential that
this happens reliably, and I’ve found
the best way to do it is via an optoisolator. The opto-isolator connection to
the PIR sensor is easy and works perfectly every time.
You can download the software from
siliconchip.com.au/Shop/6/6440, then
compile and upload it to the module
using the Arduino IDE. As the ESP32CAM does not have a built-in USB
interface, a USB-to-serial adaptor is
required to upload the sketch, connected as shown in the top section of
the circuit diagram.
GPIO0 needs to be pulled to ground
to enable uploading, which is the
purpose of switch S3. The module’s
onboard button should be pressed
during the first few seconds of uploading, then released.
Bera Somnath,
Vindhyanagar, India. ($120)
May 2022 101
101