Go Down

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

kondenado

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

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?)



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

wdt reset
http://arduino-esp8266.readthedocs.io/en/latest/boards.html#boot-messages-and-modes

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).

Quote
/* 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 */

//Libraries
#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


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

void setup()
{
  pinMode(PRPOWER,OUTPUT);
  pinMode(PRREAD,INPUT);
  pinMode(DHTPOWER,OUTPUT);
  pinMode(DHTGROUND,OUTPUT);
  digitalWrite(DHTPOWER,HIGH);
  digitalWrite(PRPOWER,HIGH);
  digitalWrite(DHTGROUND,LOW);
//  pinMode(WIFIOKPIN,OUTPUT);
//  digitalWrite(WIFIOKPIN,LOW);
  Serial.begin(9600);
  Serial.print("aaaa");//Test, if the core arrives here, i shoudl see this at arudino ide)
  dht.begin();
  //WiFi.mode(WIFI_STA);
  //WiFi.begin(ssid, password);

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

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


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(hum);
    Serial.print(" %, Temp: ");
    Serial.print(temp);
    Serial.print(" Celsius");
    Serial.print(" %, light: ");
    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);
   
    Serial.println(hum);
    Serial.println(temp);
    Serial.println(light);
 
    enviar_tweet(hum, temp, light);
    ejecutado = true;
  }
  */

 
/*void enviar_tweet(float hum, float temp, int light)
{
  // Cerramos cualquier conexión anterior
  if (client.connected())
  {
    client.stop();
  }
 
  // Esperamos hasta que se hayan enviado todos los datos
  client.flush();
 
  // 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";
 
    client.print(toSend);
  }
 
  // Esperamos hasta que se hayan enviado todos los datos
  client.flush();
  // Desconectamos del cliente
  client.stop();
}
*/

kondenado

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

PieterP

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.

Pieter

kondenado

Thanks for the suggestions Pieter!

I will look at them.

kondenado

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.

emhagman

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