Blynktimer.h Error

@desjardo what version of the required libraries are you using?

Did you install them manually, it’s not possible via the IDE as the zip has multiple libraries?

Yes I cut and pasted the text into files which I saved in the directory as stated but still no luck.

My code is more or less working I just cant get blynktimer to work so I can use the timer widget to control my relay.

Version last update March 2017 - I got it off the arduino page.

Installing libraries doesn’t involve cutting and pasting text into files. You cut and paste the files.

If you installed the latest Blynk libraries you don’t need anything from an “Arduino page” as Blynk have embedded SimpleTimer in their own library and renamed it BlynkTimer.

Certainly sounds like a bad library install.

before using blynk, PLEASE learn:

  • how to install arduino libraries
  • how the blynk libraries are structured and how to install them

and before posting compile logs, PLEASE learn:

  • what part of the log file is relevant to your problem
  • how to post properly formatted system log / code snippets
1 Like

I have the same problem … i am beginer level … i don’t understand why? You resolved the problem? How ? Please tell me ! Thanks

@Mario_Alexandru please post your code and the compile messages that you’re getting.
When you post the code be sure to put triple backticks at the beginning and end of your code.
Triple backticks look like this:


Thank you !!! Look i have this error !!! Maybe you can help me !!!

In file included from C:\Users\flp\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h:17:0,

                 from C:\Users\flp\Documents\Arduino\libraries\Blynk\src/BlynkApiArduino.h:14,

                 from C:\Users\flp\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEsp8266.h:24,

                 from C:\Users\flp\Documents\Arduino\eee\eee.ino:3:

C:\Users\flp\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'class BlynkTimer'

 #define SimpleTimer BlynkTimer


