Node MCU ESP8266 Trouble Connecting to WiFi

Hi all,

I have been having trouble connecting my ESP8266 to WiFi. Whenever I run my code with all Blynk portions of the code commented, the code runs normally with an expected response in the serial monitor.

However, whenever I run the full code, I see the following in the serial monitor instead being printed out repeatedly. The code appears to be getting stuck at Blynk.begin based on the print statement output (full code is at bottom of this post)

[251556] Connecting to blynk.cloud:8080

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Soft WDT reset

Exception (4):
epc1=0x4000dcf0 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffde0 end: 3fffffd0 offset: 0160
3fffff40:  0003e20d 0003e20d 00000000 0003d69d  
3fffff50:  00000000 00000000 00000000 40206b06  
3fffff60:  00000000 00000000 3ffef098 40201290  
3fffff70:  00000000 000000bb 3ffef270 0003d69d  
3fffff80:  00000000 3ffef098 3ffef270 40202184  
3fffff90:  4020960c ea0dfea9 feefeffe feefeffe  
3fffffa0:  feefeffe feefeffe feefeffe 3ffef3f8  
3fffffb0:  3fffdad0 00000000 3ffef3cc 4020573c  
3fffffc0:  feefeffe feefeffe 3fffdab0 401018c9  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------
b
�j!!i%!sH�*��{SV�C��!*�ʎ�D�:��
��D�JJ
�oh�o)�C���Nx��Ją�Lp�X
�Q&�@Yh2D*M+�
ą�(D�%dVx@`
SDK:2.2.2-dev(38a443e)/Core:3.1.2=30102000/lwIP:STABLE-2_1_3_RELEASE/glue:1.2-65-g06164fb/BearSSL:b024386
Adafruit MLX90614 test
[82] Connecting to ASUS_ASK_24GHZ
fpm close 1 
mode : sta(48:55:19:df:ea:0c)
add if0
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 5
cnt 

connected with ASUS_ASK_24GHZ, channel 3
dhcp client start...
pm open,type:2 0

I am not sure what is wrong with it, these are my versions for the libraries:
Board: NodeMCU 1.0 (ESP12-E Module)
Boards Manager Version: ESP8266 version 3.1.2
Blynk: 1.2.0
Arduino IDE: 2.1.0

Here is my code below for reference:


/*************************************************************

  You can use this sketch as a debug tool that prints all incoming values
  sent by a widget connected to a Virtual Pin 1 in the Blynk App.

  App dashboard setup:
    Slider widget (0...100) on V1
 *************************************************************/

/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "ABC"
#define BLYNK_TEMPLATE_NAME "ABC"
#define BLYNK_AUTH_TOKEN "ABC"

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ASUS_ASK_24GHZ";
char pass[] = "ABC";
char auth[] = BLYNK_AUTH_TOKEN;

// Set up Temperature sensor
#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

// Set up buzzer (corresponds to D7)
int buzzer = 13;

// Initialize temperatures
float temperature = 0;
int round_temp = 0;

// Initialize for 4 dig display
#include <TM1637.h>

int clk = 14;
int dio = 12;
int8_t bits[4] = {0};
TM1637 tm(clk,dio);


// This function creates the timer object. It's part of Blynk library
BlynkTimer timer;

void myTimer()
{
  // This function describes what will happen with each timer tick
  // e.g. writing sensor value to datastream V5
  Blynk.virtualWrite(V0, round_temp);

}

//// This function will be called every time Slider Widget
//// in Blynk app writes values to the Virtual Pin 1
//BLYNK_WRITE(V1)
//{
//  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
//  // You can also use:
//  // String i = param.asStr();
//  // double d = param.asDouble();
//  Serial.print("V1 Slider value is: ");
//  Serial.println(pinValue);
//}

void setup()
{
  // Debug console
  Serial.begin(57600);

  Serial.println("Adafruit MLX90614 test");

  // 4 digit display
  tm.init();
  tm.set(3);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);


  // Setting interval to send data to Blynk to 1000ms
  // This means that data is sent every second
//  timer.setInterval(1000L, myTimer);

  // Set buzzer as output
  pinMode(buzzer, OUTPUT);

  // Check for MLX error
  if (!mlx.begin()) {
    Serial.println("Error connecting to MLX sensor. Check wiring.");
    while (1);
  };

  Serial.print("Emissivity = "); Serial.println(mlx.readEmissivity());
  Serial.println("================================================");



}

void loop()
{


  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
  Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
  Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");

  temperature = mlx.readObjectTempF();
  round_temp = floor(temperature);
  Serial.print(round_temp);

  if (temperature > 200) {
    Serial.print("HOT!!");
    tone(buzzer, 750, 500);
  }

  memset(bits, 0, 4); 
  bits[0] = 0;
  bits[1] = round_temp / 100;
  bits[2] = (round_temp - (bits[1]*100)) / 10;
  bits[3] = round_temp % 10;
  for(int i = 3; i >= 0; i--){
    tm.display(i, bits[i]); 
  }

  Serial.println();

  // Runs all the Blynk stuff
  Blynk.run();

  //runs BlynkTimer
  timer.run();
}

Thank you for the help!

Are you sure that this is the exact code you used to produce the serial output you posted?
I ask because this is not what I would expect to see…

when using Blynk.begin i this format…

Also, it would be useful to see the serial output for an entire boot cycle rather than just the bit immediately before the exception error followed by part of the next boot cycle. It would also be useful if you changed this:

to a baud rate of either 74880 or 115200 so that your boot messages from the ESP8266 don’t look like this…

Have you tried installing the ESP8266 Exception Decoder and decoding the error?



You can’t have this code in your void loop, it belongs in your myTimer() function…

and you need to un-comment this line from your void setup()

Pete.

1 Like

Thank you so much Mr.Knight, I have implemented your fixes and it is now working!

1 Like