The project disconnected although “blynk.notify” is in the timer for 5 seconds.
• Arduino UNO + Ai thinker A6
• Blynk server
• Blynk Library version 0.6.5
• TinyGSM Library version 0.7.7
#define TINY_GSM_MODEM_A6
//#define BLYNK_HEARTBEAT 30
#include <TinyGsmClient.h>
#include <BlynkSimpleTinyGSM.h>
#include <Wire.h>
#include "ClosedCube_SHT31D.h"
#include <LiquidCrystal.h>
#define HUMI V2
#define TEMP V1
#define LEVEL V0
#define REAL_LEVEL V5
// Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial
// You should get Auth Token in the Blynk App.
char auth[] = "cd66085a0c784370b4e3ba8f9686c376";
// Your GPRS credentials
char apn[] = "v-internet";
char user[] = "";
char pass[] = "";
TinyGsm modem(SerialAT);
BlynkTimer timer;
ClosedCube_SHT31D sht35;
int fireLevel = 2,oldFireLevel = 2, count;
float humidity, temperature, I, errorCode;
//LCD16x2
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup()
{
// Set GSM module baud rate
SerialAT.begin(115200);
lcd.begin(16, 2);
welcomeLCD();
Wire.begin();
sht35.begin(0x44); // I2C address: 0x44 or 0x45
sht35.periodicStart(SHT3XD_REPEATABILITY_HIGH, SHT3XD_FREQUENCY_10HZ);
// Restart takes quite some time
// To skip it, call init() instead of restart()
modem.restart();
// Setup a function to be called every second
timer.setInterval(1234L, oneSecondEvent);
timer.setInterval(5000L, myTimerEvent);
Blynk.begin(auth, modem, apn, user, pass);
Blynk.syncAll();
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
void oneSecondEvent()
{
getsResult(sht35.periodicFetchData());
}
void myTimerEvent()
{
Blynk.virtualWrite(HUMI, humidity);
Blynk.virtualWrite(TEMP, temperature);
I = (humidity/20) + ((27-temperature)/10);
if (I > 4) fireLevel = 1;
else if (2.5 < I && I <= 4) fireLevel = 2;
else if (2.0 < I && I <= 2.5) fireLevel = 3;
else if (1.5 < I && I <= 2.0) fireLevel = 4;
else if (I <= 1.5) fireLevel = 5;
Blynk.virtualWrite(LEVEL, fireLevel);
if(oldFireLevel != fireLevel)
{
oldFireLevel = fireLevel;
Blynk.notify("ALARM");
}
}