ESP32 Cam save Image to SD Card, IR Sensor with ESP32 Cam

ESP32 Cam SD Card

ESP32 Cam SD Card:

ESP32 Cam SD Card

ESP32 Cam save Image to SD Card, IR Sensor with ESP32 Cam- I have already made many videos and have written several articles on ESP32 Cam. If you haven’t used the ESP32 camera module before, I highly recommend that you read my getting started article. Because in that article, I have discussed the issues related to ESP32 Camera Module. And I have also practically demonstrated; how to solve those issues.

In addition, I used the ESP32 Cam as a smart IoT Doorbell, in which I created a cell phone app with the help of the Blynk application; which I used for monitoring the camera and at the same time I used it to control the door lock.

I’ve also used the ESP32 Cam with Google Drive, and a lot of people liked this project. Because with the help of this project, you can monitor your camera from any corner of the world; provided if the internet connection is available.

check my new project on ” ESP32 CAM and Python OpenCV Yolo V3 for object detection and identification”

For more ESP32 Cam-related videos visit my YouTube channel Electronic Clinic.

You may have noticed that there is a Micro-SD Card slot on the front of the ESP32 Cam module, by using which you can store images in it. And this way you can make a time lapse camera for yourself. I have already explained the time lapse camera function in the ESP32 Cam Google Drive project.

ESP32 Cam SD Card

In today’s article, I will use this long-range adjustable IR sensor with the ESP32 Camera module. I have taken this IR sensor from DFRobot. I will share the complete specification of this IR sensor with you guys. Well, if you guys don’t have this IR sensor, you can use a simple push button for testing. I connected the IR Sensor with the ESP32 Camera module as per the circuit diagram which I will explain later in this article. First, I am going to explain its working and then I will start practical demonstration.

Before using the camera module, you have to insert the micro SD card into it. Then you have to install this IR sensor and camera at the place which you have to monitor. As you can see, there is quite a long cable with this IR sensor, so, you can easily install it at your desired location. For demonstration purposes, I will check this project on this table, so that all friends can easily understand it’s working.

You can see I have powered up the ESP32 Camera module.

Now, if any object or person comes in the range of this IR sensor, ESP32 Cam will automatically capture its picture, and will save it in the SD card. So, let’s go ahead and start our practical demonstration.

Altium Designer + Altium 365 + Octopart:

Arduino LoRa Free SMS

Altium 365 lets you hold the fastest design reviews ever. Share your designs from anywhere and with anyone with a single click. it’s easy, leave a comment tagging your teammate and they’ll instantly receive an email with a link to the design. Anyone you invite can open the design using a web browser. Using the browser interface, you’re able to comment, markup, cross probe, inspect, and more. Comments are attached directly to the project, making them viewable within Altium designer as well as through the browser interface. Design, share, and manufacture, all in the same space with nothing extra to install or configure. Connect to the platform directly from Altium Designer without changing how you already design electronics. Altium 365 requires no additional licenses and comes included with your subscription plan.

Get real-time component insights as you design with Octopart built into Altium 365. Octopart is the fastest search engine for electronic parts and gives you the most up-to-date part data like specs, datasheets, cad models, and how much the part costs at different amounts etc. Right in the design environment so you can focus on your designs. Start with Altium Designer and Activate Altium 365. Search for electronic parts on Octopart.

I Placed the IR sensor on the front and ESP32 Camera module on the backside. And I adjusted the range as per the requirements.

ESP32 Cam SD Card

For the initial testing, I waved my hand in front of the IR sensor and I could see flashes from the ESP32 Cam.

ESP32 Cam SD Card

I did it two or three times and when I was satisfied. Then I told my cousin to walk in front of the IR Sensor.

ESP32 Cam SD Card

You can see the ESP32 Cam successfully captured all the images and saved them in the Micro SD card. I am sure by now, you might have got an idea of how does this system work. So, without any further delay let’s get started!!!

Amazon Links:

ESP32 Cam Module

Adjustable IR Infrared Sensor

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!


The ESP32-CAM is a small camera module with the ESP32-S chip that costs approximately $10. Besides the OV2640 camera, and several GPIOs to connect peripherals, it also features a microSD card slot that can be useful to store images taken with the camera or to store files to serve to clients.

ESP32-CAM ESP32 WIFI+Bluetooth Development Board Module w/ OV2640 Camera

Ultra-small 802.11b/g/n Wi-Fi + BT/BLE SoC module. Low-power dual-core 32-bit CPU for application processors.

Main frequency up to 240MHz, computing power up to 600 DMIPS.Built-in 520 KB SRAM, external 4M PSRAM.Supports interfaces such as UART/SPI/I2C/PWM/ADC/DAC.Support OV2640 and OV7670 cameras, built-in flash.

ESP32 Cam SD Card

The ESP32-CAM is a small-sized camera module. The module can operate independently as a minimum system with a size of only 27*40.5*4.5mm and a deep sleep current of up to 6mA. It can be widely used in various IoT applications. It is an ideal solution for IoT applications.


  • Ultra-small 802.11b/g/n Wi-Fi + BT/BLE SoC module.
  • Low-power dual-core 32-bit CPU for application processors.
  • Main frequency up to 240MHz, computing power up to 600 DMIPS.
  • Built-in 520 KB SRAM, external 4M PSRAM.
  • Supports interfaces such as UART/SPI/I2C/PWM/ADC/DAC.
  • Support OV2640 and OV7670 cameras, built-in flash.
  • Support image WiFi upload, support TF card.
  • Support multiple sleep modes, embedded Lwip and FreeRTOS.
  • Support STA/AP/STA+AP working mode.
  • Support Smart Config/AirKiss one-click distribution network, support secondary development.
  • It is suitable for home smart devices, industrial wireless control, wireless monitoring, QR wireless identification, wireless positioning system signals, and other applications.
  • Packaged in DIP and can be directly plugged into the backplane for quick production.


  • Material: Copper
  • Module model: ESP32-CAM
  • Package: DIP-16
  • Size: 27*40.5*4.5(±0.2)mm
  • SPI Flash: 32Mbit by default
  • RAM: Internal 520KB + external 4M PSRAM
  • BT: BT 4.2BR/EDR and BLE standards
  • WiFi: 802.11 b/g/n/e/i
  • Support interface: UARI, SPI, I2C, PWM
  • Support TF card: maximum support 4G
  • IO port: 9
  • Serial port rate: default 115200bps
  • Image output format: JPEG (only supported by OV2640), BMP, GRAYSCALE
  • Spectrum range: 2412-2484MHz
  • Antenna form: onboard antenna, gain 2dBi
  • Security: WPA/WPA2/WPAS-Enterprise/WPS
  • Power supply range: 5V
  • Working temperature: -20 ° C -85 ° C
  • Storage environment: -40°C-90°C, <90%RH
  • Package size: 5*5*3cm/1.96*1.96*1.18in
  • Package weight: 15g

Transmit power:

  • 11 b: 17±2dBm (@11Mbps)
  • 11 g: 14±2dBm (@54Mbps)
  • 11 n: 13±2dBm (@MCS7)

Receive sensitivity:

  • CCK, 1 Mbps: -90dBm
  • CCK, 11 Mbps: -85dBm
  • 6Mbps (1/2 BPSK): -88dBm
  • 54Mbps (3/4 64-QAM): -70dBm
  • MCS7 (65Mbps, 72.2Mbps): -67dBm

Power consumption:

  • Turn off the flash: 180mA@5V
  • Turn on the flash and adjust the brightness to the maximum: 310Ma@5V
  • Deep-sleep: The lowest power consumption can reach 6mA@5V
  • Modern-sleep: up to 20mA@5V
  • Light-sleep: up to 6.7mA@5V

IR Adjustable Sensor:

ESP32 Cam SD Card

I have got this long-range Adjustable IR Sensor from DFRobot. On the front, it has got the transmitting and receiving IR LEDs. ON the back side you will find this Red color LED which lights up each time the sensor detects anything. Next, to the LED you can see this small screw, which you can use to adjust the detection range.

The Blue wire is the signal wire.

The Brown wire is the Voltage wire. And

The Black wire is the GND wire.


The output form is PNP Normally Open.

The signal type is digital.

The operating voltage is 3V to 5volts. Due to such a wide input voltage range it can be used with all 3.3v and 5V compatible controller boards like ESP32 CAM, Arduino, ESP32, ESP8266, STM32, etc.

The detection range is from 0 to 200cm.

Interface is XH2.54-3Pin

Humidity: 35% to 95% RH

Switch Level: 0, No obstacles in the area; 1, there are obstacles in the area.

Storage Tempera is -25 to 75 degrees Celsius.

Operating temperature is -15 to +60 Degrees Celsius.

IR Sensor Applications:

Useful for robotics, interactive media, industrial assembly line, etc. Infrared wave length is part of the Sun’s natural light spectrum. While is a nice fit for indoor projects, outdoors with plenty of sun light and reflective surfaces on the sight is not advised. It’s incredibly repurposable and can be used for a lot of different projects. The adjustable screw on it’s back makes it very convenient for different purposes. Digital read on your Arduino pin and you are ready to go. Good sensor choice for quick prototyping.

IR Sensor Interfacing with ESP32 Cam:

ESP32 Cam SD Card

The circuit diagram is very simple. The signal wire of the IR Sensor is connected with the IO12 pin of the ESP32 Camera module.

ESP32 Cam development Board:

ESP32 Cam SD Card

I have designed this simple development board for the ESP32 Camera module. You can see I have added these male and female headers for connecting the 5V power supply and for connecting different types of sensors. If you want to make the same development board, then you should watch my video on the ESP32 Cam development board.

ESP32 Cam Programming:


Upload code into ESP32 Cam:

Uploading code into ESP32 Cam is a bit tricky. You will have to connect it to the Arduino to upload the code. You can follow these connections.

ESP32 Cam SD Card

  • Connect the 5V of the Arduino Nano with the 5V of the ESP32 CAM
  • Connect the ground of the Arduino Nano with the ground of the ESP32 CAM
  • Connect the TX pin of the Arduino Nano with the VOT of the ESP32 CAM
  • Connect the RX pin of the Arduino Nano with the VOR of the ESP32 CAM
  • Connect the reset pin with the ground in the Arduino Nano.
  • Connect IOO of the ESP32 CAM with the Ground

Then we will select the following setting in the Arduino IDE.

  • Board: ”ESP32 Wrover Module”
  • Upload Speed: “115200”
  • Flash Frequency: “80MHz”
  • Flash Mode: “Q10” >
  • Partition Scheme: “Huge APP (3MB No OTA/1 MB SPIFFS)” >
  • Core Debug Level: “None” >
  • Port: “COM port’ > According to your port connection

Upload the code to the ESP32 CAM:

Anyway, after uploading the code, I connected my IR sensor with the ESP32 CAM module. And I powered up the ESP32 Cam using a 5V regulated power supply.  

Watch Video Tutorial


Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button