And another observation… please repost both the serial monitor output an the actual sketch that generated it… you two prior displayed are NOT one from the other, as evidenced in the time printout: If you changed that, what else might you have changed that could generate the 2nd connect msg?
I took out the blink.connect loop and the 2nd connect is now gone.
I still have a problem:
Wake time sometimes (every 30-40 times) goes to over 300 seconds… when it is normally 2-4 seconds.
Here is the updated output.
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld
⸮
Temp :73.40
RSSI:-43
**Wake time : 1.93**
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld
⸮
Temp :73.40
RSSI:-43
**Wake time : 4.40**
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld
⸮
Temp :73.40
RSSI:-48
**Wake time : 302.99**
and the updated code:
// #define BLYNK_PRINT Serial
#include <Blynk.h>
// #define BLYNK_DEBUG
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Arduino.h>
extern "C" {
#include <user_interface.h>
}
/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h>
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board - GPIO02
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float tempF;
unsigned long starttime;
float waketime;
// how long to sleep between checking TX temp/rssi values - in seconds
#define SLEEP_LENGTH 15
// Blynk auth
char auth[] = "xxxxxxxxxxxxxx";
/* WiFi credentials */
char ssid[] = "xx";
char pass[] = "xxxx";
void setup()
{
starttime = millis();
Serial.begin(74880); // default wake up baud after rst
DS18B20.begin();
DS18B20.setResolution(10);
DS18B20.requestTemperatures();
WiFi.setOutputPower(0);
Blynk.begin(auth, ssid, pass);
// while (Blynk.connect() == false) {
// Serial.print("atempting Conection"); //Wait until connected
// }
// Blynk.run();
tempF = DS18B20.getTempFByIndex(0);
Serial.print("\n Temp :");
Serial.println(tempF);
long rssi = WiFi.RSSI();
Serial.print("\ RSSI:");
Serial.println(rssi);
Blynk.virtualWrite(10, tempF); //virtual pin V10
Blynk.virtualWrite(11, rssi); //virtual pin V11
waketime = (millis() - starttime) / 1000.0;
Blynk.virtualWrite(13, waketime ); //virtual pin V13
Serial.print("\n Wake time : ");
Serial.println(waketime);
ESP.deepSleep(SLEEP_LENGTH * 1000000, WAKE_RF_DEFAULT); //try the default mode
delay(100);
}
void loop()
{
//do nothing here.
//The Setup() function takes care of it all.
//as the ESP resets each time after it wakes from deep sleep
}
Sounds like something gets ‘stuck’ in the Blynk.begin() call.
I am now doing WiFi.begin and it seems to speed things up. (big delays in Blynk.begin…???)
I also had to resort to a sort of watchdog to get past these 300 seconds events…
I now get ‘wake time’ of ~1.9 seconds 90% of the time and once in a while, eit goes up to 2.98 and even up to 4,92 sec.
Watchdog kicks in ~1% of the time. (no connect for >15 seconds) so no big power on for 300 seconds.
// #define BLYNK_PRINT Serial
#include <Blynk.h>
#include <Ticker.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Arduino.h>
/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h>
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board - GPIO02
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
char auth[] = "xxxx7df9c35xxxxx910e242958xxxxxx";
#define SLEEP_LENGTH 60
//SSID of your network
char ssid[] = "cxxxxx";
//password of your WPA Network
char pass[] = "pxxxxxx";
int status;
float tempF;
unsigned long starttime;
float waketime;
volatile int watchdogCount = 0;
Ticker secondTick;
#define debug 1
#define results 0
void ISRwatchdog() {
Serial.print("*");
watchdogCount++;
if ( watchdogCount == 10 ) {
// Only print to serial when debugging
(debug) && Serial.println("The watch dog barks!");
ESP.deepSleep(SLEEP_LENGTH * 1000000, WAKE_RF_DEFAULT); //try the default mode
// ESP.reset();
}
}
void setup()
{
starttime = millis();
secondTick.attach(1, ISRwatchdog);
Serial.begin(74880); // default wake up baud after rst
WiFi.setOutputPower(0);
status = WiFi.begin(ssid, pass);
while ( status != WL_CONNECTED) {
(debug) && Serial.print(".");
status = WiFi.status();
delay(100);
}
Blynk.config(auth);
Blynk.connect();
DS18B20.begin();
DS18B20.setResolution(10);
DS18B20.requestTemperatures();
tempF = DS18B20.getTempFByIndex(0);
(results) && Serial.print("\n Temp :");
(results) && Serial.println(tempF);
long rssi = WiFi.RSSI();
(results) && Serial.print("\ RSSI:");
(results) && Serial.println(rssi);
Blynk.virtualWrite(10, tempF); //virtual pin V10
Blynk.virtualWrite(11, rssi); //virtual pin V11
waketime = (millis() - starttime) / 1000.0;
Blynk.virtualWrite(13, waketime ); //virtual pin V13
Serial.print("\n Wake time : ");
Serial.println(waketime);
//delay(100);
ESP.deepSleep(SLEEP_LENGTH * 1000000, WAKE_RF_DEFAULT); //try the default mode
//delay(100);
}
void loop () {}