Hi guys,
I have a problem connecting to google sheets. What happens is the ESP connects and sends two readings to the sheet. It does this a few times and then suddenly says "connection failed" and then stops. After this the only way to restore the connection is to reset the ESP manually. Do you guys have any idea what might cause this?
I've thought that it might be that the ESP is sending data faster than googlesheets can handle the data and then it loses connection, so I've implemented delays etc. but this still doesn't work.
I'll post the method below that I use to send the data, thank you.
void sendData(int tem, int hum)
{
Serial.print("connecting to ");
Serial.println(host);
delay(1500);
if (!client.connect(host, httpsPort)) {
Serial.println("connection failed");
}
if (client.verify(fingerprint, host)) {
Serial.println("certificate matches");
} else {
Serial.println("certificate doesn't match");
}
String string_temperature = String(tem, DEC);
String string_humidity = String(hum, DEC);
String url = "/macros/s/" + GAS_ID + "/exec?temperature=" + string_temperature + "&humidity=" + string_humidity;
Serial.print("requesting URL: ");
Serial.println(url);
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"User-Agent: BuildFailureDetectorESP32\r\n" +
"Connection: close\r\n\r\n");
delay(2000);
}