I'm unable to connect nodemcu to blynk

Model of board : ESP8266 with wifi
Blynk library 1.1.0

16631300463601355290154971547575|666x500


#include <SimpleTimer.h>

#include <Blynk.h>
#define BLYNK_TEMPLATE_ID "TMPLJIaI3s4t"
#define BLYNK_DEVICE_NAME "IOT WATER RELEASE"
#define BLYNK_AUTH_TOKEN "H2PuYl3mhwb91kD_Es5-s3iGIWzwWrQy"
#define BLYNK_PRINT Serial   
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
#define BLYNK_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS D2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

char auth[] ="H2PuYl3mhwb91kD_Es5-s3iGIWzwWrQy";               //Authentication code sent by Blynk
char ssid[] = "JioFibe-5G";                       //WiFi SSID
char pass[] = "Poleehan@12$";                       //WiFi Password

#define sensorPin D3 
int sensorState = 0;
int lastState = 0;
#define DHTPIN 2    
#define DHTTYPE DHT11     
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
 
  Blynk.virtualWrite(V5, h);  //V5 is for Humidity
  Blynk.virtualWrite(V6, t);  //V6 is for Temperature
}
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
   pinMode(sensorPin, INPUT);
  dht.begin();

  timer.setInterval(1000L, sendSensor);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
   sensors.begin();
}
int sensor=0;
void sendTemps()
{
sensor=analogRead(A0);
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0); 
Serial.println(temp);
Serial.println(sensor);
Blynk.virtualWrite(V1, temp);
Blynk.virtualWrite(V2,sensor);
delay(1000);
}
void loop()
{
  Blynk.run(); 
  timer.run(); 
  sendTemps();
  sensorState = digitalRead(sensorPin);
Serial.println(sensorState);

if (sensorState == 1 && lastState == 0) {
  Serial.println("needs water, send notification");
  Blynk.notify("Water your plants");
  lastState = 1;
  delay(1000);
//send notification
    
  } 
  else if (sensorState == 1 && lastState == 1) {
    //do nothing, has not been watered yet
  Serial.println("has not been watered yet");
  delay(1000);
  }
  else {
    //st
    Serial.println("does not need water");
    lastState = 0;
    delay(1000);
  }
  
  delay(100);
}

Https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

I’d recommend using BlynkTimer instead.

Must be on the top of your sketch, the first lines.

You should read this article

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

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v000475b0
~ld

It isn’t taking #include <Blynktimer.h>

Blynk Library offers a built-in timer called blynkTimer, you don’t have to include <blynkTimer.h> or anything else.
You can get rid of the #include <SimpleTimer.h>
and replace

SimpleTimer timer;

With

BlynkTimer timer;

I replaced but it didn’t change anything


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

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v000475b0
~ld

Post your updated code. Without looking into your code its hard to assist.




#define BLYNK_TEMPLATE_ID "TMPLJIaI3s4t"
#define BLYNK_DEVICE_NAME "IOT WATER RELEASE"
#define BLYNK_AUTH_TOKEN "H2PuYl3mhwb91kD_Es5-s3iGIWzwWrQy"
#include <SimpleTimer.h>

#include <Blynk.h>

#define BLYNK_PRINT Serial   
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
#define BLYNK_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS D2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

char auth[] ="H2PuYl3mhwb91kD_Es5-s3iGIWzwWrQy";               //Authentication code sent by Blynk
char ssid[] = "JioFibe-5G";                       //WiFi SSID
char pass[] = "Poleehan@12$";                       //WiFi Password

#define sensorPin D3 
int sensorState = 0;
int lastState = 0;
#define DHTPIN 2    
#define DHTTYPE DHT11     
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
 
  Blynk.virtualWrite(V5, h);  //V5 is for Humidity
  Blynk.virtualWrite(V6, t);  //V6 is for Temperature
}
void setup()
{
  Serial.begin(74880);
  Blynk.begin(auth, ssid, pass);
   pinMode(sensorPin, INPUT);
  dht.begin();

  timer.setInterval(1000L, sendSensor);

  Blynk.begin(auth, ssid, pass);
   sensors.begin();
}
int sensor=0;
void sendTemps()
{
sensor=analogRead(A0);
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0); 
Serial.println(temp);
Serial.println(sensor);
Blynk.virtualWrite(V1, temp);
Blynk.virtualWrite(V2,sensor);
delay(1000);
}
void loop()
{
  Blynk.run(); 
  timer.run(); 
  sendTemps();
  sensorState = digitalRead(sensorPin);
Serial.println(sensorState);

if (sensorState == 1 && lastState == 0) {
  Serial.println("needs water, send notification");
  Blynk.notify("Water your plants");
  lastState = 1;
  delay(1000);

    
  } 
  else if (sensorState == 1 && lastState == 1) {
    
  Serial.println("has not been watered yet");
  delay(1000);
  }
  else {
   
    Serial.println("does not need water");
    lastState = 0;
    delay(1000);
  }

}

