Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » How to send ESP32 CAM Captured Image to Google Drive
ESP32-CAM Projects IoT Projects

How to send ESP32 CAM Captured Image to Google Drive

Priyansh ShankhdharBy Priyansh ShankhdharUpdated:May 29, 20235 Comments8 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
ESP32 Cam send Image Google Drive
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview: Sending ESP32 CAM Captured Image to Google Drive

In this project, we will learn how to send ESP32 CAM Captured Image to Google Drive. We can use ESP32-Cam Module to click pictures after any specific duration of time and then upload it to a specific folder. This project is totally different as we will be using Google Drive API to upload images. We will require a specific client ID and password to access the folder in the Cloud.

The project is completed in four major steps:

  • Writing code for ESP cam and uploading
  • Installing Python and all required libraries
  • Setting up the google drive API
  • Writing python code to upload the images

In an earlier ESP32 CAM Based project we learned about Face Detection System or Color Detection System & also Object Identification System using Python & OpenCV. This project also requires the use of OpenCV for uploading the data to Google Drive.



Bill of Materials

The following is the list of Bill of Materials for building an ESP32 CAM Based Google Drive Image Upload System. TheESP32 CAM when combined with other hardware & firmware Take a Picture & Send to Google Drive.You can purchase all these components from Amazon.

S.N.ComponentsQuantityPurchase Links
1ESP32-CAM Board AI-Thinker1Amazon | AliExpress
2FTDI Module1Amazon | AliExpress
3Micro-USB Cable1Amazon | AliExpress
4Jumper Wires10Amazon | AliExpress

ESP32 CAM Module

The ESP32 Based Camera Module developed by AI-Thinker. The controller is based on a 32-bit CPU & has a combined Wi-Fi + Bluetooth/BLE Chip. It has a built-in 520 KB SRAM with an external 4M PSRAM. Its GPIO Pins have support like UART, SPI, I2C, PWM, ADC, and DAC.

The module combines with the OV2640 Camera Module which has the highest Camera Resolution up to 1600 × 1200. The camera connects to the ESP32 CAM Board using a 24 pins gold plated connector. The board supports an SD Card of up to 4GB. The SD Card stores capture images.

To learn in detail about the ESP32 Camera Module you can refer to our previous Getting Started Tutorial.


ESP32-CAM FTDI Connection

The board doesn’t have a programmer chip. So In order to program this board, you can use any type of USB-to-TTL Module. There are so many FTDI Module available based on CP2102 or CP2104 Chip or any other chip.



Make a following connection between FTDI Module and ESP32 CAM module.

ESP32 CAM FTDI Module Connection

ESP32-CAM FTDI Programmer
GND GND
5V VCC
U0R TX
U0T RX
GPIO0 GND


Connect the 5V & GND Pin of ESP32 to 5V & GND of FTDI Module. Similarly, connect the Rx to UOT and Tx to UOR Pin. And the most important thing, you need to short the IO0 and GND Pin together. This is to put the device in programming mode. Once programming is done you can remove it.


Project PCB Gerber File & PCB Ordering Online

If you don’t want to assemble the circuit on a breadboard and you want PCB for the project, then here is the PCB for you. The PCB Board for ESP32 CAM Board is designed using EasyEDA online Circuit Schematics & PCB designing tool. The PCB looks something like below.

The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from ALLPCB at 1$ only.

Download Gerber File: ESP32-CAM Multipurpose PCB

You can use this Gerber file to order high quality PCB for this project. To do that visit the ALLPCB official website by clicking here: https://www.allpcb.com/.

You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.

After filling all details, select your country and shipping method. Finally you can place the order.

You can assemble the components on the PCB Board.


Installing ESP32CAM Library

Here we will not use the general ESP webserver example rather another streaming process. Therefore we need to add another ESPCAM library. The esp32cam library provides an object oriented API to use OV2640 camera on ESP32 microcontroller. It is a wrapper of esp32-camera library.

Go to the following Github Link and download the zip library as in the image

Once downloaded add this zip library to Arduino Libray Folder. To do so follow the following steps:
Open Arduino -> Sketch -> Include Library -> Add .ZIP Library… -> Navigate to downloaded zip file -> add




Source Code/Program for ESP32 CAM Module

