walidamriou / ESP_Data_to_Google_Sheets

Upload IoT data to Google Sheets from Espressif Systems ESP32 or ESP8266 board

Home Page:https://www.walidamriou.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Espressif Systems ESP32 or ESP8266 board Data to Google Sheets

Upload data to Google Sheets from Espressif Systems ESP32 or ESP8266 board


Reasons to Use Google Sheets for IoT Sensor Data

  • Logging sensor data from your embedded devices to Google Sheets is simple.
  • Can mixte between data from your sensors and another source.
  • Easy make a data visualization like a graph,... etc.
  • Embed your graphed data on the web.
  • Manipulate and analyze your data with default functions or by javascript functions (Apps Script).
  • You can check in on your data in the mobile by google sheets app.
  • You can make conditions actions with the incoming data (by Apps script or javascript).

Note:

Apps Script services impose daily quotas and hard limitations on some features. If you exceed a quota or limitation, your script throws an exception and execution terminates. See current Quotas here: https://developers.google.com/apps-script/guides/services/quotas#current_quotas


POST vs GET method

POST sumbits data (include in the body) to be processed to the indentified resource, the effect of this method is create a new resource or update existing resource or both. GET requests a representation of the specified resource. In general, GET is used to retrieve remote data, and POST is used to insert/update remote data, because GET can used arvitrily by robots (secripts) or crawlers, and for our work can make a problem with our data in the sheet. But just because we learn, we use the two methods to send the data to Google sheets but The security of the implementation is your work.


by GET method

Google drive:

1- Create a Google Sheets file (https://docs.google.com/spreadsheets/?usp=mkt_sheets) or you can use data_from_esp32.ods file from /sheets by upload it to your Google drive.
2- open the Google sheets file and go to Tools -> Script editor to use Google Apps Script. Google Apps Script is a rapid application development platform that makes it fast and easy to create business applications that integrate with G Suite. You write code in modern JavaScript and have access to built-in libraries for favorite G Suite applications like Gmail, Calendar, Drive, and more. There's nothing to install—we give you a code editor right in your browser, and your scripts run on Google's servers. more info here: https://developers.google.com/apps-script/
3- use the code from Google_apps_scripts/script1.gs , it is general code, and after that save the script and Go to Publish -> Deploy as web app, publish it as accessible to Anyone. Execute the app as Me. remember to assign a new version whenever you are making changes and deploying it again. Copy the link that is provided to you, at this step.

4- if you use data_from_esp32.ods file you can test by put the link that get it after publish the app script with queries (?id=data_s_1&data1=10&data2=20&data3=30&data4=40) in your browser, you need to give the code permissions in first use https://script.google.com/macros/s/your_id_of_the_script_here/exec?id=data_s_1&data1=10&data2=20&data3=30&data4=40

ESP board:
-- Platfomio with Arduino:

use the code in: ESP_code/main_https_get_by_arduino_platformio.c the comments in the code will help you.

-- ESP-IDF:

It will be published later


by POST method

Google drive:

The same notes of "by GET method" but use /Google_apps_scripts/Google_App_Scripts_POST_receive_for_project.gs

ESP board:
-- Platfomio with Arduino:

use the code in: ESP_code/main_https_POST_by_arduino_platformio.c the comments in the code will help you.

-- ESP-IDF:

It will be published later


Tools used:

Software

  • VScode
  • ESP-IDF
  • Platformio
  • https://requestcatcher.com Request Catcher will create a subdomain on which you can test an application. All requests sent to any path on the subdomain are forwarded to the browser in real time. I use it as Https server requests for test.
  • Postman

Hardware

  • ESP Lolin32

extra

IoT dashboard html by google sheets data Article 1 ,

Copyright CC 2020 Walid Amriou

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

You are free to:

  • Share — copy and redistribute the material in any medium or format
  • Adapt — remix, transform, and build upon the material The licensor cannot revoke these freedoms as long as you follow the license terms.

Under the following terms:

  • Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • NonCommercial — You may not use the material for commercial purposes.
  • ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
  • No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.

the software or Code or Scripts or any files in this source is provided "as is" and the author disclaims all warranties with regard to this files including all implied warranties of merchantability and fitness. in no event shall the author be liable for any special, direct, indirect, or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software or code or scripts or any files in this source.

References:

Reference 1 , Reference 2 , Reference 3 , Reference 4 , Reference 5 , Reference 6 , Reference 7 , Reference 8 , Reference 9 , Reference 10

About

Upload IoT data to Google Sheets from Espressif Systems ESP32 or ESP8266 board

https://www.walidamriou.com/


Languages

Language:C 73.8%Language:JavaScript 26.2%