[CLOSED] Widget Button Occasional failure


I’ve a project that will control 4 arduino (same authentification token - different virtual pins).
It has a total of 29 widgets, and receive a low rate of data (less than 10/minute).

At the beginning, only one device was used and all the widgets worked fine, excepted the buttons widgets that failed sometimes to send the command. I had to repeat the push and it finally worked.

Now I’ve connected a second arduino and it seems this occasional problem occurs more often (perhaps one time on 4 push).

The major problem is that the button is in “switch mode”, and so in case of failure its displayed state doesn’t reflect anymore the real state on the hardware.

Is it possible to improve the realibility of theses button commands?
(Or if it’s not possible, how can I get the displayed state of the buttons synchronized on the appli following the real state on the hardware.)

PS: only one common widget (terminal V6) is used for all the devices. And sometimes it appears empty and I’ve to logout/login the app to refresh it. Is it not a problem to use the same virtualpin on multiple devices?


/below my code if it could help…

//#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#define BLYNK_NO_BUILTIN        // Disable built-in analog & digital pin operations
#define BLYNK_NO_FLOAT          // Disable float operations
#define BLYNK_NO_INFO           // Skip device info
#include <BlynkSimpleUIPEthernet.h>
#include <Wire.h>
#include <avr/pgmspace.h>

WidgetTerminal terminal(V6);

// You should get Auth Token in the Blynk App.///////////////////////////////////
char auth[] = "XXXXXXXXXXXXXXXXXXX";////////////////////////////////

  unsigned long currentTime;      //variables TIMER
  unsigned long lastRunTime;
  unsigned long interval = 60000; 
  char Buffer [33];               //transmission I2C de NANO Slave//32 byte received (MAX I2C) 
  char WeightChar[7]="000.00";     //6 bytes utiles XXX.XX + "\0" qui ponctue le array char
  char Flag_Measure = 'E';           //par défaut mesure ENABLED après mise sous tension  
  char Flag_Protec_Taring = '1';      
  byte X=5;                          
void setup()  
  Wire.begin();                  // join i2c bus  
  terminal.println(F("DEMARRAGE DANS ~60sec..."));

