sinricpro / esp8266-esp32-sdk

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
https://sinric.pro
Other
234 stars 124 forks source link

ESP8266 disconnects continuously #186

Closed samiron7567 closed 3 years ago

samiron7567 commented 3 years ago

Hello, Please help me fix this issue. I am working on a project that can onoff or change color of my WS2812B LED strip. My Wemos D1 Mini has other integration like Blynk, Web Server or AutoConnect that is working perfectly. But only SinricPro is experiencing issue. Initially it was working for a day and after that I am not able to connect to sinric pro anymore.

I used simple sinricpro swith example with my Wemos D1 Mini. However to debug this issue I updated my code with only minimal settings that is required to establish connection. Please let me know if I missed anything. There is no internet related issue as Blynk is accepting connection on same setup.

[WS-Client] connection to ws.sinric.pro:443 Failed
[WS-Client] client disconnected.
[WS-Client] connect wss...
[WS-Client] connection to ws.sinric.pro:443 Failed
[WS-Client] client disconnected.
[WS-Client] connect wss...
[WS-Client] connection to ws.sinric.pro:443 Failed
[WS-Client] client disconnected.
[WS-Client] connect wss...
[WS-Client] connection to ws.sinric.pro:443 Failed
[WS-Client] client disconnected.

Here is the code:

#include <SinricPro.h>
#include <SinricProLight.h>

#define APP_KEY     "xxx"
#define APP_SECRET  "xxxx"
#define LIGHT_ID    "xxx"

bool onColor(const String &deviceId, byte &r, byte &g, byte &b) {
  Serial.printf("Device %s color is set to red=%d, green=%d, blue=%d, %s\r\n", deviceId.c_str(), r, g, b);
  fill_solid(leds, LED_NUMBER, CRGB(r, g, b));
  FastLED.show();
  return true; // request handled properly
}

void setupSinricPro() {

  // get a new Light device from SinricPro
  SinricProLight& espLight = SinricPro[LIGHT_ID];
  SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); });
  SinricPro.restoreDeviceStates(true);
  SinricPro.begin(APP_KEY, APP_SECRET);
}

void setup(void) {
  setupSinricPro();
  WiFi.mode(WIFI_STA);
}

void loop(void) {
  SinricPro.handle();
  if (WiFi.status() == WL_IDLE_STATUS) {
    ESP.reset();
    delay(1000);
  }
}
sivar2311 commented 3 years ago

No WiFi setup, -> No internet connection -> No sinric Pro connection

samiron7567 commented 3 years ago

Yes the WIFi setup is there. I have not hardcoded my WiFi SSID. Thats taken care by AutoConnect. As I said, the same ESP board is serving Blynk, AutoConnect Web, Local API server currently. there is no question on connectivity to the Internet.

sivar2311 commented 3 years ago

Please provide the full sketch (without your wifi / sinric pro credentials) because you edited the sketch in the first comment. This is confusing.

sivar2311 commented 3 years ago

Sidenote: You missed to assing the onColor callback to the espLight: espLight.onColor(onColor);

sivar2311 commented 3 years ago

Thats taken care by AutoConnect

I cannot see any AutoConnect setup here

samiron7567 commented 3 years ago

Thank you very much @sivar2311 . I figured it out just now. Looks like the installed module was corrupted for some reason. a clean arduino with required libraries installation resolved this issue.

P.S. I only pasted the required code as the entire code is too long and has nested files included with different roles.