The formal update of my coding - with a little extra.
To the problem, I changed the timers to be called at 30s intervals with a 2 second delay between each as suggested by Pete. This is my last hope.
In addition to everything, I had decided to (for my own entertainment) add some code to display uptime of my device on Virtual Pin V2.
I have adapted the code from another user for the conversion of units to days/hrs/mins etc.
The original code can be found at Converting millis to Sec or Hours for Uptime Display
Here is my code that seems to be working after 13 minutes and counting.
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <DHT.h>
#include <blynk.h>
SimpleTimer timer;
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxx"; //Blynk App auth Token
char server [] = "blynk-cloud.com";
char ssid[] = "xxxxxxxxxxxxxx"; //WiFi name
char pass[] = "xxxxxxxxxxxxx"; //WiFi password, set password to "" for open networks
unsigned int port = 8442;
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
#define DHT1PIN 5 // What digital pin we're connected to
#define DHT2PIN 12
#define DHT1TYPE DHT11 // DHT 11
#define DHT2TYPE DHT11 // DHT 11
DHT dht1(DHT1PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT2TYPE);
void sendSensor1()
{
float h = dht1.readHumidity();
float t = dht1.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
void sendSensor2()
{
float h2 = dht2.readHumidity();
float t2 = dht2.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h2) || isnan(t2)) {
Serial.println("Failed to read from DHT sensor 2!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V7, h2);
Blynk.virtualWrite(V8, t2);
}
void setup()
{
Serial.begin(9600); // Debug console
EspSerial.begin(ESP8266_BAUD); // Set ESP8266 baud rate
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
dht1.begin();
dht2.begin();
timer.setInterval(30000L, sendSensor1); // Setup a function to be called every 10 seconds
delay(2000L);
timer.setInterval(30000L, sendSensor2);
delay(2000L);
timer.setInterval(1000L, uptime);
}
void uptime()
{
long ms = millis();
long days = 0;
long hours = 0;
long mins = 0;
long secs = 0;
String secs_o = ":";
String mins_o = ":";
String hours_o = ":";
secs = ms / 1000; // set the seconds remaining
mins = secs / 60; //convert seconds to minutes
hours = mins / 60; //convert minutes to hours
days = hours / 24; //convert hours to days
secs = secs - (mins * 60); //subtract the coverted seconds to minutes in order to display 59 secs max
mins = mins - (hours * 60); //subtract the coverted minutes to hours in order to display 59 minutes max
hours = hours - (days * 24); //subtract the coverted hours to days in order to display 23 hours max
if (secs < 10) {
secs_o = ":0";
}
if (mins < 10) {
mins_o = ":0";
}
if (hours < 10) {
hours_o = ":0";
}
String disptime = days + hours_o + hours + mins_o + mins + secs_o + secs;
Blynk.virtualWrite(V2, disptime);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates SimpleTimer
}
I will update this thread with new information as it comes along.