UNO wifi rev2 looses connection every hour or so

hi all,

i have a problem with Arduino UNO Wifi rev2 and Blynk, hope that someone can shad some light of what i am doing wrong.

So as i said, i use UNO wifi rev2, with wifinina 1.2.4.
Once i upload my sketch everything works, i have a connection, my Blynk app works… then after 45min it just says “device offline”, then i restart UNO, then after 1h15min it happens again… connection lasts between 20min and 2 hours but not longer.

  • Arduino UNO Wifi rev2
  • Blynk on Android
  • Using blynk server
  • Blynk library 0.6.1

Bellow is my sketch, i have one fan, one relay and one button that simulates “door open” and “door closed” scenario.
As i said, everything works while i am connected but that doesnt last long.

My wifi router never disconnects any other device so not sure why would it have an issues with Arduino UNO…

Any help would be highly appreciated.
Many thanks,
Alek


#define BLYNK_PRINT Serial
#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>


#define fan 9


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "***";
char ssid[] = "******";
char pass[] = "********";


const int buttonPin = 2;     // the number of the pushbutton pin
int buttonState = 0;         // variable for reading the pushbutton status

char door_open[] = {"Open!"};
char door_closed[] = {"Closed!"};


BlynkTimer timer;

  
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, millis() / 1000);
}

void control()
{
  buttonState = digitalRead(buttonPin);

  if (buttonState == 0) {
    Blynk.virtualWrite(V1, door_closed);
    Blynk.setProperty(V1, "color", "#a7f542");
  }
  if (buttonState == 1) {
    Blynk.virtualWrite(V1, door_open);
    Blynk.setProperty(V1, "color", "#f54242");
  }

int relayState = digitalRead(fan);
if (relayState == LOW) 
{
  WidgetLED led2(V2);
    led2.off();
  } else {
    // turn LED off:
    WidgetLED led2(V2);
    led2.on();
  }
}
  


void setup()
{
  pinMode(buttonPin, INPUT);
  pinMode(fan, OUTPUT); 
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
  timer.setInterval(1000L, myTimerEvent);
  timer.setInterval(1000L, control); // Call "control" every second
   
}



void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer

}

Over time “millis() / 1000” will quickly become a very, very large number. Sending this to Blynk may cause the disconnect?

billd

I shall not try to do the math… (OK, I Googled instead :stuck_out_tongue: see link… after about 50 days millis() just goes back to 0) but I have had devices running weeks without any issues using this calculation for uptime.

1 Like

Thanks guys!

I dont think its millis, anyway i have switched to NodeMCU with ESP8266 and i got it running for 12 hours and counting, no hassle, no reconnects… it just works! and i can get 20 of them for the price of one UNO :slight_smile:

Thanks again,
Alek

Oh, right… I jumped in at the end and missed the beginning :innocent:

An UNO (which I started with, and still use) is probably the lowest of the low options for IoT type operations, not much horsepower or memory, and something as simple as trying to run both your timed functions at the same time every second can overwhelm one. Even the “newer” UNO WiFi R2 doesn’t seem to increase the power, just the connectivity add-on convenience (at a price).

Thanks GTT.

Well, i was not aware that UNO is so under-powered!? i was not familiar with NodeMCU3 but loving it, so seamless and so nice, smaller, works great… seems odd when you compare it to 40,00 EUR UNO wifi rev2, which will go back.

Thanks,
Alek

Well, costwise at least, you are probably paying for “Genuine Arduino” and not an open sourced re-creation.

And there is nothing wrong with an UNO and its bigger bro the MEGA… for the right purpose… they are very easy to use, have forgiving 5V and 3.3v compliant GPIO, well documented, etc. But they are very old tech in a world where tech is measured in months.

But just for kicks and testing… you could try staggering your timers and give it another go before returning it.

timer.setInterval(1000L, myTimerEvent);
delay(100);  // Short delay before starting next timer iteration... adjust as needed.
timer.setInterval(1000L, control); // Call "control" every second

Will try but now in love with MCU :slight_smile:

No, i love both UNO and MEGA, non genuine of course, they are amazing, but UNO wifi has disappointed , i was really expecting much much more.

Will test and let you know!
Thanks,
Alek

I did a comparison here…

Pete.

1 Like

Thanks Pete, good read!
Wow, again was not aware NodeMCU is that better.
I have never used NodeMCU before but had a few in my stash, seems pretty straight forward and other than port numbers difference it worked straight away. Seems like i will abandoning anything Arduino for IoT. Ordering D1 mini now to test it, so tiny and yet so usable!

Many thanks guys,
Alek

2 Likes