Go Down

Topic: ESP8266 (D1 mini) watchdog reset problem (Read 1 time) previous topic - next topic


Aug 23, 2017, 07:00 pm Last Edit: Aug 24, 2017, 09:54 am by kondenado

Long history short, I am trying to set up an ESP8266 based chip, a D1 mini. It should send the temperature, humidity and light data so - in the future, i could accordingly dim the heater and dimmable lights.

I settled everything in the board, the temp/humidity sensor, the photoresistor, and a led to tell me when it succeeds connecting to wifi.

But I didn't manage to make this working.

So I remove everything from the board, and I commented unnecessary lines (*) from my code, and I got this error message. With unnecessary lines I meant everything related to WiFi, i mean i just want to get the signal/data in the Arduino IDE and once this is correct i will figure out about WiFi connection; step by step.

(I did NOT have this board connect to anything, just to my computer via mini USB. The esp needs 3.3 v and apparently, this board can supply it from the USB cable - afaik - (am I wrong?)

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

wdt reset

rst cause 4 ---> watchdog
boot mode
3   0V   3.3V   3.3V   Flash
6   3.3V   3.3V   0V   SDIO

my code: (its mostly copy-pasted from different sources and afterwards modified).

/* How to use the DHT-22 sensor with Arduino uno
   Temperature and humidity sensor
   More info: http://www.ardumotive.com/how-to-use-dht-22-sensor-en.html
   Dev: Michalis Vasilakis // Date: 1/7/2015 // www.ardumotive.com */

#include <DHT.h>
//#include <ESP8266WiFi.h>
//#include <ESP8266WiFiMulti.h>

//Constants (the pins where the sensors will be connected)
#define DHTPIN 6     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
#define DHTPOWER 5
#define DHTGROUND 7
#define PRPOWER 8
#define PRREAD 2
#define PRGROUND 1
//#define WIFIOKPIN 4
//#define HOSTIFTTT "maker.ifttt.com"
//#define EVENTO "enviar_tweet"
//#define IFTTTKEY "c59f1gEzJCimUDM8ouBGj"

//ESP8266WiFiMulti WiFiMulti;
//Utilizamos la conexión SSL del ESP8266
//WiFiClientSecure client;
// Variable que permite ejecutar una sola vez la función
//bool ejecutado = false;

//const char* ssid     = "NET";
//const char* password = "vas";
//const char* ssid     = "HUAWEI";
//const char* password = "FQEE";
//const char* host = MY_HOST;
//const char* hostIP = MY_HOSTIP;
//int status = WL_IDLE_STATUS;
//WiFiServer server(80);//Service Port

//DHT function, neccesary to get the one of teh sensors working.
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino

int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value
int light; //Stores light intensity value

void setup()
//  digitalWrite(WIFIOKPIN,LOW);
  Serial.print("aaaa");//Test, if the core arrives here, i shoudl see this at arudino ide)
  //WiFi.begin(ssid, password);

   // Conectamos a la red WiFi
 //WiFiMulti.addAP(ssid, password);

 Serial.print("Eperando a conectar a la WiFi... ");
/* while (WiFiMulti.run() != WL_CONNECTED)
 Serial.println("WiFi conectada");
 Serial.println("Direccion IP: ");
// Serial.println(WiFi.localIP());
// digitalWrite(WIFIOKPIN,HIGH);

void loop()
    //Read data and store it to variables hum and temp
    hum = dht.readHumidity();
    temp= dht.readTemperature();
    light = analogRead(PRREAD);
    //Print temp and humidity values to serial monitor
    Serial.print("Humidity: ");
    Serial.print(" %, Temp: ");
    Serial.print(" Celsius");
    Serial.print(" %, light: ");
    Serial.println(" TLIU");
    delay(2000); //Delay 10 sec.
 /*if (!ejecutado)
    // Obtenemos los valores
    float hum = dht.readHumidity();
    float temp= dht.readTemperature();
    int light = analogRead(PRREAD);
    enviar_tweet(hum, temp, light);
    ejecutado = true;

/*void enviar_tweet(float hum, float temp, int light)
  // Cerramos cualquier conexión anterior
  if (client.connected())
  // Esperamos hasta que se hayan enviado todos los datos
  // Hacemos la petición mediante SSL
  if (client.connect(HOSTIFTTT, 443)) {
    // Construimos la petición HTTP
    String toSend = "GET /trigger/";
    toSend += EVENTO;
    toSend += "/with/key/";
    toSend += IFTTTKEY;
    toSend += "?value1=";
    toSend += hum;
    toSend += "&value2=";
    toSend += temp;
    toSend += "&value3=";
    toSend += light;
    toSend += " HTTP/1.1\r\n";
    toSend += "Host: ";
    toSend += HOSTIFTTT;
    toSend += "\r\n";
    toSend += "Connection: close\r\n\r\n";
  // Esperamos hasta que se hayan enviado todos los datos
  // Desconectamos del cliente


(I have just edited the post to add some comments to my code)


Maybe the library enters a while loop that lasts more than 3 or 8 seconds, so the watch dog bites.
What DHT library are you using? Is it compatible with the ESP8266?

Also, you may want to edit your post to delete your passwords, and to put [code][/code] tags around your code instead of quote tags.



Thanks for the suggestions Pieter!

I will look at them.


UPDATE: It wasn't a problem if libraries, I made a new sketch and i started slowly copypasting lines do codes to the new sketch with a serial.print("aaaa") to know wher emy code has reached. It turn out that the problem is in the "pinMode" line of codes and i suspect that it is because i declare 1, 4, 5 instead of D1, D4, D5

I wanted to see if this was the issue, but now i have a compiling error, I will open a new post about this since it is a different error.


I just made an account to say thank you. I also declared a PIN as "7" not "D7" and it was causing the NodeMCU to reset. That fixed it!

Go Up