ESP32-CAM emails picture

ESP32-CAM sends email with a pic attached every half hour while we are away and if it's bright enough. Now includes servo to move cam.

Similar projects worth following
Added another $5 ESP32-CAM to remote monitor the birdfeeder when we are away. It sends an email with a 1600X1200 picture of the birdfeeder attached every 1/2 hr when it's bright enough to a dedicated email. Can view the pic from anywhere.

Includes a photoresistor in a voltage divider circuit so it only sends pics when it's bright enough.

See code in files.
I could also get the exact time from the internet or send the time to it using another controller that has a RTC connected with ESP-NOW so the emails are sent on the hour and half hour if bright enough.
No I/O needed for date and time on the receiving microcontrollers. ESPNOW code on 8266 and ESP32 are slightly different.

I put it on top of a servo for wider views. See pics and code in flies.

Project added to this one:

Apr 4, 2023  Worked out the issues with ESP32Cam and Google email. Now includes servo to move cam every 5 minutes for much wider views.  

For the price of a servo and power supply you could have a bunch of fixed cams @$5 each arranged in a circle instead. Most servos won't give 360 degree views. Program them to send pics at different times. If you buy the cams with the USB shield that's all you need. Trigger the pics based on time from the internet between sunrise and sunset, and/or PIR sensor and/or on demand remotely from a webpage dashboard button in MQTT. For MQTT info go to

Sunrise and sunset times depend on which month it is. Year, month, day and time comes from the internet. Corrected for daylight savings time or not. This project shows how to get the time from the internet.

It's nice to be able to look around the house and outside while we are away for peanuts cost. 

See test rig pic and code in files. The ESP32Cam shield is only needed for easy programming. If the email doesn't show up in Gmail just wait 1/2 hr or so. Once Google decides to accept the email it usually keeps working. Also Gmail stops temporarily if you send more than 500 emails in one day.

Servo version is powered from USB charger and cable with 5 volts split out to power the ESP32Cam. I use orange wires for 5V so it's not mixed up with red 3.3V.  Yellow is the PWM command to the servo. The servo is separately powered from a 6V power supply on the white + and blue - wires in the last pic. Grounds connected. 

Different wire colours are so I don't mix them up. ESP32Cam is a 3.3V device. 5V on most pins can destroy it.

I could use a number of 3.3V AM312 PIRs to detect which zone has activity, move the cam to that zone and email a pic.

I found the WiFi on ESP boards gives a lot of PIR false triggers if it's mounted nearby so I put an aluminum tube around the base of the PIR to shield it. Side shields are needed for multiple zones as well.

Note!! Jan 2023: There are now many issues with emailing a picture from ESP32 Cam including Google requires 2-step verification and the libraries have changed. Good luck sorting out all the new changes.

Also it seems on ESP32 WiFi and ESPNOW can't coexist. One or the other. I can get time from an existing NodeMCU with a clock. Pic capture and send based on time. 

With my ESP8266/NodeMCUs it's not a problem at all. I still prefer NodeMCU over ESP32.

My solution is to only connect to wifi,  WiFi.begin("wifi name", "wifi password"); based on time from ESPNOW, capture and send pic then disconnect using WiFi.disconnect(); . This works OK but ESPNOW seems flaky on ESP32.

It's better to use time from the internet instead. Then wifi can remain connected.  If you have multiple cameras make sure pics are emailed at different times. See code for this in files. And/or Subscribe to a button on MQTT and trigger a pic and email remotely from anywhere.

The original ESP32 Cam board doesn't have a micro USB socket for programming so many temporary connections are needed to program it. OTA programming should work like it does with NodeMCU but no luck so far. With OTA you don't need the USB socket.

Program it using an Arduino Uno or a FTDI board. Correct wiring is at 1:00.

Or get a ESP32 Cam shield with a micro USB socket. For this one you don't need to hold a button to program.

Much, much easier. The shield can be removed after programming. Or left on and used to power the ESP32-Cam . The cam with the shield is only around a dollar more. Make sure you buy a few cams as they are easily damaged. Don't waste hours trying to get a  reluctant board working. Just switch boards and the same code works fine. I use clear silicone to stick the camera to the SD card holder. Silicone sticks to...

Read more »

ESP32Cam Apr 10, 2023 Wifi Time Servo OnOff.txt

Added servo detach after move to stop growling noise and power use when idle. Servo attach just before move. Moves and sends pic every 5 minutes.

plain - 11.85 kB - 04/10/2023 at 19:26


ESP32Cam Apr 8, 2023 Wifi Time Servo.txt

Servo moves cam for every pic.

plain - 11.29 kB - 04/10/2023 at 15:09



Sends pic based on time from the internet.

plain - 9.27 kB - 04/02/2023 at 23:30



Updated code. Works as of Mar 30, 2023 w/o photoresistor Sends pic every minute. Based on code from here:

plain - 5.04 kB - 03/30/2023 at 23:40


  • 1 × ESP32 Cam - get one with a USB shield Or a Cam shield
  • 1 × USB charger
  • 1 × Micro USB cable With the ESP32Cam with USB built in the above items are all you need for no servo.
  • 1 × Photoresistor optional
  • 1 × 4.7K resistor optional

View all 9 components

View all 3 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates