Save JPEG image to GoogleDrive[GAS] with ESP32 and OV2640 (Overview and Google Setting)

In the Video

Japanese【日本語】

English

1. Overview

Using ESP32 and OV2640, I do electronic work and a program that saves JPEG images captured by the camera to GoogleDrive. In this case, I use the Google App Script[GAS].

Another way is API[Google Cloud API], API is another post on this site. The hardware is exactly the same, the only difference is the software. So, see the API post for hardware.

This post will explain the overall overview and Google cloud settings. The software will be posted separately. See below for details.

As a reference, setting up Google Cloud is easier with GAS than with API.

2. Work content

There are three major works as follows.

1) Google Cloud Setting
This section is below.

2) Electric Work [Hardware]
This section is another post. [It is the same as the API post]
Please see “IoT camera production using ESP32 and OV2640 [Hardware]

3) Program [Software]
This section is another post of this series.
Please see “Save JPEG image to GoogleDrive[GAS] with ESP32 and OV2640 (Software)

3. Google Cloud Setting

Here are the Google Drive settings:

Step1. Log in with your Google account on your web browser
Step2. Create a storage folder in Google Drive
Step3. Create “GoogleAppScript” in Google Drive
Step4. Deploy the created “GoogleAppScript”
Step5. Set permissions for deployed applications
Step6. Operation check

See below for details.

Step1. Log in with your Google account on your web browser

Log in with your Google account on your web browser(In this case, Chrome)

Select “Google Drive”

Step2. Create a storage folder in Google Drive

Click on the plus sign and select “New Folder”

Input the name of this Folder. In this case, The name is “ESP32CAM_FOLDER”.

Step3. Create “GoogleAppScript” in Google Drive

Click on the plus sign and select “GoogleAppScript”

Click the name and Input the name of this Project.

In this case, The name is “ESP32CAM_PROJECT”

Copy and paste the script below here.

This is the Script for Google App Script.

function doGet(e) {
  return ContentService.createTextOutput('doGet Completed')
}

function doPost(e) {
  var data = Utilities.base64Decode(e.parameters.data);
  var myFilename = Utilities.formatDate(new Date(), "GMT+9", "yyyyMMdd_HHmmss")+".jpg";
  var blob = Utilities.newBlob(data, e.parameters.mimetype, myFilename );
  
  
   // Save the photo to Google Drive
  var folder, folders = DriveApp.getFoldersByName("ESP32CAM_FOLDER");
  if (folders.hasNext()) {
    folder = folders.next();
  } else {
    folder = DriveApp.createFolder("ESP32CAM_FOLDER");
  }
  var file = folder.createFile(blob); 
  return ContentService.createTextOutput('doPost Completed')
}

Click the “Save button(Floppy Disk Mark)” and save this script.

Step4. Deploy the created “GoogleAppScript”

Click “Deploy” and select “New Deployment”.

Click “Setting Mark” and select “Web App”.

Input the name of this deployment and select “Anyone” like below. After Input, Click the “Deploy” button at the right bottom.

Step5. Set permissions for deployed applications

Click “Authorize access”.

Select the Google Account to use this project.

Proceed to next page.

Click “Allow”

Get ID and URL. So, Please make a note of this.

Step6. Operation check

Open a new tab or page in your web browser and paste the acquired URL into the access destination.
If “doGet Completed” is displayed like below, the setting is successfully completed and the operation check is OK.

4. Reference

Again, this post only covers an overview and Google Cloud setup. Please refer to the separate post for hardware and software.

Comments

Copied title and URL