BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

[SOLVED] ESP8266 NodeMCU V1.0 and wdt resets

#1

Hi All. This post is for ask if somebody has problemes with watchdog timer in ESP8266 when use Blynk library. I only use another library, SimpleTimer. Sometimes the sketchs works perfectly for long time, but if I do a small modification it will start a secuence of whatchdog resets. Return for the first sketch is not the solution. I think is not a power problem. My suspect is watchdog but there isn’t information about it. Are there somebody with the same problem?
Thanks.
Jaume Nogues
rPrim Tech School

0 Likes

#2

hi Jaume, sorry but without seeing your sketch we may as well take up jobs as clairvoyants?

0 Likes

#3

Here is my code with resets. I need put ESP.wdtEnable(WDTO_8S);?

#define BLYNK_PRINT Serial 
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h> // here is the SimpleTimer library

char auth[] = "myToken";

void setup()
{
  Serial.begin(115200);
  Serial.println("Start..");
  Blynk.begin(auth, "ssid", "pass");//servidor Blynk
}

void loop()
{
  Blynk.run();

}

0 Likes

#4

where is the rest of your code?

0 Likes

#5

This sketch works for control an output with a button. I think than the sketch or blynk library are not the problem.
But if I play with other sketchs and I return to this sketch it starts to resets by wdt. Sometimes if I add a ESP.wdtEnable function the problem is solved, but sometimes no. I tested in 4 diferents boards. I think is a wdt configuration problem but I can’t find god information about the use of wdt. I ask to the community if you are using simple sketchs working fine, without resets problems. I’m shure. Is not a power supply problem.
If somebody could share a 100% free errors sample sketch I’m agree.
But I would like if another blynkers has the same problem with nodeMCU or others ESP boards.

0 Likes

#6

OK, so the rest of the code is a secret? no worries…

FYI - i have seven different Blynk/ESP8266 projects with many 1000’s of lines of code and no wdt reset issues.

0 Likes

#7

NO! No secrets! Here is all my code.

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example runs directly on ESP8266 chip.
 *
 * You need to install this for ESP8266 development:
 *   https://github.com/esp8266/Arduino
 *
 * Please be sure to select the right ESP8266 module
 * in the Tools -> Board menu!
 *
 * Change WiFi ssid, pass, and Blynk auth token to run :)
 *
 **************************************************************/

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h> // here is the SimpleTimer library
#include <DHT.h>  //adafruit
#include <Adafruit_NeoPixel.h>
#include <Servo.h>
#define PIN 10
#define NUMPIXELS 8
#define DHTPIN 9
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE, 15);
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Servo myservo;  // create servo object to control a servo
SimpleTimer timer; // Create a Timer object called "timer"! 

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
   char auth[] = "myToken";

boolean state4=0;
boolean state5=0;
boolean state16=0;
boolean state14=0;
boolean state12=0;
boolean prevState14=0;
boolean prevState12=0;
boolean prevState4=0;
boolean prevState5=0;
int dimmer=0;
int red=0;
int green=0;
int blue=0;
byte servoPosition=90;
int clicks=0;

void setup()
{
   Serial.begin(115200);
  Serial.println("Comencem..");
  Blynk.begin(auth, "SSID, "pass");
  pinMode(5, INPUT);
  pinMode(4, INPUT);
  pinMode(14, INPUT);
  pinMode(12, INPUT);
  pinMode(0,OUTPUT);
  pinMode(2,OUTPUT);
  pinMode(13,OUTPUT);
  pinMode(15,OUTPUT);
  pinMode(16,OUTPUT);//blue led onboard
  digitalWrite(0,HIGH);
  digitalWrite(2,HIGH);
  digitalWrite(13,LOW);
  digitalWrite(15,LOW);
  digitalWrite(16,HIGH);
  timer.setInterval(300L, alive);
  timer.setInterval(60000L, publishMillis);
  timer.setInterval(60000L, readDHT);
  timer.setInterval(10000L, refreshA0);
  pixels.begin(); // This initializes the NeoPixel library.
  pixels.show(); // Initialize all pixels to 'off'
  myservo.attach(13);
  myservo.write(servoPosition);
 
}

void loop()
{
  Blynk.run();
  timer.run(); // SimpleTimer is working
}

void alive()
{
  digitalWrite(16,state16);
  state16=!state16;
  
  state14=digitalRead(14);
  if (prevState14==0 && state14==1)
  {
    bool temp=digitalRead(15);
    if (temp){ digitalWrite(15,LOW); Blynk.virtualWrite(V13,0);}
    if (!temp){ digitalWrite(15,HIGH); Blynk.virtualWrite(V13,255);}
    prevState14=1;
  }
  if (prevState14==1 && state14==0)
  {
    prevState14=0;
  }

  state4=digitalRead(4);
  if (state4!=prevState4)
  {
    if (state4==0) Blynk.virtualWrite(V4,0);
    if (state4==1) Blynk.virtualWrite(V4,255);
    clicks=clicks+1;
    Blynk.virtualWrite(V21,clicks);
  }
  prevState4=state4;

  state5=digitalRead(5);
  if (state5!=prevState5)
  {
    if (state5==0) Blynk.virtualWrite(V5,0);
    if (state5==1) Blynk.virtualWrite(V5,255);
  }
  prevState5=state5;

  state12=digitalRead(12);
  if (state12!=prevState12)
  {
    if (state12==0) Blynk.virtualWrite(V20,0);
    if (state12==1) Blynk.virtualWrite(V20,255);
  }
  prevState12=state12;

  
}

void publishMillis()
{
   unsigned long m=millis()/60000L;
   Blynk.virtualWrite(V15,m);
   Serial.println(m);
}

void readDHT()
{
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
  Serial.println("Failed to read from DHT sensor!");
  return;
  }
  
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.print(" ºC ");
  Blynk.virtualWrite(V10,t);
  Blynk.virtualWrite(V11,h);    
  
}

