Further data. I have now replaced the DHT sensor with a BME280 sensor (and now send the pressure as well).
I have also included a virtual LED to show whether the sensor is getting valid data.
This time, the code ran for about 6 hours before failing to send data. The LED is indicating that the sensor is failing to return valid values.
I’ve restarted it and am waiting to see how long it runs for now.
It seems rather unlikely that 2 different sensors of 2 different types are both faulty, and in the same way that they work for a while then stop sending data. (I’m not exposing them to any harsh environment etc.)
As the DHT and BME devices don’t work in the same way (one is I2C based, the other is not), it seems rather unlikely that their respective libraries are in each case the cause of the problem, and more likely that something unchanged as at the base of this.
That leaves us with several possibilities
(1) fault in my code - it is given above and is very simple, and if anyone can see a problem with it, I will gladly be enlightened and apologise
(2) faulty ESP8266 board - if all else fails, I have another on order and will try that
(3) problem in ESP8266 Arduino core
(4) problem in Blynk routines
If anyone can see other possibilities to 1-4 above, please chip in.
In fact, Googling a bit shows that quite a few people have problems with their ESPs losing network connectivity after a while, but that does not seem to be the same issue. I am not losing network connectivity - my Blynk app on my phone shows the ESP as connected all the time.
If the sensors are not faulty, I suspect what I am seeing is faulty program behaviour, due to either memory corruption or resource exhaustion, in either ESP core or Blynk libraries. (This may or may not be triggered or exacerbated by a similar cause to whatever is causing other people to lose net connectivity with their ESP 8266s.)
My previous suggestion of overflow due to it being 4.5 days can now obviously be ruled out, as the error occurred after just a few hours in the new code.
To try to constructively take this further, and try to track down where the issue might lie:
(1) Is there anyone on here who has successfully run an ESP8266 continuously with ongoing network activity, without issue over several weeks or more?
(2) and was it using Blynk?