void MyTimer(){
  char DS18B20_T_Char[5];
  char DHT22_T_Char[5];
  char DHT22_H_Char[5];

  if (Flag_Measure == 'E') {             
			  //Receiving data I2C
				byte i=0;                         
				while (Wire.available()) {  // loop through all bytes
				char c = Wire.read();       
				Buffer[i] = c ;             
				Buffer[i] = '\0' ;           

			//Saving I2C into variables  
				  for (i=1 ; i <= 6 ; i++){ WeightChar[i-1]=Buffer[i];}   //  Weight ***.**
					WeightChar[i] = '\0';                                           
				  byte j=0; 
				  for (i=8 ; i <= 11 ; i++){ DS18B20_T_Char[j]=Buffer[i];j++;} //  T° IN **.*
				  for (i=13 ; i <= 16 ; i++){ DHT22_T_Char[j]=Buffer[i];j++;} //  T° OUT **.*
				  for (i=18 ; i <= 21 ; i++){ DHT22_H_Char[j]=Buffer[i];j++;} //  Humidité **.*
				   Blynk.virtualWrite(V8, WeightChar);           // transmit Weight 
				   if (X == 5){    // transmit data T° et humidité, un cycle sur 5
				   Blynk.virtualWrite(V9, DS18B20_T_Char);       
				   Blynk.virtualWrite(V10, DHT22_T_Char);         
				   Blynk.virtualWrite(V11, DHT22_H_Char);         

                   Blynk.setProperty(V6, "color", "#000000");
  } //end of loop if (measure = enabled)

BLYNK_WRITE(V12) { //Push Button Widget for taring 
    int buttonstate = param.asInt();    
    if (buttonstate == 1) {
          if (Flag_Protec_Taring == '0') {     // protect TARING
          Blynk.setProperty(V6, "color", "#FF00FF");
          FlagNoEvent = '0';
          if (Flag_Protec_Taring == '1') {terminal.println(F(""));terminal.println(F("MISE A 0.0KG VERROUILLE"));terminal.flush();}

BLYNK_WRITE(V13) //enable-disable measures
    int buttonstate = param.asInt();
    interval=10000;                       // accélérer la réponse du système lors des configs
    if (buttonstate == 1)
    Flag_Protec_Taring='0';   //bouton TARING actif
    Flag_Measure = 'D';
    terminal.println(F(""));terminal.println(F("STATUT BUFFER V1.5"));      
    Blynk.setProperty(V6, "color", "#FF00FF");
    else if (buttonstate == 0)
    Flag_Measure = 'E';
    FlagNoEvent = '0';
    Flag_Protec_Taring='1';   //bouton TARING protégé

void Transmission(char FlagMaster){
        Wire.beginTransmission(4);    // transmit to device address #4
        Wire.write(FlagMaster);       // sends one byte to slave to setup enable-disable / taring 
        Wire.endTransmission();       // stop transmitting  

void loop(){  
  currentTime = millis();  
  if (currentTime - lastRunTime >= interval)     //TIMER 60 sec
    lastRunTime = currentTime;


i do not have too much experience using the same tokens on multiple arduinos…
but wouldn’t be more logic to have 4 separate devices in the blynk app, and use different tokens? since the latest major update you can control multiple devices from the same project…

also, you should look into what
#define BLYNK_NO_INFO // Skip device info
is doing, because @vshymanskyy said several months ago:

you can use the led widget for this, or display widget for every button and send “on” or “off” text from hardware to display widget.

1 Like

Hello Wanek,

Thanks for advices.

wouldn’t be more logic to have 4 separate devices in the blynk app, and use different tokens?

I can try, but in this case I can’t feed the same widget terminal with my 4 devices… and I don’t have enough free space because my project has a lot of hystory widgets…

also, you should look into what #define BLYNK_NO_INFO // Skip device infois doing, because @vshymanskyy said several months ago:
Arduino Blynk library static memory footprint report
Exactly. And no-info frees some memory by skipping meta info sending (this might hurt in future, so better not to skip this)

It should be a big problem for me because using a little arduino with the big library UIP for ethernet, it’s hard to keep the sketch below the 32k flash memory.

how can I get the displayed state of the buttons synchronized on the appli following the real state on the hardware.
you can use the led widget for this, or display widget for every button and send “on” or “off” text from hardware to display widget.

Still the lack of space on project & the lack of memory on hardware that make difficult to add more things.
In fact, at this time, I check on the terminal the effect of the buttons. But the best shoul be to make the buttons reliable.

I keep on searching …Thanks a lot :slight_smile:

if you are interested, in one of my projects i also had to use uip lib on atmega328.
i have successfully reduced the uip lib to a very small footprint. (with using static ip and other hacks). i can try to find the methods i used, if you would like to take a look…

read this, maybe will help:

1 Like

Yes I have seen and it helped me a lot;)

I use->

[details=Summary]#define UIP_CONF_MAX_CONNECTIONS 1
#define UIP_CONF_UDP 0
#define UIP_CLIENT_TIMER -1[/details]

But I still want to keep the DHCP enabled.

yeah, but you must consider, that dhcp functionality alone it takes ~20% of the uip lib…

i do not know your project, but maybe replacing the arduinos to wemos d1 mini pro would be the best solution. since @Lichtsignaal recommended this to me, it was one of the best decisions and i never look back. i can write and import as much libs i want, use as much global variables i want, still just using 25% of the wemos capacity, and no more hassle with power hungry ethernet modules… i have built in wifi and ota.

Wemos works great, but for this project I excluded wifi because I want to monitor hives, and I prefer not to stream wifi on bees…

It’s true I can find some work around to avoid my problem, but I would prefer to understand why my commands sometimes fail.
Is there not other users that should got the same problems with button?

I seems the appearance of the button changes directly on the app when pushed, even although the command failed. As it should be much better that the appearance changes only after the command is received by the server, and so the server can confirm it to the app.
Anybody can confirm how it works, with or whitout acknowledge?

You could consider switching the Arduino Mega. That has a lot more memory and works fine with Ethernet. I can understand you don’t want Wifi near the bees, so switching to a bigger Arduino might be an idea.

regarding hives, i have read some thesis in exactly this subject: they implemented some kind of alarm system for hives, and studied how bees react to 2.4ghz radio. they didn’t observed any disturbance in comportment.

another thing, that you do not have to keep the wifi always on, maybe use sleep mode, and just turn on time by time to exchange information with server. using wifi has advantage, that you do not need cables, just a battery / solar panel.


I adapted the offline notifier widget to “instant”, and →
The problem is that the project goes frequently offline as soon as I use 2 devices.
That is why when I push a command, it doesn’t work at each time.
As soon as I stop one device, the project works perfectly.

As finally the problem is not specific to button widget. I close this subject and go on there →

Thanks for the good advices.

Thank you, but I use NANO because I’m very short in space. I put all the system in a chassis large of 40 mm.
It weighs half of the hive, and I multiply X2 by software.
It’s low cost, easy to place under the hives, and finally the important is not the absolute weigh but the variations…

I know, I want all in the same time… :slight_smile: