Hello ,
I’m very new in Blynk, i have project for my school, i got my Arduino Uno and ESP8266 01 and DHT22 temperature sensor, everything is running well except when the internet connection is loss and Blynk goes offline and when the internet connection goes back but Blynk stay offline, the only thing can make it online again is by reset the arduino , or power off and on again the arduino or to open the serial monitor. Is there anyways to make Blynk goes back to online automaticaly? i have been searching this topic but it doesn’t solve my problem. any help will be greatly appreciated. sorry for my broken English.
#include "DHT.h"
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "EYHnZN41eSCvoZdSyK8CnUciHKUeoAGP";
char ssid[] = "xxxxxxx";
char pass[] = "xxxxxxx";
BlynkTimer timer;
//komunikasi ardu dengan ESP01
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(9, 10); // RX, TX
#define ESP8266_BAUD 9600 //untuk komunikasi ardu dgn ESP jgn diganti
ESP8266 wifi(&EspSerial);
//dht22
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
float t, h;
void myTimerEvent()
{
awal:
t = dht.readTemperature();
h = dht.readHumidity();
if (isnan(h) || isnan(t))
{
Serial.println(F("Sensor DHT ERROR/Blm Terpasang!"));
goto awal;
}
//serial monitor
Serial.print("Suhu : ");
Serial.print(t);
Serial.print(" *C | Humd : ");
Serial.print(h);
Serial.println(" %");
//blynk
Blynk.virtualWrite(V1, t); //kirim suhu ke blynk di virtual1
Blynk.virtualWrite(V2, h); //kirim humd ke blynk di virtual2
if (t > 28)
{
//isi email yg mau dirik niotifikasi
Blynk.email("xxxxxx@gmail.com", "Notifikasi DHT22 - Suhu melebihi 28C!");
Blynk.notify("Notifikasi DHT22 - Suhu melebihi 28C!");
}
}
void setup()
{
Serial.begin(115200); //untuk serial monitor di Arduino IDE
dht.begin();
delay(10);
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
timer.setInterval(2000L, myTimerEvent);
}
```cpp
void loop()
{
Blynk.run();
timer.run();
}