C:\Users\flp\Documents\Arduino\libraries\SimpleTimer-1.0.0/SimpleTimer.h:10:7: note: in expansion of macro 'SimpleTimer'

 class SimpleTimer {


C:\Users\flp\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: previous definition of 'class BlynkTimer'

 #define SimpleTimer BlynkTimer


C:\Users\flp\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:41:7: note: in expansion of macro 'SimpleTimer'

 class SimpleTimer {


exit status 1
Error compiling for board WeMos D1 R1.

And your code???


This is my code …I try before 10 min to install again the library manual …and now i have a new error about my code…Look the code and please help me …

#define BLYNK_PRINT Serial    
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
WidgetLED PUMP(V0); 
#include "DHT.h"
#include <SimpleTimer.h>
#define DHTPIN 4     // pin  DATA with D4
#define SOIL_MOIST_1_PIN A0 // pin A0 with A0
#define PUMP_PIN 13   // PUMP RELAY
#define DHTTYPE DHT11   
#define DRY_SOIL      68
#define WET_SOIL      90
#define TIME_PUMP_ON  15
#define READ_SOIL_HUM_TM  10L 
#define READ_AIR_DATA_TM  2L  
#define SEND_UP_DATA_TM   10L 
#define AUTO_CTRL_TM      60L 
char auth[] = "Blynk token";
char ssid[] = "wifi name";
char pass[] = "wifi password";
float humDHT = 0;
float tempDHT = 0;
int soilMoist = 0;
boolean pumpStatus = 0;
int timePumpOn = 1; 
long sampleTimingSeconds = 20; 
long startTiming = 0;
long elapsedTime = 0;
SimpleTimer timer;
void setup() {
  pinMode(PUMP_PIN, OUTPUT);
  Blynk.begin( auth, ssid , pass );;
void loop() {;;
  int i = param.asInt();
  if (i == 1)
    pumpStatus = !pumpStatus;
void getSoilMoist(void)
  int i = 0;
  soilMoist = 0;
  for (i = 0; i < 10; i++)  //
    soilMoist += analogRead(SOIL_MOIST_1_PIN); 
  soilMoist = soilMoist / (i);
  soilMoist = map(soilMoist, 1023, 0, 0, 100); 

void getDhtData(void)
tempDHT = dht.readTemperature();
  humDHT = dht.readHumidity();
  if (isnan(humDHT) || isnan(tempDHT))   
    Serial.println("Failed to read from DHT sensor!");
void aplyCmd()
  if (pumpStatus == 1)
    Blynk.notify("pump ON");
    digitalWrite(PUMP_PIN, LOW);

  else {
    digitalWrite(PUMP_PIN, HIGH);;
void autoControlPlantation(void)
  if (soilMoist < DRY_SOIL)
void turnPumpOn()
  pumpStatus = 1;
  delay (TIME_PUMP_ON * 1000);
  pumpStatus = 0;
void startTimers(void)
  timer.setInterval(READ_AIR_DATA_TM * 1000, getDhtData);
  timer.setInterval(READ_SOIL_HUM_TM * 1000, getSoilMoist);
  timer.setInterval(SEND_UP_DATA_TM * 1000, sendUptime);
  timer.setInterval(AUTO_CTRL_TM * 1000, autoControlPlantation);
void sendUptime()
  Blynk.virtualWrite(1, tempDHT); 
  Blynk.virtualWrite(2, humDHT); 
  Blynk.virtualWrite(3, soilMoist);
1 Like

Thank you @PeteKnight !!!

After install the new library The new error code is :slight_smile:
‘class SimpleTimer’ has no member named ‘run’

Please edit your post and add-in the missing triple backticks.


Use built-in and more powerful BlynkTimer instead SimpleTimer.
Change your code as follows:

// Remove this
//#include <SimpleTimer.h>
// Modify this
//SimpleTimer timer;
// into this
BlynkTimer timer;

I didn’t check any of your code logic / implementation. Just fix the compiler error.


Yes i make this before and work the code only SimpleTimer but the relay working nonstop … the relay dont turn offf oder on and my pump watter working nonstop and i dont want this …

It does not make sense at all. The problem was not caused by using the BlynkTimer, but by something else you did at that time.

The code logic is so far OK, you only have to verify which virtual pin you’re using for PUMP CONTROL button then correct the BLYNK_WRITE() function.

// Button at V4 ??
  int i = param.asInt();
  if (i == 1)
    pumpStatus = !pumpStatus;

Why don’t you try the modified code to verify before making the decision? Isn’t that a way to know if something different will fix the issue?

i try all this what you tell me but dont working i have the same error like up …i change de v4 …but not work…
only time when work the code ist when i remove #include <SimpleTimer.h> but if i delete the comand dont switch on off my relay…i dont know . please somebody help me oder have another idee why dont work ???

I succeeded To repair the program … was from SimplerTimer library … i installed manuall and then worked …but i have a problem i use a arduino D1 with wifi board and i put the pin from relay by D13 how i write im program… but my relay dont switch on oder off… he stay off all time and i don’t understand why? What i make false?

As @khoih has already pointed-out, you should’t really be using the SimpleTimer library. Instead you should use BlynkTimer, which is built-in to the BlynkSimpleEsp8266.h library.

The Blynk version of the timer is better because it fixes a bug with the first timer that is created, it allows more timer instances for each timer object, and it has code built-in that prevents flooding of the Blynk server.


1 Like

Your application is similar to :

Have a look at this and see if you can apply according to your purpose.

Another thing is pin 13 (GPIO13)

#define PUMP_PIN 13   // PUMP RELAY

in your code for NodeMCU or Wemos D1 is actually pin D7 / GPIO13 and I guess you connect the relay to the wrong pin.

#define PIN_D7            13        // Pin D7 mapped to pin GPIO13/RXD2/HMOSI of ESP8266

Thanks forr all tips … i fix the error and was from from relay i must to change the pin Vcc to 3.3v and my pin was to 5v… and the pin who switch on off was D2 for relay … the code was good but i dont have so much experience… was my first project !