ESP8266 NodeMCU doesn't sync with Blynk App

Hello blynkers.
I have a problem when I synchronize my NodeMCU with my Blynk App. Basically I load the program correctly to the NodeMCU, but the Blynk App ignores that the NodeMCU is connected. I verify the program and the AuthToken is written correctly, also the internet ssid and pass. I try to load the program many times and the problem persist.
I’m using the NodeMCU with a YF-s201 flow sensor, also I’m using the most recent Blynk Library. Thank you in advance guys.


#define BLYNK_PRINT Serial


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


char auth[] = "xxxxxx"; 


char ssid[] = "xxxxxx";
char pass[] = "xxxxxx";

BlynkTimer timer;  


int sensor = A0;
int val = 0;
int Porcentaje = 0;

volatile int NumPulsos; 
const int sensorPin= 14;    
float factor_conversion=7.11;      
float volumen=0;
long dt=0; 
long t0=0; 
byte sensorInterrupt = 0;

void ContarPulsos ()  
{ 
  NumPulsos++; 
} 

int ObtenerFrecuecia() 
{
  int frecuencia;
  NumPulsos = 0;  
  interrupts();  
  delay(1000);  
  noInterrupts(); 
  frecuencia=NumPulsos; 
  return frecuencia;
}

void sendSensor()
{
  val = analogRead(sensor);
  Porcentaje = map(val, 1023, 0, 0, 100);
  
   Blynk.virtualWrite(V0, Porcentaje);
}

void sendSensor3(){
  float frecuencia=ObtenerFrecuecia(); 
  float caudal_L_m=frecuencia/factor_conversion; 
  dt=millis()-t0; 
  t0=millis();
  volumen=volumen+(caudal_L_m/60)*(dt/1000); 

  
   Blynk.virtualWrite(V6, caudal_L_m);
   Blynk.virtualWrite(V7, volumen);
}

void setup()
{

  Serial.begin(9600);

  pinMode (sensor,INPUT);
  pinMode (sensorPin,INPUT);

   attachInterrupt(digitalPinToInterrupt(14), ContarPulsos,RISING);
  t0=millis();

  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, sendSensor);
  timer.setInterval(1010L, sendSensor3);

 
}

void loop()
{
  Blynk.run();
  timer.run();
}

Can you post the output of the serial monitor? I dare say it is a connection problem.

1 Like