Hi,
I have 2 Arduinos , which are connected to a local Blynk Server.
In the beginning,the system is running normally, but after one minute one or both of connections are lost. After few seconds, they are re-connected to themselves. Why?What should i do to fix it?
Also, i use a variable(Int), which i have initialized at zero in the beginning of the code as global variable, to measure something, but when connection is lost this variable re-becomes zero and loses its price.
How and where i should place it , in order not to lose her price,when the link is lost???
I don’t know
Hmm… Perhaps you should reveal this mysterious code working on those devices?
What internet connection method are you using - Ethernet shields, ESP-01 etc?
What happens if you use just one Arduino on its own?
Is your power supply adequate?
Pete.
Good Morning…Pete
I use Arduno Uno Wifi,so the wifi-shield is incorporated.
if I use one Arduino, the same happens!
Can you post your code?
Pete.
Is there any Wizard Out there??
How can we even TRY to help, without knowing the code creating issues? If we are unauthorised to look at it, then you probably need to sort it out by yourself.
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#include <SPI.h>
#include <WiFiLink.h>
#include <BlynkSimpleWifiLink.h>
char auth[] = "ecd7fe065c3841f9b2a911fca13a475f"; //gia oooo mara.v
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "VODAFONE_WIFI_108";
char pass[] = "NRGGEPYYJK";
const int tempSensor = A3;
const int flameSensor = A2;
const int gasSensor = A1;
const int k = 0;
#define ledYellow = 2
#define ledGreen = 4
#define ledRed = 6
float temperature;
int isFlame;
int isGas;
BlynkTimer timer;
WidgetLED led1(V5);
WidgetLCD lcd(V10);
WidgetMap myMap(V11);
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V4, temperature);
Blynk.virtualWrite(V3, isFlame);
Blynk.virtualWrite(V1, isGas);
}
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass,IPAddress(192,168,2,3));
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
pinMode(6, OUTPUT);
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
int index = 1;
float lat = 51.5074;
float lon = 0.1232;
myMap.location(index, lat, lon, "Arduino 1");
timer.setInterval(60000L, myTimerEvent);
}
void loop() {
int k;
int value = analogRead(tempSensor);
float millivolts = (value / 1024.0) * 5.0 ;
temperature = (millivolts - 0.5) * 100 ;
isFlame = analogRead(flameSensor);
isGas = analogRead(gasSensor);
delay(20000);
if(temperature >= 25 && isFlame < 1000 && isGas > 100) {
digitalWrite(2, HIGH);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
Serial.println("FIRE!!!");
lcd.print(4,0, "fwtia!!");
//Blynk.notify("Danger_1!!!");
k = k + 1;
if(k == 3){
Serial.println("mphkee");
Blynk.notify("Danger_1!!!");
k = 0;
}
led1.on();
}
else if(isGas > 100 && temperature >= 25) {
digitalWrite(2, HIGH);
digitalWrite(6, HIGH);
Serial.println("FIRE!!");
lcd.print(4,0, "fwtia!!");
//Blynk.notify("Danger_1!!");
k = k + 1;
if(k == 3){
Serial.println("mphke2");
Blynk.notify("Danger_1!!");
k = 0;
}
led1.on();
}
else if(isGas > 100 && isFlame < 1000) {
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
Serial.println("FIRE!");
lcd.print(4,0, "fwtia!!");
//Blynk.notify("Danger_1!!");
k = k + 1;
if(k == 3){
Serial.println("mphke3");
Blynk.notify("Danger_1!!");
k = 0;
}
led1.on();
}
else {
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
Serial.println("NO FIRE");
lcd.print(4,0, "no fire");
led1.off();
}
Blynk.run();
timer.run();
}
I fixed your code formatting…
Now you should fix your code… bad use of code in the void loop()
… and a 20 second delay in the middle of it…wow…