Ask Your Question

How can data be retrieved from a Google Sheet using an ESP32 or ESP8266?

asked 2021-04-10 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-08-05 01:00:00 +0000

huitzilopochtli gravatar image

To retrieve data from a Google Sheet using an ESP32 or ESP8266, you can follow these steps:

  1. Create a Google Sheet and add some data.

  2. Publish the sheet as a CSV file by going to File > Publish to the web, and choose Comma-separated values (.csv) in the drop-down menu.

  3. Copy the CSV link from the window and save it.

  4. Install the ESPAsyncWebServer library on your ESP32/ESP8266.

  5. Set up an HTTP server on the ESP32/ESP8266 using the ESPAsyncWebServer library.

  6. Set up the server to handle GET requests and parse the CSV link.

  7. Use the HTTPClient library to send a GET request to the CSV URL and obtain the data.

  8. Parse the CSV data and use it as needed.

Here is a basic example code:

#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include <HTTPClient.h>
#include <CSV.h>

const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";

AsyncWebServer server(80);

void setup() {

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.println("Connecting to WiFi...");

  // Set up HTTP server
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    HTTPClient http;    
    int httpCode = http.GET();
    if (httpCode > 0) {
      String csvData = http.getString();
      Serial.println(csvData); // Print CSV data to Serial monitor

      // Parse CSV data
      CSV csv;
      int numCols = csv.setRows(csvData.c_str());
      for (int i = 0; i < numCols; ++i){
        String value = csv.getValue(1, i);
        Serial.println(value); // Print each value in row 1

  Serial.println("HTTP server started");

void loop() {

Note that this is just a basic example and you may need to modify the code to fit your specific requirements. Also, make sure to keep the CSV link private and secure if it contains sensitive data.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2021-04-10 11:00:00 +0000

Seen: 8 times

Last updated: Aug 05 '22