Here is a source code for sending ESP32 CAM Captured Image to Google Drive. Copy the code and paste it in the Arduino IDE.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <WebServer.h>
#include <WiFi.h>
#include <esp32cam.h>
const char* WIFI_SSID = "ssid";
const char* WIFI_PASS = "password";
WebServer server(80);
static auto loRes = esp32cam::Resolution::find(320, 240);
static auto midRes = esp32cam::Resolution::find(350, 530);
static auto hiRes = esp32cam::Resolution::find(800, 600);
void serveJpg()
{
  auto frame = esp32cam::capture();
  if (frame == nullptr) {
    Serial.println("CAPTURE FAIL");
    server.send(503, "", "");
    return;
  }
  Serial.printf("CAPTURE OK %dx%d %db\n", frame->getWidth(), frame->getHeight(),
                static_cast<int>(frame->size()));
  server.setContentLength(frame->size());
  server.send(200, "image/jpeg");
  WiFiClient client = server.client();
  frame->writeTo(client);
}
Void handleJpgLo()
{
  if (!esp32cam::Camera.changeResolution(loRes)) {
    Serial.println("SET-LO-RES FAIL");
  }
  serveJpg();
}
Void handleJpgHi()
{
  if (!esp32cam::Camera.changeResolution(hiRes)) {
    Serial.println("SET-HI-RES FAIL");
  }
  serveJpg();
}
Void handleJpgMid()
{
  if (!esp32cam::Camera.changeResolution(midRes)) {
    Serial.println("SET-MID-RES FAIL");
  }
  serveJpg();
}
Void  setup(){
  Serial.begin(115200);
  Serial.println();
  {
    using namespace esp32cam;
    Config cfg;
    cfg.setPins(pins::AiThinker);
    cfg.setResolution(hiRes);
    cfg.setBufferCount(2);
    cfg.setJpeg(80);
    bool ok = Camera.begin(cfg);
    Serial.println(ok ? "CAMERA OK" : "CAMERA FAIL");
  }
  WiFi.persistent(false);
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  Serial.print("http://");
  Serial.println(WiFi.localIP());
  Serial.println("  /cam-lo.jpg");
  Serial.println("  /cam-hi.jpg");
  Serial.println("  /cam-mid.jpg");
  server.on("/cam-lo.jpg", handleJpgLo);
  server.on("/cam-hi.jpg", handleJpgHi);
  server.on("/cam-mid.jpg", handleJpgMid);
  server.begin();
}
Void loop()
{
  server.handleClient();
}

Before Uploading the code you have to make a small change to the code. Change the SSID and password variable and in accordance with your WiFi network.

Now compile and upload it to the ESP32 CAM Board. But during uploading, you have to follow few steps every time.

  • Make sure the IO0 pin is shorted with the ground when you have pressed the upload button.
  • If you see the dots and dashes while uploading press the reset button immediately
  • Once the code is uploaded, remove the I01 pin shorting with Ground and press the reset button once again.
  • If the output is the Serial monitor is still not there then press the reset button again.

Now you can see a similar output as in the image below.

Congratulations, half of the work is done now.


Python Library Installation

For the live stream of video to be visible on our computer we need to write a Python script that will enable us to retrieve the frames of the video. The first step is to install Python. Go to python.org and download Python.

Once download, install Python.
Then Go to the command prompt and install NumPy and OpenCV libraries.

  • type: pip install numpy and press enter. After the installation is done.
  • type: pip install opencv-python and press enter, close the command prompt.

Now open Idle code editor or any other python code editor.




Setting up Google Drive API

Google has made the google drive API public but still, it has become difficult to grasp how things work. With this article, you don’t need to worry, as we are going to use a library that makes our work smoother. The library is known as PyDrive.

Before starting to use Google Drive API or PyDrive, you need to create a project in Google Developers Console, this is where Google will link your account with the API, provide you with keys to authenticate, and track your usage rate.

Steps to follow

1. Go to the Google Developer Console and log in with your Google account. A dashboard must be visible as in the image below.

2. Now create a new project, by clicking on select a project (The option is visible on the blue bar ) and then click on New Project.

3. Now add a name to the project and select your organization( or leave it as No Organization)

4. Once the project is created you will be directed to the Dashboard, now at the Sidebar click on OAuth Consent Screen. After that click on Configure Consent Screen.

