https://github.com/softplus/googleformpost
Arduino / Platform.io library to add data to Google Spreadsheets via Google Forms, without API or authentication.
https://github.com/softplus/googleformpost
Last synced: 7 months ago
JSON representation
Arduino / Platform.io library to add data to Google Spreadsheets via Google Forms, without API or authentication.
- Host: GitHub
- URL: https://github.com/softplus/googleformpost
- Owner: softplus
- License: mit
- Created: 2023-05-06T16:26:13.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-06T19:30:43.000Z (almost 3 years ago)
- Last Synced: 2025-04-09T14:18:17.739Z (12 months ago)
- Language: C++
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# GoogleFormPost
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](LICENSE) / (c) 2023 [John Mueller](https://johnmu.com/)
 -
[](https://www.ardu-badge.com/GoogleFormPost) -
[](https://registry.platformio.org/libraries/softplus/GoogleFormPost)
*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
# Usage
## Installing
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).
### Install through Library Manager
__Works with release 2.4.0 or newer of the [ESP8266 core for Arduino](https://github.com/esp8266/Arduino)__
- in Arduino IDE got to Sketch/Include Library/Manage Libraries

- search for GoogleFormPost

- click Install and start [using it](#using)
### Checkout from github
__Github version works with release 2.4.0 or newer of the [ESP8266 core for Arduino](https://github.com/esp8266/Arduino)__
- Checkout library to your Arduino libraries folder
## Example code
Example code is in `/examples/`.
```c++
#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
```
## Setting up your Form and Spreadsheet
To submit to your own form and spreadsheet, you have to do the following:
1. Create a new Google Form ( https://form.new/ works).
2. Add a few "short answer" fields (however many you want).
3. Click on "Responses" and "Link to Sheets" to create a spreadsheet.
4. Click on the eyeball-symbol ("preview") to open the form.
5. Copy & paste that URL into your code.
6. That's it.
# Usage notes
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.