BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynktimer.h Error

<Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp: In function 'long unsigned int elapsed()':

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:264:29: error: redefinition of 'long unsigned int elapsed()'

 static inline unsigned long elapsed() { return millis(); }

                             ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:6:29: note: 'long unsigned int elapsed()' previously defined here

 static inline unsigned long elapsed() { return millis(); }

                             ^

In file included from C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:1:0:

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp: At global scope:

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'BlynkTimer::BlynkTimer()'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:267:1: note: in expansion of macro 'SimpleTimer'

 SimpleTimer::SimpleTimer()

 ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'BlynkTimer::BlynkTimer()' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:9:1: note: in expansion of macro 'SimpleTimer'

 SimpleTimer::SimpleTimer()

 ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'void BlynkTimer::init()'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:272:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::init() {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'void BlynkTimer::init()' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:14:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::init() {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'void BlynkTimer::run()'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:284:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::run() {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'void BlynkTimer::run()' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:26:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::run() {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'int BlynkTimer::findFirstFreeSlot()'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:345:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::findFirstFreeSlot() {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'int BlynkTimer::findFirstFreeSlot()' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:87:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::findFirstFreeSlot() {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'int BlynkTimer::setupTimer(long unsigned int, void*, void*, bool, unsigned int)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:363:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setupTimer(unsigned long d, void* f, void* p, bool h, unsigned n) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'int BlynkTimer::setupTimer(long unsigned int, void*, void*, bool, unsigned int)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:105:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setupTimer(unsigned long d, void* f, void* p, bool h, unsigned n) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'int BlynkTimer::setTimer(long unsigned int, timer_callback, unsigned int)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:393:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setTimer(unsigned long d, timer_callback f, unsigned n) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'int BlynkTimer::setTimer(long unsigned int, timer_callback, unsigned int)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:135:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setTimer(unsigned long d, timer_callback f, unsigned n) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'int BlynkTimer::setTimer(long unsigned int, timer_callback_p, void*, unsigned int)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:397:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setTimer(unsigned long d, timer_callback_p f, void* p, unsigned n) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'int BlynkTimer::setTimer(long unsigned int, timer_callback_p, void*, unsigned int)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:139:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setTimer(unsigned long d, timer_callback_p f, void* p, unsigned n) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'int BlynkTimer::setInterval(long unsigned int, timer_callback)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:401:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setInterval(unsigned long d, timer_callback f) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'int BlynkTimer::setInterval(long unsigned int, timer_callback)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:143:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setInterval(unsigned long d, timer_callback f) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'int BlynkTimer::setInterval(long unsigned int, timer_callback_p, void*)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:405:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setInterval(unsigned long d, timer_callback_p f, void* p) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'int BlynkTimer::setInterval(long unsigned int, timer_callback_p, void*)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:147:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setInterval(unsigned long d, timer_callback_p f, void* p) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'int BlynkTimer::setTimeout(long unsigned int, timer_callback)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:409:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setTimeout(unsigned long d, timer_callback f) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'int BlynkTimer::setTimeout(long unsigned int, timer_callback)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:151:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setTimeout(unsigned long d, timer_callback f) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'int BlynkTimer::setTimeout(long unsigned int, timer_callback_p, void*)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:413:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setTimeout(unsigned long d, timer_callback_p f, void* p) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'int BlynkTimer::setTimeout(long unsigned int, timer_callback_p, void*)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:155:5: note: in expansion of macro 'SimpleTimer'

 int SimpleTimer::setTimeout(unsigned long d, timer_callback_p f, void* p) {

     ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'bool BlynkTimer::changeInterval(unsigned int, long unsigned int)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:417:6: note: in expansion of macro 'SimpleTimer'

 bool SimpleTimer::changeInterval(unsigned numTimer, unsigned long d) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'bool BlynkTimer::changeInterval(unsigned int, long unsigned int)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:159:6: note: in expansion of macro 'SimpleTimer'

 bool SimpleTimer::changeInterval(unsigned numTimer, unsigned long d) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'void BlynkTimer::deleteTimer(unsigned int)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:432:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::deleteTimer(unsigned timerId) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'void BlynkTimer::deleteTimer(unsigned int)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:174:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::deleteTimer(unsigned timerId) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'void BlynkTimer::restartTimer(unsigned int)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:455:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::restartTimer(unsigned numTimer) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'void BlynkTimer::restartTimer(unsigned int)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:197:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::restartTimer(unsigned numTimer) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'bool BlynkTimer::isEnabled(unsigned int)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:464:6: note: in expansion of macro 'SimpleTimer'

 bool SimpleTimer::isEnabled(unsigned numTimer) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'bool BlynkTimer::isEnabled(unsigned int)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:206:6: note: in expansion of macro 'SimpleTimer'

 bool SimpleTimer::isEnabled(unsigned numTimer) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'void BlynkTimer::enable(unsigned int)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:473:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::enable(unsigned numTimer) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'void BlynkTimer::enable(unsigned int)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:215:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::enable(unsigned numTimer) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'void BlynkTimer::disable(unsigned int)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:482:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::disable(unsigned numTimer) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'void BlynkTimer::disable(unsigned int)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:224:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::disable(unsigned numTimer) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'void BlynkTimer::enableAll()'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:490:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::enableAll() {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'void BlynkTimer::enableAll()' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:232:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::enableAll() {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'void BlynkTimer::disableAll()'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:499:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::disableAll() {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'void BlynkTimer::disableAll()' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:241:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::disableAll() {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'void BlynkTimer::toggle(unsigned int)'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:508:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::toggle(unsigned numTimer) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'void BlynkTimer::toggle(unsigned int)' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:250:6: note: in expansion of macro 'SimpleTimer'

 void SimpleTimer::toggle(unsigned numTimer) {

      ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of 'unsigned int BlynkTimer::getNumTimers()'

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:517:10: note: in expansion of macro 'SimpleTimer'

 unsigned SimpleTimer::getNumTimers() {

          ^

C:\Arduino\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: note: 'unsigned int BlynkTimer::getNumTimers()' previously defined here

 #define SimpleTimer BlynkTimer

                     ^

C:\Arduino\Arduino\libraries\BlynkTimer\BlynkTimer.cpp:259:10: note: in expansion of macro 'SimpleTimer'

 unsigned SimpleTimer::getNumTimers() {

          ^

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

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

Cant figure this out for posting but I cant get rid of this error.

Any suggestions?

@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

Hello,
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:
```

Pete.

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???

Pete.

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;
DHT dht(DHTPIN, DHTTYPE);
void setup() {
  pinMode(PUMP_PIN, OUTPUT);
 aplyCmd();
  Serial.begin(115200);
  dht.begin();    
  Blynk.begin( auth, ssid , pass );
  PUMP.off();
 startTimers();
}
void loop() {
  timer.run(); 
  Blynk.run();
}
BLYNK_WRITE(3) 
{
  int i = param.asInt();
  if (i == 1)
  {
    pumpStatus = !pumpStatus;
    aplyCmd();
  }
}
void getSoilMoist(void)
{
  int i = 0;
  soilMoist = 0;
  for (i = 0; i < 10; i++)  //
  {
    soilMoist += analogRead(SOIL_MOIST_1_PIN); 
    delay(20);   
  }
  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!");
    return;
  }
}
void aplyCmd()
{
  if (pumpStatus == 1)
  {
    Blynk.notify("pump ON");
    digitalWrite(PUMP_PIN, LOW);
    PUMP.on();
  }

  else {
    digitalWrite(PUMP_PIN, HIGH);
    PUMP.off();
  }
}
void autoControlPlantation(void)
{
  if (soilMoist < DRY_SOIL)
  {
    turnPumpOn();
  }
}
void turnPumpOn()
{
  pumpStatus = 1;
  aplyCmd();
  delay (TIME_PUMP_ON * 1000);
  pumpStatus = 0;
  aplyCmd();
}
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.

Pete.

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.

2 Likes

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.

//BLYNK_WRITE(3)
// Button at V4 ??
BLYNK_WRITE(V4) 
{
  int i = param.asInt();
  if (i == 1)
  {
    pumpStatus = !pumpStatus;
    aplyCmd();
  }

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.

Pete.

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