5. Now follow as in the image below; click on External and CREATE

6. Now add your email ID and fill your details below as in the images below and then click on SAVE AND CONTINUE

7. Now go to Credentials and Click on +CREATE CREDENTIALS

8. Now click on Application Type dropdown options and select Desktop App.

9. Now once the above step is done click on CREATE and you’ll be directed to the dashboard, Now comes an essential step that is to download a JSON file for credentials which our python code will be using.

Download and save this file by renaming it client_sectrets.json

Now open Idle code editor or any python code editor



Python Code for Sending ESP32 CAM Captured Image to Google Drive

Please note that before implementing the following code, you have already installed the previously mentioned python libraries using PIP. Let’s see the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import cv2
import urllib.request
import numpy as np
import time
from pydrive.drive import GoogleDrive
from pydrive.auth import GoogleAuth
url='http://192.168.162.162/cam-lo.jpg'
cv2.namedWindow("live transmission", cv2.WINDOW_AUTOSIZE)
count=0
gauth = GoogleAuth()
gauth.LocalWebserverAuth()      
drive = GoogleDrive(gauth)
folder ="1CCAlI_b5x7jjb4jlsk0NiDBpkkqpB9Nf"#please change this value according to your folder
while True:
    img_resp=urllib.request.urlopen(url)
    imgnp=np.array(bytearray(img_resp.read()),dtype=np.uint8)
    frame=cv2.imdecode(imgnp,-1)
    
    cv2.imshow("live transmission", frame)
    key=cv2.waitKey(5)
    
    if key==ord('k'):
        count+=1
        t=str(count)+'.png'
        cv2.imwrite(t,frame)
        print("image saved as: "+t)
        f= drive.CreateFile({'parents':[{'id':folder}],'title':t})
        f.SetContentFile('1.png')
        f.Upload()
        print("image uploaded as: "+t)
        
    if key==ord('q'):
        break
    else:
        continue
cv2.destroyAllWindows()


Testing & Results

Now before you run the code you have to do few changes to the above code.

  • First, change the IP in URL variable to IP that is shown in the Arduino Serial monitor
  • Now, Save the json file in the same directory of the python code
  • Now, we also have to change the folder variable, to do so, go to the folder of google drive where you want to save pictures (make sure the google drive you are selecting is linked with the same email ID for which you did settings in Developer Console ). Once you are inside the folder, we have to copy the folder id from the link as in the image below

Once done you run the code.

For the first time, it will ask for Authentication you have to allow it all. Now every time you press K from your keyboard the image will be captured and uploaded.

Sending ESP32 CAM image to Google Drive

Congratulations you have successfully uploaded the image to google drive with the help of ESP32 CAM.

ESP32 CAM Google Drive


Video Tutorial & Guide

ESP32 CAM Send Captured Image to Google Drive
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleColor Detection & Tracking with ESP32 CAM & OpenCV
Next Article Raspberry Pi Pico Primer Kit for Beginners & Students – 10 Projects

Related Posts

IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20261K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

Updated:February 1, 20261K
View 5 Comments

5 Comments

  1. Architom on February 9, 2022 3:16 AM

    how do you capture the image? My IDLE shell gets to a point where it says authentication successful and I link it to the google drive but I don’t get the next “image saved as” line

    Reply
  2. Michelle on October 5, 2022 1:39 AM

    “client_sectrets.json” should be “client_secrets.json” – that caused some pain until I realised the typo in the instructions.

    Reply
  3. peter on June 29, 2023 1:55 PM

    error compiling.. any reason why? exit status 1

    Compilation error: ‘Void’ does not name a type

    Reply
  4. Shashi Kiran on July 3, 2023 3:13 AM

    Yes noticed the typo. !

    Reply
  5. Shashi Kiran on July 3, 2023 3:19 AM

    pip3 install pydrive
    To be included in the requirements.

    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • IoT Based Drinking Water Quality Monitoring with ESP32
    IoT Based Drinking Water Quality Monitoring with ESP32
  • LD2410 Sensor with ESP32 - Human Presence Detection
    LD2410 Sensor with ESP32 - Human Presence Detection
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • DIY IoT Water pH Meter using pH Sensor & ESP32
    DIY IoT Water pH Meter using pH Sensor & ESP32
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.