void refreshA0()
{
  Blynk.virtualWrite(V0, analogRead(0));
}

BLYNK_WRITE(V12) 
{
  int i = param.asInt();
  boolean kk=digitalRead(15);
  if (i==1 && kk==0) {digitalWrite(15,HIGH);  Blynk.virtualWrite(V13,255);}
  if (i==1 && kk==1) {digitalWrite(15,LOW);   Blynk.virtualWrite(V13,0);}
}

BLYNK_WRITE(V16)
{
  dimmer = param[0].asInt();
  Serial.println(dimmer);
  for(int i=0;i<NUMPIXELS;i++)
  {
    pixels.setPixelColor(i, pixels.Color(red*dimmer/100,green*dimmer/100,blue*dimmer/100));
    pixels.show();
  }
}

BLYNK_WRITE(V17)
{
  red = param[0].asInt();
  green = param[1].asInt();
  blue = param[2].asInt();
  //red=(red*dimmer)/100; green=(green*dimmer)/100; blue=(blue*dimmer)/100;
  for(int i=0;i<NUMPIXELS;i++)
  {
    pixels.setPixelColor(i, pixels.Color(red*dimmer/100,green*dimmer/100,blue*dimmer/100));
    pixels.show();
  }
}

BLYNK_WRITE(V14)
{
  servoPosition = param[0].asInt();
  myservo.write(servoPosition);
}

BLYNK_CONNECTED() {
  
  Blynk.syncAll();
  Serial.println(".");
}
0 Likes

#8

running alive every 300 milliseconds?

you might need to look up “flooding”

0 Likes

#9

Alive only check real buttons in the board and toggle a onboard led. If there isn’t changes no communication with server.
This sketchs sometimes works for weeks!. But If I play with wdt when I return to this sketch don’t work!! I want understand why. Why the same robust sketch stops to be robust.

0 Likes

#10

i have no idea what this means?

0 Likes

#11

If I load another no blynk sketch with wdt funciona and later return to a blynk sketch it don’t work.

0 Likes

#12

wow, that sounds really weird!!

i actually only use ESP8266-12’s not NodeMCU…

0 Likes

#13

Solved!! If I add in setup()

ESP.wdtDisable();
ESP.wdtEnable(WDTO_8S);

and in loop()

ESP.wdtFeed();

The resets by whatchdog STOPS!!

4 Likes

#14

That’s super! Well done!

I’m sure that’s going to help others too…

0 Likes

#15

Thaks a lot, man!! Honestly, I dont know what it does, but it definitely saved my life. Thanks again!

0 Likes

#16

Thank you, saved me a lot of agony.

0 Likes

#18

Hey guys I have added give code to setup and loop but still I get error in serial terminaly :

Connecting to Tenda_5F19A8

Soft WDT reset

ctx: cont
sp: 3ffef4e0 end: 3ffef6f0 offset: 01b
stack>>>
3ffef6a0: 3ffefffc 402020a8 3ffee608 3ffee6c4
3ffef6b0: 3ffe8350 3ffee514 3ffee608 40201c8f
3ffef6c0: feefeffe feefeffe feefeffe feefeffe
3ffef6d0: 3fffdad0 00000000 3ffee6bc 40203390
3ffef6e0: feefeffe feefeffe 3ffee6d0 40100718
stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(3,2)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld

Please help me.
Thank you…

0 Likes

#19

I solved my resets without using gpio9 and gpio10 in my nodeMCU.

Jaume

1 Like

closed #20

@Hemang_Joshi If you still need assistance, please create a new topic with details of your specific issue, thank you.

0 Likes