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

How many functions in a timer?

#1

are these features correct for a single timer?

timer.setInterval(800L, buttonLedWidget);
.......

void buttonLedWidget(){

if ( digitalRead (inp5)==0){led5.on();  } else {led5.off();  }      
if ( digitalRead (inp6)==0){led6.on();  } else {led6.off();Blynk.notify("PLC Stop !!!");}       
if ( digitalRead (inp12)==0){led12.on();  } else {led12.off();}   
if ( digitalRead (inp18)==0){led18.on();Blynk.notify("Alarm"); } else {led18.off();}
if ( digitalRead (inp27)==1){;Blynk.notify("Test"); }                           
if ( digitalRead (inp29)==1){led29.on();} else {led29.off();}                                   
if ( digitalRead (inp37)==1){led37.on();} else {led37.off();}                                   
if ( digitalRead (inp45)==1){led29.on();} else {led45.off();}                                  
if ( digitalRead (inp47)==1){led47.on();} else {led47.off();}  
}                                

I have problems of disconnection, there are too many functions I have to set timers with different times for each single reading?

0 Likes

#2

If you increase the time from 800 to say, 1800 does the problem go away?
If so, I suspect the Blynk calls may be too frequent.

0 Likes

#3

I’d capture the time at the beginning and end of the function …

void buttonLedWidget(){
   long int start_time = millis();
   // ...
   Serial.println(millis() - start_time);
}
0 Likes

#4

Put a few Blynk.run(); commands in your function, say after ever two or thee digital ‘if’ statements.

Pete.

0 Likes

#5

time result is 14

0 Likes

#6

You have nothing preventing these notifications from attempting to process each timer iteration (if the pin is the needed value). But there is a 5 second limit between consecutive calls.

http://docs.blynk.cc/#widgets-notifications

image

0 Likes

#7

That’s 14 ms. I’d probably look elsewhere for your disconnection issue.

0 Likes

#8

messages are sent very rarely. I will soon put a time limitation

0 Likes

#9

I have tried every cause but I have the same result.
I also increased the timer time to 1000L

0 Likes

#10

If you’ve tried adding extra Blynk.run commands then perhaps you should post your full code and a few more details about exactly what symptoms you’re seeing and what you get in your serial monitor.

Pete.

0 Likes

#11

the problem was the network card, certainly defective. I mounted a w5100 and it is working fine without Blink.run in the middle of if.

The process time has dropped to 6ms

1 Like

#12

I spent soooo much time messing around with various Ethernet shields and libraries for the Arduino before I finally saw the light.

Pete.

0 Likes