noiasca
November 27, 2023, 4:13pm
21
connect the 5 DHT to ESP pins, and use a 16 channel port expander for the relays.
georgepa:
I have played with the delays and I managed to make it to work. I have put on the Mega a 2s delay between sends and on the ESP32 a 1s delay between sends of the URL.
Now I have a different problem. It seems that the data is not reach to the Google Sheets. If I copy the URL from the serial monitor and paste it in a browser this way it works.
Here is the code that I'm running now:
Pachet = String(Serial2.readString());
if( (millis() - TimpGoogleSheetsTU) >= IntervalGoogleSheetsTU){
TimpGoogleSheetsTU = millis();
urlTU += "https://script.google.com/macros/s/";
urlTU += "xxx";
urlTU += "/exec?";
//urlTU += "Magazie_IN_T=NAN";
urlTU += Pachet;
Serial.println(urlTU);
HTTPClient httpTU;
httpTU.begin(urlTU);
int httpResponseCode2 = httpTU.GET();
urlTU = "";
}
But if I comment the "urlTU += Pachet;" part and uncomment the "urlTU += "Magazie_IN_T=NAN";" then it sends the "NAN" to the google sheets.
Also I have noticed that when I add the "urlTU += Pachet;" in the serial monitor I get the string plus a blank line:
17:02:01.055 -> https://script.google.com/macros/s/xxx/exec?Magazie_IN_T=23.80
17:02:01.055 ->
17:02:03.072 -> https://script.google.com/macros/s/xxx/exec?Magazie_IN_T=23.80
17:02:03.072 ->
17:02:05.091 -> https://script.google.com/macros/s/xxx/exec?Magazie_IN_T=23.80
17:02:05.091 ->
17:02:07.114 -> https://script.google.com/macros/s/xxx/exec?Magazie_IN_T=23.80
17:02:07.114 ->
blank line that is not present if I add the "urlTU += "Magazie_IN_T=NAN";"
17:06:20.839 -> https://script.google.com/macros/s/xxx/exec?Magazie_IN_T=NAN
17:06:24.856 -> https://script.google.com/macros/s/xxx/exec?Magazie_IN_T=NAN
17:06:28.872 -> https://script.google.com/macros/s/xxx/exec?Magazie_IN_T=NAN
17:06:32.913 -> https://script.google.com/macros/s/xxx/exec?Magazie_IN_T=NAN
17:06:36.946 -> https://script.google.com/macros/s/xxx/exec?Magazie_IN_T=NAN
17:06:40.979 -> https://script.google.com/macros/s/xxx/exec?Magazie_IN_T=NAN
I have managed to find out why when I use the line of code "urlTU += Pachet;" it did not send the URL. Apparently there were some empty spaces that were transmitted. I used the trim() function and now it works fine.