Widget.setVpin (vpin) error using Blynk

This the code that I having problem with. I got it to work and then I had to start over but now I cant even get past the compile stage. Any ideas?

The code

Widgets setvPins
#define BLYNK_DEBUG           // Comment this out to disable debug and save space
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WebServer.h>
#include <SimpleTimer.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
#include <Ticker.h>              //for LED status
Ticker ticker;

char auth[] = "Your Auth Token";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] ="Wiffi SSID";
char pass[] ="Password";

SimpleTimer timer;
WidgetRTC rtc;         
WidgetTerminal terminal(V2);
WidgetLCD lcd(V7);

bool simulation = false;     

byte sensorInterrupt = 4;   // WeMos & NodeMCU D2
byte sensorPin       = 4;   // WeMos & NodeMCU D2
byte pumpInterrupt   = 5; //2;  //5;   // WeMos D1 ModeMCU D3
byte pumpPin         = 5; //2;  //5;   // WeMos D1 ModeMCU D3

// The hall-effect flow sensor outputs approximately 4.5 pulses per second per litre/minute of flow.
float calibrationFactor = 4.5;
volatile byte pulseCount;  
float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
unsigned long oldTime;

#define averageperiod 5         // currently set to average the flow every 5 seconds
int countseconds = 0;           // count up to averageperiod
int averageflow = 0;            // used for averaging flow over averageperiod
bool notificationsent = false;  // to ensure just one message for each flow start
bool pumpState = false;         // pump is OFF on start up
bool masterState = false;       // 
bool flowoffprintonce = false;  // to ensure just one serial and terminal print for each flow stop
int rowIndex = 0;                //Saurabh
String currentDate  ;
String daybefore;
int rtctimer = 1; //check if RTC is OK and then disable / delete this #1 timer
int currentDatesi = 0;         //Saurabh simulation
int daybeforesi=currentDatesi;
int menu=0;
int s;

void setup()

 pinMode(sensorPin, INPUT);
 digitalWrite(sensorPin, HIGH);
  pinMode(pumpPin, OUTPUT);
  digitalWrite(pumpPin, LOW);  // ACTIVE HIGH, pump relay set to OFF on restart
  flowMilliLitres   = 0;
  totalMilliLitres  = 0;
  oldTime           = 0;
  flowRate          = 0.0;
  if(simulation == true){
    pulseCount        = 47;
    pulseCount        = 0;

  // Configured to trigger on a FALLING state change (transition from HIGH state to LOW state)
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);//FALLING

  // Configured to trigger on a CHANGE state change LOW to HIGH or HIGH to LOW
  attachInterrupt(pumpInterrupt, pumpToggle, CHANGE);
  Blynk.begin(auth, ssid, pass);
  terminal.println("Connected to Blynk");
  timer.setInterval(1000L, showFlow);
  timer.setInterval(100L, pumpControl);  // check if pump needs to be switched ON or OFF every 0.1s
  rtctimer = timer.setInterval(2000L, checkRTC);   // check every 2s if RTC is correct
