I am new in here and also quite new with programming. The issue I have is the following:
I start a simple rotational measurement and try to write the measured data (rpm) to pushingbox and further to my google sheet (all 10 revs.). I have a display, showing me the right rpm values and it works . Also a small testing porgram worked to write data to my google sheet, but with static values.
So here it goes:
after 10 revolutions, a program is started to write the measure and calculated rpm value to my sheet, and it fails. I have to restart my ESP32. Right when I hit "WiFiClient client;" it goes off and shows an error... I can not post the error message right now sorry... But maybe you guys have an idea what's wrong with my code... Already tried to disable interrupts when writing function is called with "noInterrupts()"....
Using ESP32 Heltec WiFI Lora 32 v2 and Arduino IDE...
Many thanks!
Lareina
- #include "WiFi.h"
- const char WEBSITE[] = "api.pushingbox.com"; //pushingbox API server
- const String devid = "XXXmyIDxxxx"; //device ID from Pushingbox
- const char* MY_SSID = "TestWiFi";
- const char* MY_PWD = "123456890";
- // VARIABLEN ### TEST mit 1 Sensor! ##
- volatile byte cISR_V1;
- unsigned long timeold;
- int iWriteToSheet;
- float fRCVentil_1;
- /* float fRCVentil_2;
- float fRCVentil_3;
- float fRCVentil_4;
- float fRCVentil_5;
- float fRCVentil_6;
- float fRCVentil_7;
- float fRCVentil_8;
- float fRCVentil_9;
- float fRCVentil_10;
- float fRCVentil_11;
- float fRCVentil_12; */
- void setup()
- {
- Serial.begin(115200); //baud rate
- Serial.print("Connecting to "+*MY_SSID);
- WiFi.begin(MY_SSID, MY_PWD);
- Serial.println("going into wl connect");
- while (WiFi.status() != WL_CONNECTED) //not connected,..waiting to connect
- {
- delay(1000);
- Serial.print(".");
- }
- Serial.println("connected to "+*MY_SSID);
- Serial.println("");
- Serial.println("Credentials accepted! Connected to wifi\n ");
- Serial.println("");
- // INTERRUPT
- attachInterrupt(digitalPinToInterrupt(36), ISR_V1, FALLING); //attachInterrupt(digitalPinToInterrupt(pin), ISR, mode)
- int cISR_V1 = 0; // counter Ventil1
- }
- // ##################### ISR #################################
- void ISR_V1()
- {
- cISR_V1++;
- }
- // ##################### LOOP #################################
- void loop()
- {
- //delay(10000);
- if(cISR_V1 >= 1) {
- fRCVentil_1 = 60*1000/(millis() - timeold)*cISR_V1;
- timeold = millis();
- cISR_V1 = 0;
- iWriteToSheet++;
- }
- //Print @ 115200 Baud
- Serial.print("RCV1: ");
- Serial.print(fRCVentil_1);
- // Serial.print(" %\t");
- /* Serial.print("Temperature in Cel: ");
- Serial.print(celData);
- Serial.print(" *C ");
- Serial.print("Temperature in Fehr: ");
- Serial.print(fehrData);
- Serial.print(" *F\t");
- Serial.print("Heat index in Cel: ");
- Serial.print(hicData);
- Serial.print(" *C ");
- Serial.print("Heat index in Fehr: ");
- Serial.print(hifData);
- Serial.print(" *F\n"); */
- WiFiClient client; // Initialize the client library
- //Start or API service using our WiFi Client through PushingBox
- if(iWriteToSheet >= 100){
- if (client.connect(WEBSITE, 80))
- {
- client.print("GET /pushingbox?devid=" + devid
- + "&fRCVentil_1=" + (String) fRCVentil_1
- /* + "&celData=" + (String) celData
- + "&fehrData=" + (String) fehrData
- + "&hicData=" + (String) hicData
- + "&hifData=" + (String) hifData */
- );
- client.println(" HTTP/1.1");
- client.print("Host: ");
- client.println(WEBSITE);
- client.println("User-Agent: ESP32/1.0");
- client.println("Connection: close");
- client.println();
- }
- iWriteToSheet = 0;
- }
- }