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
}