I have ESP8266 project working with battery.
The deepsleep in this project work fine.
But problem is, how to stop draining battery when the ESP8266 can’t connect to wifi?
i thought, Blynk.connect(); has 30 sec timout and after this timeout esp8266 starts deepsleep.
But if i lost connection i have still 70 mA consumption till connection is back.
define ONE_WIRE_BUS 2
define TEMPERATURE_PRECISION 12
OneWire oneWire(2);
DallasTemperature sensors(&oneWire);
DeviceAddress thermometer1, thermometer2;
char auth[] = “”;
void setup()
{
Blynk.begin(auth, “”, “”);
sensors.begin();
sensors.getAddress(thermometer1, 0);
sensors.getAddress(thermometer2, 1);
sensors.setResolution(thermometer1, TEMPERATURE_PRECISION);
sensors.setResolution(thermometer2, TEMPERATURE_PRECISION);
Blynk.connect();
}
void sendTemps()
{
sensors.requestTemperatures();
float tempC1 = sensors.getTempC(thermometer1);
float tempC2 = sensors.getTempC(thermometer2);
Blynk.virtualWrite(1, String(tempC1, 1));
Blynk.virtualWrite(2, String(tempC2, 1));
delay(100);
}
void loop()
{
Blynk.run();
sendTemps();
ESP.deepSleep(300 * 1000000); // 300 sec
delay(100);
}