@Blackfin so yes as we suspected with that commented out it works just fine. So how can i go about setting it up so i can send the on off signal and timer together?
Do you see any of this on the monitor?
if(httpResponseCode > 0){
String response = http.getString();
Serial.println(httpResponseCode);
Serial.println(response);
} else {
Serial.print("Error on sending PUT Request: ");
Serial.println(httpResponseCode);
}
If you do, put a Serial. print(); after the http.end(); call.
-jim lee
You could try modifying switchLight() by adding a check for a valid WiFi connection before sending HTML stuff:
void switchLight(byte room, bool current_state)
{
state = current_state;
HTTPClient http;
if( WiFi.status()== WL_CONNECTED )
{
String req_string;
req_string = "http://";
req_string += ip;
req_string += "/api/";
req_string += user_name;
req_string += "/lights/";
req_string += light_id;
req_string += "/state";
Serial.println(req_string);
http.begin(req_string);
http.addHeader("Content-Type", "text/plain");
String put_string;
put_string = "{\"on\":";
put_string += (current_state)? "true" : "false";
put_string += "}";
int httpResponseCode = http.PUT(put_string);
if(httpResponseCode > 0)
{
String response = http.getString();
Serial.println(httpResponseCode);
Serial.println(response);
}
else
{
Serial.print("Error on sending PUT Request: ");
Serial.println(httpResponseCode);
}
http.end();
}//if
else
{
Serial.println( "Error: WiFi connection down." );
}//else
}//switchLight
@Jimlee yes i was seeing that i put the print statement it went away however light will still not turn off
@Blackfin still no luck with that either
omg you guys are never going to believe this so i was like we have tried everything else let me try downgrading the esp package to an older version maybe its a bug i downgraded and now its flawless works perfect
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.