Capture image using ESP32-Cam (OV2640) using ESP8266 WeMos D1 R1 WiFI Processor with Uno and send it to email, save to Google Drive and send it to Whatsapp using Twilio.
Requirements:
In this project we will use ESP32-cam to capture image using OV2640 and send it to email, save to Google Drive and send to Whatsapp using Twilio. We can use the ESP32-cam with the FTDI programmer because it doesn’t come with a USB connector but in this project, we are using ESP8266 WeMos D1 R1 WiFI Processor with Uno to upload the code. Further, we are using Google Apps Script (https://developers.google.com/apps-script) to send the image data to email, save to Google Drive and send it to Whatsapp using Twilio API.
There are three GND pins and two pins for power: either 3.3V or 5V.
UOT and UOR are the serial pins. You need these pins to upload code to your board. Additionally, GPIO 0 (Io0) also plays an important role, since it determines whether the ESP32 is in flashing mode or not. When GPIO 0 (Io0) is connected to GND, the ESP32 is in flashing mode. When you finished uploading
We used GPIO2 for the push button input
In this example, we use the Arduino IDE to program the ESP32-CAM board. So, you need to have Arduino IDE installed as well as the ESP32 board using Arduino core for the ESP32. Follow one of the next tutorials to install the ESP32 board, if you haven’t already:
Installation instructions using Arduino IDE Boards Manager
- Stable release link:
https://raw.githubusercontent.com/espressif/arduin...
Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32, 64 bit and ARM).
After finishing the installation, clone this repository or download directly from Github and open [esp32_cam.ino](esp32_cam.ino). Before uploading the code, you need to insert your network credentials in the following variables:
const char* ssid = "REPLACE_WITH_YOUR_SSID";<br>const char* password = "REPLACE_WITH_YOUR_PASSWORD";
Also, comment out the respective camera model line, in our case it is
#define CAMERA_MODEL_AI_THINKER //We have this model of Esp32-cam
Further, you need to replace the "myScript" Google Apps Script URL with your script URL, "myRecipient" with your email & "mySubject" with your subject.
String myScript = "/macros/s/**********/exec"; //Create your Google Apps Script and replace the "myScript" path.<br>String myRecipient = "youremail@gmail"; //Enter your Email address String mySubject = "Image Captured from Arduino Esp32-Cam"; //Enter some subject
You can create a new project in Google apps script and copy the code from (Code.gs) and replace the POST request URL with your server URL. We used Siteground shared hosting for this purpose and any basic hosting can be used for this purpose.
var url = 'http://server-url/esp32/esp32.php';
Publish your script with anonymous access.
Upload (esp32.php) to your server along with Twilio PHP SDK that we have included in the PHP file. Replace the Twilio Account Sid and Auth Token. Find your Account Sid and Auth Token at twilio.com/console.
$sid = "xxxxx"; $token = "xxxx";
You also need to change the To WhatsApp number with the number that you have linked in Twilio.
->create("whatsapp:+xxxxxx", // to
Before uploading the code to the ESP32-Cam be sure you have connected GPIO 0 (Io0) to GND so ESP32-cam will be in flash mode. Also, keep the ESP32 Wrover Module board selected in this project and before uploading. Press the Reset button on ESP32-Cam and press the upload button in Arduino IDE. After finishing open the serial monitor in IDE and press the Reset button on ESP32-cam again. It will connect to wifi soon. After that press the push button to capture and send the image to the email and WhatsApp number.
Part of the code we used is taken from https://github.com/fustyles/Arduino