ESP8266 - sketch stopped working

Hi guys, I’m having trouble with my sketch that I have been using for about a year without any issues on NodemCU 12E and Wemos D1 mini.

This week I wanted to setup new Wemos D1 mini, using Arduino IDE I updated libraries and boards to the latest versions and I started getting wdt reset ( ets Jan 8 2013,rst cause:4, boot mode:(1,6)).

Nothing is connected to the board while this is happening. I have two fully functional devices already up and running. I even tried several wemos and nodemcu boards, all with the same results. It connects to blynk for a few second, I’m able to push some buttons in iOS app but the feedback is incredibly slow (>5s) and it gets disconnected after that.

Using blynk server and ther sketches are working correctly without watchdog resets, including blynk blink.

Thank you for any suggestions! My code is below…

note: the use of serial is there only for “debug”, I’m not using it in live setups…


/*------------------ LIBRARIES ------------------*/
#include <ESP8266WiFi.h>
#include <DHT.h>
#include <BlynkSimpleEsp8266.h>

/*------------------ WIFI AND BLYNK SETTINGS ------------------*/
const char ssid[] = "xxx";
const char pass[] = "xxx";
char auth[] = "";

/*------------------ DEFINE DHT SENSOR PIN ------------------*/
#define SENSOR_IN D6
#define SENSOR_IN_Type DHT22
/*------------------ DEFINE RELAY PINS ------------------*/
#define relayLight D1
#define relayHeat D2
#define relayFan D4 //RX pin on NodeMCU 
#define relayHeat2 D5

/*---------- OTHER ----------*/
float humIN, tempIN;
DHT dht_IN(SENSOR_IN, SENSOR_IN_Type);
SimpleTimer timer;

/*---------- SYNC ALL SETTINGS ON BOOT UP ----------*/
bool isFirstConnect = true;
BLYNK_CONNECTED() {
  if (isFirstConnect) {
    Blynk.syncAll();
    isFirstConnect = false;
  }
}
/*---------- LIGHT CONTROL ----------*/
BLYNK_WRITE(V10)
{
  if (param.asInt()) {
    digitalWrite(D1, HIGH);
    Blynk.virtualWrite(V0, 255);
  } else {
    digitalWrite(D1, LOW);
    Blynk.virtualWrite(V0, 0);
  }
}
/*---------- HEAT CONTROL ----------*/
BLYNK_WRITE(V11)
{
  if (param.asInt()) {
    digitalWrite(D2, HIGH);
    Blynk.virtualWrite(V1, 255);
  } else {
    digitalWrite(D2, LOW);
    Blynk.virtualWrite(V1, 0);
  }
}
/*---------- HEAT2 CONTROL ----------*/
BLYNK_WRITE(V12)
{
  if (param.asInt()) {
    digitalWrite(D5, LOW);
    Blynk.virtualWrite(V2, 255);
  } else {
    digitalWrite(D5, HIGH);
    Blynk.virtualWrite(V2, 0);
  }
}
/*---------- FAN CONTROL ----------*/
BLYNK_WRITE(V13)
{
  if (param.asInt()) {
    digitalWrite(D4, LOW);
    Blynk.virtualWrite(V3, 255);
  } else {
    digitalWrite(D4, HIGH);
    Blynk.virtualWrite(V3, 0);
  }
}
/*----------READ DHT SENSOR ----------*/
void sensorRead() {
  tempIN = dht_IN.readTemperature();
  humIN = dht_IN.readHumidity();
  Blynk.virtualWrite(V8, tempIN);
  Blynk.virtualWrite(V9, humIN);
}

void setup()
{
   Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  Blynk.notify("Terrarium: Successfully connected to: " + String(ssid));
  Serial.println("Terrarium: Successfully connected to: " + String(ssid));
  pinMode(relayLight, OUTPUT);
  pinMode(relayHeat, OUTPUT);
  pinMode(relayFan, OUTPUT);
  pinMode(relayHeat2, OUTPUT);
  timer.setInterval(1000L, sensorRead);
  
}

void loop()
{
  Blynk.run();
  timer.run();
    Serial.print(tempIN);
  Serial.print(" ");
  Serial.println(humIN);
}

Hi @PraetorianCZ,
As far as I can see, your code is not really complicated, it should work properly, my only suggestios could be remove the serial.prints into the loop and increase the interval from 1 to 2 or 3 seconds for the DHT.

Give it a try…

Hi, thanks for suggestion but I already tried that… The thing is, it is working on my non-updated devices. It stopped working after updating Arduino IDE, boards and libraries, so I think the problem must be in one or more libraries. Or maybe in the board setting as there is lots of new setting. I’m always using defaults with baud rate 115200

This shows that you have ESP timing issues… perhaps the prior ESP Core and even past Blynk libraries may have been more 'forgiving" of your coding practices… but now that more is happening each update, you have apparently tipped over the line.

Try the suggestions above (if you already did, then why post the worst of the coding options?) and keep reading other references about the need for proper timing and code structure in the IoT WiFi world…