Arduino / Platform.io library to add data to Google Spreadsheets via Google Forms, without API or authentication. Specifically for ESP-8266 and ESP32 platforms.
MIT license / (c) 2023 John Mueller
This works with the ESP8266 Arduino platform - https://github.com/esp8266/Arduino
This works with the ESP32 Arduino platform - https://github.com/espressif/arduino-esp32
You can either install through the Arduino Library Manager or checkout the latest changes or a release from github. To use this, you must also set up a Google Form and Spreadsheet (below).
Works with release 2.4.0 or newer of the ESP8266 core for Arduino
-
in Arduino IDE got to Sketch/Include Library/Manage Libraries
-
click Install and start using it
Github version works with release 2.4.0 or newer of the ESP8266 core for Arduino
- Checkout library to your Arduino libraries folder
Example code is in /examples/.
#include "GoogleFormPost.h"
// ... connect to your Wifi, get data, etc
// ... when you're ready ...
#define YOUR_FORM_URL "https://docs.google.com/forms/d/e/1FA..."
#define FIELD_ID_1 "entity.12345678"
#define FIELD_ID_2 "entity.109876543"
String yourDataString = ...;
String yourOtherDataString = ...;
GoogleFormPost gf;
gf.setFormUrl( YOUR_FORM_URL );
gf.addData( yourDataString, FIELD_ID_1 );
gf.addData( yourOtherDataString, FIELD_ID_2 );
gf.send();
// done! Total time ca 2 seconds
// Alternately, if you don't have the field IDs, you can read them:
GoogleFormPost gf;
gf.setFormUrl( YOUR_FORM_URL );
gf.readFields();
gf.addData( yourDataString );
gf.addData( yourOtherDataString );
gf.send();
// done! Total time ca 6-7 seconds
To submit to your own form and spreadsheet, you have to do the following:
- Create a new Google Form ( https://form.new/ works).
- Add a few "short answer" fields (however many you want).
- Click on "Responses" and "Link to Sheets" to create a spreadsheet.
- Click on the eyeball-symbol ("preview") to open the form.
- Copy & paste that URL into your code.
- That's it.
Comments:
- Use the specified form URL; does not support redirects
- Reading form fields takes about 4.5s on an ESP01 (ESP8266); be faster by supplying the fields yourself. The code is not super-efficient, but primarily reading from wifi is slow with these devices.
- Submitting form data takes about 1.6s on an ESP01 (ESP8266)
- Code uses Arduino-style "String" variables; can be converted to std::string if you hate Strings.
