Hi all, my connection works just fine after either being uploaded or reset pressed but after a while of inactivity (hour or 2), I need to reset the arduino to regain connection as I get the error “arduino uno is offline”.
My code is as follows:
(it turns the heating on for either 1 hour or 3 hours)
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>
char auth[] = “325f0348e76c4a759330d8940d95d764”;
int pin3; //to read pin3
int pin4;
int x; //for the counter
int led= 9;
// the setup function runs once when you press reset or power the board
void setup()
{
// initialize digital pin 13 as an output.
Serial.begin(9600);
Blynk.begin(auth);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(led, OUTPUT);
x=0;
}
// the loop function runs over and over again forever
void loop()
{
Blynk.run();
////////////////////////////////////////////////////////Turn on heat for 4 hours/////////////////////////////////////
pin4= digitalRead(4);
if (pin4==HIGH && x<14400) // run 5 loops at 1second each
{
Serial.println(‘1’);
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
x=x+1;
Serial.println(x);
}// wait for a second
else
{
digitalWrite(led, LOW);
}
if (pin4== LOW)
{
x=0;
}
/////////////////////////////////////////////////////Turn on heat for 1 hours//////////////////////////////////////////
pin3= digitalRead(3);
if (pin3==HIGH && x<3600) // run 5 loops at 1second each
{
Serial.println(‘1’);
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
x=x+1;
Serial.println(x);
}// wait for a second
else
{
digitalWrite(led, LOW);
}
if (pin3== LOW)
{
x=0;
}
}