void showFlow()  // average the flow over averageperiod
    detachInterrupt(sensorInterrupt);  // Disable the interrupt while calculating flow rate and sending the value to the host        
    // Because this loop may not complete in exactly 1 second intervals we calculate
    // the number of milliseconds that have passed since the last execution and use
    // that to scale the output. We also apply the calibrationFactor to scale the output
    // based on the number of pulses per second per units of measure (litres/minute in
    // this case) coming from the sensor.
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    // Note the time this processing pass was executed. Note that because we've
    // disabled interrupts the millis() function won't actually be incrementing right
    // at this point, but it will still return the value it was set to just before
    // interrupts went away.
    oldTime = millis();
    // Divide the flow rate in litres/minute by 60 to determine how many litres have
    // passed through the sensor in this 1 second interval, then multiply by 1000 to
    // convert to millilitres.
    flowMilliLitres = (flowRate / 60) * 1000;
    // Add the ml passed in this second to the cumulative total
    totalMilliLitres += flowMilliLitres;
    // Print the flow rate for this second in litres / minute
    Serial.print("Flow rate: ");
    Serial.print(int(flowRate));  // Print the integer part of the variable
    Serial.print("\t");          // Print tab space
    // Print the cumulative total of litres flowed since starting
    Serial.print("Output Liquid Quantity: ");        
    Serial.print("\t");       // Print tab space
    if(simulation != true){  
      pulseCount = 0; // Reset the pulse counter so we can start incrementing again
    if(countseconds > 0){    // used to skip the first rogue data flow reading
      averageflow = averageflow + flowRate;   // used to calculate the average flow over averageperiod cycles
    if(countseconds == averageperiod){
      Serial.print("Average water flow in litres / M is ");
      Serial.println(averageflow / averageperiod);
      Blynk.virtualWrite(V0, int(averageflow) / averageperiod);
      Blynk.virtualWrite(V1, totalMilliLitres/1000);
      countseconds = 0;  // reset the counter
      averageflow = 0;     // reset the average but only after chkFlow() function
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);  // Enable the interrupt again now that we've finished sending output

void chkFlow(){
  if((averageflow > 3) && (notificationsent == false)){  // guess of a decent water pressure
    Serial.println("Water IS flowing.");
    lcd.print(0,0,"Water is flowing");
    Blynk.email("Water Flow Sensor", "Water IS flowing.");
    Blynk.notify("Sensor: Water IS flowing.");
    notificationsent = true;         // stop getting messages until water stops flowing and starts again
    flowoffprintonce = false;        // when water stops flowing again we can restart serial and terminal print (once)
  if((averageflow <= 3)&& (flowoffprintonce == false)){
    Serial.println("Water is NOT flowing.");
    lcd.print(1,0,"Water is NOT");
    notificationsent = false;  // when water starts flowing again we can send another notification
    flowoffprintonce = true;      // stop serial and terminal prints after first pass of water stopping
 if(averageflow <= 3){
     digitalWrite(pumpPin, LOW);   // turn off pump //s*
if(averageflow>3 && menu == 1){
    digitalWrite(pumpPin, HIGH);   // turn on pump //s*
    Blynk.virtualWrite(V8, "ON");
    Blynk.virtualWrite(V4, 1);     // update app button on V4  COSTAS//s*

void pulseCounter()
  pulseCount++;  // Increment the pulse counter

void pumpToggle(){                // toggle just pumpState OFF and ON from pin interrupt
  pumpState = !pumpState;         // don't do anything else in this function or the system will crash
  //Serial.println(pumpState);      // for debugging only  TODO comment this out later     

void pumpControl()                // toggle pump OFF and ON
  detachInterrupt(pumpInterrupt);  // disable interrupt
  if(pumpState == masterState){
    // do nothing
    masterState = pumpState;
    if(pumpState == true){
    Blynk.virtualWrite(V4, 1);
    Blynk.virtualWrite(V8, "ON");
    // Blynk.setProperty(V8, "color","#48E06B");
    Serial.println("Pump turned ON"); 
      Blynk.virtualWrite(V4, 0);
      Blynk.virtualWrite(V8, "OFF");
   //   Blynk.setProperty(V8, "color","#04C0F8");
      Serial.println("Pump turned OFF"); 
  attachInterrupt(pumpInterrupt, pumpToggle, CHANGE);   // enable pump pin interrupt
void checkRTC(){
  if(year() != 1970){
    timer.disable(rtctimer);  // disable rtctimer now RTC is ok
    //rtcupdated = true; // can be commented out as checkRTC will stop when RTC is ok
    currentDate = String(day()) + "/" + month() + "/" + year();   // etc
    terminal.println("RTC started");
    timer.setInterval(60000L, table);   //start table() now RTC is OK
void table()                               //Saurabh
  currentDate = String(day()) + "/" + month() + "/" + year();  // etc
   if(currentDate != daybefore)
    //currentDate = String(day()) + "/" + month() + "/" + year();
    Blynk.virtualWrite(V10, "add", rowIndex,daybefore,totalMilliLitres/1000+String(" litre")); //Saurabh
    Blynk.virtualWrite(V1, 0);
    flowMilliLitres = 0;
    totalMilliLitres = 0;
BLYNK_WRITE(V3){   // reset with button in PUSH mode on virtual pin 3
  int resetdata = param.asInt();
  if(resetdata == 1){
    Serial.println("Clearing data");
    Blynk.virtualWrite(V0, 0);
    Blynk.virtualWrite(V1, 0);
    averageflow = 0;
    countseconds = 0;
    flowMilliLitres = 0;
    totalMilliLitres = 0;
BLYNK_WRITE(V20){   // reset with button in PUSH mode on virtual pin 20
  int resetdata = param.asInt();
  if(resetdata == 1){
    Serial.println("Clearing table data");
    Blynk.virtualWrite(V10, "clr");
BLYNK_WRITE(V4){   // Button in SWITCH mode on virtual pin 4 to control relay
  int controlRelay = param.asInt();
  if(controlRelay == 1){
    digitalWrite(pumpPin, HIGH);  // turn relay ON
   // Blynk.virtualWrite(V8, "ON"); 
    digitalWrite(pumpPin, LOW);  // turn relay OFF 
     //Blynk.virtualWrite(V8, "OFF"); 
  case 1:{
    lcd.print(1,0,"Automatic Mode");
  case 2:{
    lcd.print(3,0,"Manual Mode");
void loop(){

The error

Arduino: 1.8.11 (Windows Store (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

In file included from C:\Users\bsykstus.KVHINTERNAL\Documents\Arduino\libraries\Blynk\src/WidgetLED.h:13:0,

                 from C:\Users\bsykstus.KVHINTERNAL\Documents\Arduino\libraries\Blynk\src/BlynkWidgets.h:10,

                 from C:\Users\bsykstus.KVHINTERNAL\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEsp8266.h:102,

                 from C:\Users\bsykstus.KVHINTERNAL\Documents\Arduino\Flow sensor\instructables_water_flow_08_01_2017\Sketch\Sketch.ino:22:

C:\Users\bsykstus.KVHINTERNAL\Documents\Arduino\Flow sensor\instructables_water_flow_08_01_2017\Sketch\Sketch.ino: In function 'void BlynkWidgetWrite6(BlynkReq&, const BlynkParam&)':

C:\Users\bsykstus.KVHINTERNAL\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkWidgetBase.h:60:33: error: 'class WidgetRTC' has no member named 'onWrite'

     BLYNK_WRITE(pin) { (widget).onWrite(request, param); }


C:\Users\bsykstus.KVHINTERNAL\Documents\Arduino\Flow sensor\instructables_water_flow_08_01_2017\Sketch\Sketch.ino:38:1: note: in expansion of macro 'BLYNK_ATTACH_WIDGET'



C:\Users\bsykstus.KVHINTERNAL\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkWidgetBase.h: In instantiation of 'BlynkAttachWidgetHelper::BlynkAttachWidgetHelper(T&, uint8_t) [with T = WidgetRTC; uint8_t = unsigned char]':

C:\Users\bsykstus.KVHINTERNAL\Documents\Arduino\Flow sensor\instructables_water_flow_08_01_2017\Sketch\Sketch.ino:38:1:   required from here

C:\Users\bsykstus.KVHINTERNAL\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkWidgetBase.h:53:9: error: 'class WidgetRTC' has no member named 'setVPin'



exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

@Bsykstus please edit your post using the pencil icon at the bottom and add triple backticks at the beginning and end of your code, and your compiler error messages, so that they display correctly.
Triple backticks look like this:


Hi Pete

Done as instructed

Olay, well your sketch is missing this line at the begining:


and I have no idea what you’re trying to achieve with this line of code:

but that’s were your problem lies.


Sorry Pete

/* is at the beginning of my code…just a copy and paste error and my apologies.

So would need to rectify the below line, correct?


Commenting-out the line allows the code to compile, but as I said, I’m not sure what you’re trying to achieve with this line of code.


Thank you Pete, will try it later when back in front of PC.

I think I added it when trying to fix another problem and never came came back to remove it.

Thanks Pete, you were spot on and much appreciated.

1 Like