Esp32 Problem with http for google spreadsheet

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).

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 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.

#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.

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

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