/**************************************************************************/ // DMX input test with serial enabled causes hang and WDT reset // on esp8266 arduino v2.4.0+ but not v2.3.0 and earlier. /**************************************************************************/ #include #include #define LED_PIN D5 int got_dmx = 0; #define CRASH true //This causes WDT reset in esp8266 arduino v2.4 void setup() { WiFi.forceSleepBegin(); //not using WiFi, sleep to prevent background activity #if CRASH Serial.begin(250000); //This causes WDT reset in esp8266 arduino v2.4 #endif pinMode(LED_PIN, OUTPUT); pinMode(D0, OUTPUT); digitalWrite(D0, LOW); //_RE receiver enable pin, set low to receive ESP8266DMX.setDataReceivedCallback(&gotDMXCallback); delay(1000); //avoid boot print?? ESP8266DMX.startInput(); } void gotDMXCallback(int slots) { got_dmx = slots; } void loop() { if ( got_dmx ) { //ESP8266 PWM is 10bit 0-1024 analogWrite(LED_PIN,2*ESP8266DMX.getSlot(1)); } else { digitalWrite(LED_PIN, !digitalRead(LED_PIN)); delay(20); } }