Problem with GET using HTTPClient library and ESP32

Hi everyone, this is my first post on the forums so please be lenient on whatever mistakes I made with my post (typos, weird title/format etc...).

I'm currently doing a mini project involve posting parameters gathered by my weather station (consists of sensors BME280 and BH1750) to Google Sheet, which will be processed and print Status "YES" or "NO" on a column. With "YES", the board will turn the motor and close off my house's terrace, which will prevent my clothes from getting wet due to raining. With "NO", the board will check whether the cover is closed or not, and proceed to do nothing or retract the cover. Here is additional infos:

Hardware used : Wemos D1 R32 with ESP32 chip, BME280, BH1750, L298n motor driver
Software used: Google App Script, Arduino IDE.
Libraries used: WiFi.h, ArduinoJson.h, HTTPClient.h.

As mentioned prior, the parameters gathered by my weather station to my Google Sheet, which will be processed and the Google Script I wrote will then write "YES" or "NO" on the status column. Which the esp board will send a request GET to get the status and use it to determine whether to turn the motor on or off. I used the standard HTTPClient to connect to Google Script server and post the parameters, so far so good, but when I send my GET request, an error occured. Here is my test code and the error console (I was running verbose debug mode) :

Codes:

  • Arduino:
#include <WiFi.h>
#include <HTTPClient.h>
#include <iostream>
#include "ArduinoJson.h"
 
const char* ssid = "somewhere";
const char* password =  "someplace";
StaticJsonDocument<300> doc;
const char* Status = doc["Status"];
 
void setup() {
 
  Serial.begin(115200);
  delay(1000);

  WiFi.mode(WIFI_STA);
  delay(300);
  WiFi.begin(ssid, password); 
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
    Serial.println(WiFi.status());
  }
 
  Serial.println("Connected to the WiFi network");
    if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status
 
    HTTPClient http;

    http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
    http.begin("https://script.google.com/macros/s/AKfycbzgifMKsPof-z0b8t0KBCAVT2Daysya-XMq_XevANOR25ElRFJwpTN-p512Ltw8H2tb/exec"); //Specify the URL and certificate
    int code = http.GET();
  
  if (code > 0) { //Check for the returning code
 
        String payload = http.getString();
        DeserializationError error = deserializeJson(doc, payload);

  // Test if parsing succeeds.
  if (error) {
        Serial.println(F("DeserializeJson() failed:"));
        Serial.println(error.f_str());
        return;
  }
        Serial.println(payload);
        Serial.println(Status);
      }
 
    else {
      Serial.println("Error on HTTP request");
    }
 
    http.end(); //Free the resources
  delay(10000);
}
  
}
 
void loop() {

}
  • Google Script:
1 Like

Sorry I carelessly entered twice :frowning:
Here is the continued post:
Link to Google Script code (pastebin): //Global variablesvar SID = '1M1ek4w_iQ-GefiwX2FwBc_O4Dh0T65ZzlKzc487calA';v - Pastebin.com
And here is the console output:

[W][HTTPClient.cpp:251] beginInternal(): unexpected protocol: https, expected http
[D][HTTPClient.cpp:287] beginInternal(): host: script.google.com port: 443 url: /macros/s/AKfycbzgifMKsPof-z0b8t0KBCAVT2Daysya-XMq_XevANOR25ElRFJwpTN-p512Ltw8H2tb/exec
[D][HTTPClient.cpp:573] sendRequest(): request type: 'GET' redirCount: 0

[I][ssl_client.cpp:127] start_ssl_client(): WARNING: Skipping SSL Verification. INSECURE!
[D][HTTPClient.cpp:1119] connect():  connected to script.google.com:443
[D][HTTPClient.cpp:1251] handleHeaderResponse(): code: 302
[D][HTTPClient.cpp:1258] handleHeaderResponse(): Transfer-Encoding: chunked
[D][HTTPClient.cpp:597] sendRequest(): sendRequest code=302

[D][HTTPClient.cpp:640] sendRequest(): following redirect (dropped to GET/HEAD): 'https://script.googleusercontent.com/macros/echo?user_content_key=IhJFgMdNUFBcASJizblwkCQd5TjfXYgMlOEafmoY2hjtBbgi4mx50uUfa4o7UPOhvDna7wwtaazbcarkWlCvGp1cBZ8tCZIxm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnDduO0GIF9KxAayBRaAjWZUqeKCmm8iwgRkoaKBuTcHonn4jW9a3MFoRXQYjDdalnIwvL1ctCQ0nPdef1M5ojJePCQQwhEhfeA&lib=M0uHZZgQZlhrctYVxrpYjsv6P3xwH8FnN' redirCount: 1

[D][HTTPClient.cpp:372] disconnect(): still data in buffer (185), clean up.

[D][HTTPClient.cpp:379] disconnect(): tcp keep open for reuse

[D][HTTPClient.cpp:281] beginInternal(): switching host from 'script.google.com' to 'script.googleusercontent.com'. disconnecting first
[D][HTTPClient.cpp:381] disconnect(): tcp stop

[D][HTTPClient.cpp:287] beginInternal(): host: script.googleusercontent.com port: 443 url: /macros/echo?user_content_key=IhJFgMdNUFBcASJizblwkCQd5TjfXYgMlOEafmoY2hjtBbgi4mx50uUfa4o7UPOhvDna7wwtaazbcarkWlCvGp1cBZ8tCZIxm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnDduO0GIF9KxAayBRaAjWZUqeKCmm8iwgRkoaKBuTcHonn4jW9a3MFoRXQYjDdalnIwvL1ctCQ0nPdef1M5ojJePCQQwhEhfeA&lib=M0uHZZgQZlhrctYVxrpYjsv6P3xwH8FnN
[D][HTTPClient.cpp:573] sendRequest(): request type: 'GET' redirCount: 1

Guru Meditation Error: Core  1 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x00000000  PS      : 0x00060e30  A0      : 0x800d4bcf  A1      : 0x3ffb1d70  
A2      : 0x3ffb1efc  A3      : 0x00000000  A4      : 0x3ffb8214  A5      : 0x00000000  
A6      : 0x00000000  A7      : 0xffffffb4  A8      : 0x801851c5  A9      : 0x3ffb1d30  
A10     : 0x3ffccd58  A11     : 0x3ffccd58  A12     : 0x00000000  A13     : 0x00000001  
A14     : 0x00060020  A15     : 0x00000000  SAR     : 0x00000004  EXCCAUSE: 0x00000014  
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffffe  

ELF file SHA256: 0000000000000000

Backtrace: 0x00000000:0x3ffb1d70 0x400d4bcc:0x3ffb1d90 0x400d4dfe:0x3ffb1dd0 0x400d5017:0x3ffb1e30 0x400d1c4a:0x3ffb1e50 0x400d8042:0x3ffb1fb0 0x400897da:0x3ffb1fd0

I encounterd a very strange Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled.
Which after some investigation, seemed to be due to memory access violation, however i didn't utilised any advanced code and pretty much all derived from what I read on the Internet. I don't really have the adequate background to tell what is amiss so I'd like to ask for help from people more knowledgeable on these matters.
Thanks in advance!

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