# Esp32 Problem with http for google spreadsheet

**URL:** <https://forum.arduino.cc/t/esp32-problem-with-http-for-google-spreadsheet/1058178>\
**Category:** Programming\
**Created:** [November 26, 2022, 12:13pm UTC](https://forum.arduino.cc/t/esp32-problem-with-http-for-google-spreadsheet/1058178 "2022-11-26T12:13:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![axel83](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@axel83](https://forum.arduino.cc/u/axel83)\
**Post date:** [November 26, 2022, 12:13pm UTC](https://forum.arduino.cc/t/esp32-problem-with-http-for-google-spreadsheet/1058178/1 "2022-11-26T12:13:46Z")

</div>

Hi,

I like to write / read from a google spreadsheet with an ESP32. Hence, I followed the instructions on:  
[ESP32 Data Logging to Google Sheets with Google Scripts (iotdesignpro.com).](https://iotdesignpro.com/articles/esp32-data-logging-to-google-sheets-with-google-scripts)

Setting up the google spreadsheet worked fine. Whenever I execute the URL

[https://script.google.com/macros/s/A\*\*\*\*g/exec?sensor=35&date=1103](https://script.google.com/macros/s/A **** g/exec?sensor=35&date=1103) in a browser I get a new line in the spreadsheet as mentioned in the example.

In the next step I followed the example for the arduino code.

```arduino
#include <WiFi.h> //Wifi library
#include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks
#include <HTTPClient.h> //Http Client to write and sent datato google spreadsheet

//const char* ssid_home = "FRITZ!Box ****";
//const char* password_home = "0***5";

void connecthome(){
  Serial.print("Connect to Wifi at home ");
 
  WiFi.begin(ssid_home, password_home);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
 
  Serial.println("");
  Serial.println("Home-WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void setup() {

  Serial.begin(115200);
  delay(10);
  // Set WiFi to station mode and disconnect from an AP if it was previously connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  Serial.println("Setup done");
  // Scan for all available networks
  int n = WiFi.scanNetworks();

  Serial.println("scan done");
  if (n == 0) {
      Serial.println("no networks found");
  } else {
        connecthome();
        Serial.println("Connect to Home Network");
        }
}

void loop() {

  String urlFinal = "https://script.google.com/macros/s/A***g/exec?sensor=35&date=1103";
  Serial.print("POST data to spreadsheet:");
  Serial.println(urlFinal);
  HTTPClient http;
  http.begin(urlFinal.c_str());
  http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
  int httpCode = http.GET(); 
  Serial.print("HTTP Status Code: ");
  Serial.println(httpCode);
  delay(1000);
}

```

Excuting the code on the ESP32 I get the output

> POST data to spreadsheet:h\*\*3  
> HTTP Status Code: 200

but no line appears in the spreadsheet. I also tried different networks, but the result is the same. Has anyone an idea, what could be wrong.

Thanks for that, Axel

PS:  
1: The connection to the network seems to be a bit strange. But in the full code IU automatically choose between two networks. I just deleted this part in this example as this is working fine.  
2: In the replay there is the url, but I had to delete them as I'm not allowed to have so many links.

---

<div class="post-metadata">

**Author:** ![pylon](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@pylon](https://forum.arduino.cc/u/pylon)\
**Post date:** [November 28, 2022, 4:29pm UTC](https://forum.arduino.cc/t/esp32-problem-with-http-for-google-spreadsheet/1058178/2 "2022-11-28T16:29:07Z")

</div>

You might want to print out what Google returns to you.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 27, 2023, 4:29pm UTC](https://forum.arduino.cc/t/esp32-problem-with-http-for-google-spreadsheet/1058178/3 "2023-05-27T16:29:47Z")

</div>

Closed on May 27, 2023, 4:29pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
