This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to send message to esp32 to change pin state
#5
Well after some more testing I have an issue?
When the device is powered via USB it will run for days.
But when i use 12V power it crashes after about 12 hrs.
I checked the power supply, buck converter all seem well in spec range.
I turned debug on in the Arduino IDE and I am getting this error. every time i use the getLight function.
setting the timeout has no effect.
Code:
[E][WiFiClient.cpp:236] setSocketOption(): 1006 : 9
0x1006 is defined as

Code:
#define SO_RCVTIMEO 0x1006 /* receive timeout */
I dont know if this is my issue but it is the only error coming out of Debug.
The request is working and i get data back.

Here is the code i use.

Code:
void getlight()
{
 uint16_t time = millis();
 static uint16_t last_time;
 uint16_t dt = time - last_time;

 if (dt >= 1000) { // output every 1s
   last_time += 1000;
   if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status
     HTTPClient http;
     //http.setTimeout(10000);
     http.begin("http://192.168.1.7:3000/signalk/v1/api/vessels/self/sensors/anchorLight"); //Specify the URL
     int httpCode = http.GET();
     
     //Make the request
     if (httpCode > 0) { //Check for the returning code
       String payload = http.getString();
       StaticJsonBuffer<500> jsonBuffer;
       JsonObject& root = jsonBuffer.parseObject(payload);
       int code = root["value"];
       http.end(); //Free the resources
       if (code == 1) {
         digitalWrite (ALT_PIN, HIGH);  // turn on the LED
       } else if  (code == 0) {
         digitalWrite (ALT_PIN, LOW);  // turn off the LED
       } else {
         Serial.println("Fail");
       }
       
       return;
     } else {
       Serial.println("get http failed");
     }
     
   } else {
     Serial.println("Error on HTTP request");
   }

 }
 
}
Reply


Messages In This Thread
RE: Best way to send message to esp32 to change pin state - by ddelorme - 2018-12-18, 02:27 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)