Hi I’m trying to use a Wemos d1 mini and YF-S201 flow meter and I would like to synchronize the flow reading via blynk in case of lack of connection.
I have enabled virtual pin V3 on Blynk console in the datastreams section
with Data Type “String” and with Sync with latest server value every time device connects to the cloud but it doesn’t work, the value on restart is always 0.
Where am I wrong?
Thank you.
#define D2 4
#define BLYNK_TEMPLATE_ID "TMPL4xYq*****"
#define BLYNK_TEMPLATE_NAME "TEST"
#define BLYNK_FIRMWARE_VERSION "0.9"
#define BLYNK_PRINT Serial
#define APP_DEBUG
#define USE_WEMOS_D1_MINI
#include "BlynkEdgent.h"
BlynkTimer timer;
//******************** VARIABILI FLUSSOMETRO ********************
int ingresso = D2; //Piedino di ingresso del flussostato
int flusso ; //Quantità di acqua che scorre
volatile int count; //Variabile di conteggio
//******************** VARIABILI FLUSSOMETRO ********************
BLYNK_CONNECTED() {
Blynk.syncVirtual(V3);
}
BLYNK_WRITE(V3) { flusso , param.asInt();}
void setup() {
Serial.begin(115200);
BlynkEdgent.begin() ;
pinMode (ingresso, INPUT); //Imposta piedino 2 in ingresso
attachInterrupt (ingresso, IntCallback, RISING); //Configura interrupt D2 pin 2
timer.setInterval( 1000L, LetturaFlusso ) ;
}
IRAM_ATTR void IntCallback(){
count = count +1; //Incrementa count di 1}
}
void LetturaFlusso(){
flusso = (count * 2.25); //2.25mL per ogni impulso
flusso = flusso / 1000; //Trasforma i mL in litri
Blynk.virtualWrite(V3, flusso ," L");
}
void loop() {
BlynkEdgent.run();
timer.run();
}
Hi Peter,
the original value of “int flow” was “flaot flow”, unfortunately in datastreams if I set Data type double or int the value is no longer displayed on the app, it is only displayed if I set String.
I tried as you recommended, and I noticed that on the serial line the value is displayed correctly, however on the app I always get 0.000
On the serial monitor the flow value is read by the blynk server and therefore synchronized, instead on the blynk iot app (it always remains 0.000 when the device restarts)