I am pretty sure that you not taking time to understand what me and @John93 say.

I gave you a link to go through. You have not followed those steps of keeping your void loop clean.

And John said to replace SimpleTimer with BlynkTimer and you have not.

If you do not follow what we say, then its hard to solve your problem.

Your serial monitor shows that when your NodeMCU starts-up, it is going into FLASSH mode rather than RUN mode, this means that your code isn’t executing, because the NodeMCU is waiting for a new sketch to be uploaded to it.
The NodeMCU can’t execute code while it’s waiting for new code to be uploaded, as the two processed would clash with each other.

The reason why this is happening is because you’ve made a bad choice of pins. You’ve chosen to connect one of your sensors to pin D3 (GPIO0) and your sensor is pulling this pin to GND (LOW), so your NodeMCU is entering FLASH mode at startup.

@John93 has already flagged this up, and linked you to an article which explains this…

However, you seem to have ignored that tip.

You are also still including the SimpleTimer library (twice!)…

and you still have a cluttered void loop where you are still calling functions directly using blocking delays, rather than using BlynkTimer to do this in a non-blocking way.

Also, as you are copy/pasting the Blynk Auth token from the web console to the top of your sketch, it makes no sense to manually add it later in your sketch…

I’d suggest that you delete this line, then change this line in your void setup…

to this…

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

so that you are using the token from the top of your sketch.

Pete.

Please don’t mind I am a complete beginner so it’s being difficult for me to understand stuffs

Sir I did what you have said,


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

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v00047a00
~ld
[70] Connecting to JioFibe-5G

this is been shown.
And please help me out with that void loop I’m unable to do it

#define BLYNK_TEMPLATE_ID "TMPLJIaI3s4t"
#define BLYNK_DEVICE_NAME "IOT WATER RELEASE"
#define BLYNK_AUTH_TOKEN "H2PuY13mhwb91kD_Es5-s3iGTWzwWrQy"
#define BLYNK_PRINT Serial   
#include <Blynk.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
#include <DHT.h>
#define BLYNK_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS D2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

char auth[] ="H2PuY13mhwb91kD_Es5s3iGIWzwWrQy";               
char ssid[] = "JioFibe-5G";                       
char pass[] = "Poleehan@12$";                       

#define sensorPin D1
int sensorState = 0;
int lastState = 0;
#define DHTPIN 2    
#define DHTTYPE DHT11     
DHT dht(DHTPIN, DHTTYPE);
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
 
  Blynk.virtualWrite(V5, h);  
  Blynk.virtualWrite(V6, t);  
}
void setup()
{
  Serial.begin(74880);
  Blynk.begin(auth, ssid, pass);
   pinMode(sensorPin, INPUT);
  dht.begin();

  timer.setInterval(1000L, sendSensor);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
   sensors.begin();
}
int sensor=0;
void sendTemps()
{
sensor=analogRead(A0);
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0); 
Serial.println(temp);
Serial.println(sensor);
Blynk.virtualWrite(V1, temp);
Blynk.virtualWrite(V2,sensor);
delay(1000);
}
void loop()
{
  Blynk.run(); 
  timer.run(); 
  sendTemps();
  sensorState = digitalRead(sensorPin);
Serial.println(sensorState);

if (sensorState == 1 && lastState == 0) {
  Serial.println("needs water, send notification");
  Blynk.notify("Water your plants");
  lastState = 1;
  delay(1000);

    
  } 
  else if (sensorState == 1 && lastState == 1) {
    //do nothing, has not been watered yet
  Serial.println("has not been watered yet");
  delay(1000);
  }
  else {
    //st
    Serial.println("does not need water");
    lastState = 0;
    delay(1000);
  }
  
  delay(100);
}

The ESP8266 doesn’t work with 5GHz WiFi networks, which is probably why you aren’t getting connected. You need to connect to a 2.4GHz network.

Pete.

Thank you sir It got connected

Good, now I’d suggest you go back and re-read the advice you’ve been given and fix these things…

Pete.