1

I am trying to control esp8266 esp 01 with Alexa

This is my code:

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"

#define ssid "admin"
#define pass "admin0000"

#define device1 "arduino"

fauxmoESP fauxmo; 

void wifi() 
{
  WiFi.mode(WIFI_STA);

  WiFi.begin(ssid,pass);
  while (WiFi.status() != WL_CONNECTED) 
  {
    Serial.print("not connected\n");
    delay(100);
  }
    Serial.print("1");    
      
}

void setup() 
{
  Serial.begin(115200);
  wifi();
  fauxmo.createServer(true);
  fauxmo.addDevice(device1);
  Serial.print("device added\n");
    fauxmo.setPort(80);
   fauxmo.enable(true);
  
  fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
  Serial.printf("[MAIN](%s) state: %s\n",device_name, state ? "ON" : "OFF");
    if (strcmp(device_name, device1) == 0)
    {
      if (state)
        Serial.print("3");
      else
        Serial.print("2");
    }
    
  });
}

void loop() 
{
  fauxmo.handle();
}

And I am getting an error after 10 - 20 sec

ets Jan  8 2013,rst cause:4, boot mode:(1,7)

wdt reset

Anyone please help me to solve this issue

6
  • Looks like a watchdog timer reset. You could try to "feed" the watchdog by adding a yield(); command inside loop();, for example.
    – StarCat
    Feb 17 at 8:25
  • you have io 0 LOW so on watchdog reset the exp8266 goes into flashing mode
    – Juraj
    Feb 17 at 15:44
  • @StarCat adding a yield() call to that loop() won't do anything. loop() has an implicit yield() when it returns. Give that there's only one line of code inside loop(), adding a yield() would be pointless.
    – romkey
    Feb 19 at 2:40
  • @romkey correct, but there’s still a watchdog timeout.
    – StarCat
    Feb 19 at 6:30
  • @StarCat yes but adding a yield() as you suggested won't fix that in this case - there's already an implicit yield() as soon as loop() returns. It already happens, and doesn't solve the timeout.
    – romkey
    Feb 19 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.