(Display Widget's output of DHT22 data ) Stops working after a few days

Ah yes that will be the difference between my two screenshots.

Easy enough to check

Just drop this code into your void setup() and assign a display widget to vPinā€¦ adjust timing if desired and watch the results over time & conditions.

The data will be a negative number, with the smaller the number (towards 0) meaning the stronger the signal. e.g. My ESP-01 is the furthest away from router and the weakest signal, but still respectable -61 to -64.

  // Timed Lambda Function - RSSI display
  timer.setInterval(4500L, []() {
    Blynk.virtualWrite(vPin, WiFi.RSSI());
  });  // END Timer Function

Thanks all for the observations on the differences in scale, which I had not seen - I assumed the scales were carried over too, which of course they were not.

Thanks too for the observations on NaNs etc, but I was trying to avoid screwing up my minimum and maximum observations if the sensor goes haywire. In this project, it is important to know the real maximum and minimum temperatures (and less so humidities), as they are important in monitoring that a control system is working as intended.

The good news is I got a new Lolin Nodemcu today. The bad news is it was dead on arrival. At least, although I could connect to the serial chip, no lights lit up, and any attempt to talk to the ESP8266 failed - not just programming it, but any contact with esptool.

However, back to good news - I did manage to find a spare Wemos D1 (not mini, not R2 but R1 - original), and have put the revised code below into that, having appropriately changed the pins used for SDA and SCK.

To avoid any issue with the button, as pointed out by Costas, the code has now been cleaned up as follows (I also changed units to hPa to avoid the need to divide by 100). (Other parts omitted, as unchanged, apart from pin assignments).

int resetLimits = 0; // flag to say if limits need to be reset

BME280I2C bme;    // Default : forced mode, standby time = 1000 ms
                  // Oversampling = pressure Ɨ1, temperature Ɨ1, humidity Ɨ1, filter off,

BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
BME280::PresUnit presUnit(BME280::PresUnit_hPa);

BlynkTimer timer;
WidgetLED led(V10);

float t, tmin, tmax, h, hmin, hmax, p;

BLYNK_WRITE(V0) {  resetLimits = 1;        } // Button to reset limits
BLYNK_WRITE(V1) {  hmin = param.asFloat(); } // For data coming from server
BLYNK_WRITE(V2) {  hmax = param.asFloat(); }
BLYNK_WRITE(V3) {  tmin = param.asFloat(); }
BLYNK_WRITE(V4) {  tmax = param.asFloat(); }

void sendSensor()
{
  bme.read(p, t, h, tempUnit, presUnit);
  
  if (isnan(p) || isnan(t) || isnan(h)) {
    Serial.println("Failed to read from  sensor!");
    led.setColor(RED);
    return;
  }
  
  led.setColor(GREEN);
  
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
  Blynk.virtualWrite(V9, p); 

  if(h<hmin || isnan(hmin) || resetLimits == 1) { hmin=h; Blynk.virtualWrite(V1, h); }
  if(h>hmax || isnan(hmax) || resetLimits == 1) { hmax=h; Blynk.virtualWrite(V2, h); }
  if(t<tmin || isnan(tmin) || resetLimits == 1) { tmin=t; Blynk.virtualWrite(V3, t); }
  if(t>tmax || isnan(tmax) || resetLimits == 1) { tmax=t; Blynk.virtualWrite(V4, t); }

  resetLimits = 0; // clear any request to reset limits
}

So, now we can wait and see how long that runs for. Iā€™m hoping at this point it will be fine, given that others were not having problems with their long running code. Iā€™ll let you all know what happens in due course.

Iā€™m curious what youā€™re using ESPtool for in this scenario?

What happens if you connect the ESP to your PC, open the Arduino IDE and select the correct COM port, open the serial monitor and choose 74880 baud then press the reset button on the MCU?

Pete.

I was ONLY using esptool as an alternative to Arduino to give me some debugging clue as to what the device was doing and why I couldnā€™t program it with Arduino. I had already tried the ā€œserial monitor with 74880 baud and resetā€ routine, and itā€™s as dead as a dodo. I got no response from any debugging approaches I tried. After 1/2 hour I gave up. Given that it costs Ā£2, itā€™s hardly worth wasting a lot of effort on it. Iā€™m certainly not going to get the scope outā€¦

When you power it up, is it broadcasting an SSID?

No, the new one does not broadcast an SSID. I hadnā€™t thought of checking that, but it is indeed further evidence that it is dead. Anyway, letā€™s not get too distracted by the dead one. Thatā€™s another story for another day. :neutral_face:

PS I did hook the dead one up to an external power supply just in case, but that didnā€™t help either.

The (tidied up) code has been running OK for 18 hours so far on the Wemos D1. Iā€™ll report further in a few days, or if it locks upā€¦

Bugs in ESP8266 Arduino core, would you believe that ESP8266 Arduino Core Bug - hostname and DHT22 etc ?

Maybe we should all ask Arduino for our money back :wink:

My BME sensors arrived yesterday so Iā€™ve set-up a couple of NodeMCU 1.0ā€™s running @ralphrmartinā€™s original BME code (not the tidied-up version as I didnā€™t want any ambiguity about the changes).
One is in the spare room and the other on the loft and theyā€™ve been running since 20:15 yesterday. Iā€™ll keep an eye on them over the next week or so and see if they continue working okay.

Pete.

Nice one @PeteKnight

My clone of the project has been running for 3 days without any problems. Not even a reset from the ESP which you can expect with a sub $5 product.

Mine has also been running for over 2.5 days now without issue. However, before it was failing repeatably after about 4.5 days.

Reading that bug report you pointed to, this seems to be hitting the nail on the head:
ā€œProposal 2 does fix the dhcp hostname issue, and the DHT22 seems to be happy, too. Iā€™m betting something was referencing the non-initialized hostname and clobbering stuff. Iā€™ll close this issue once the fix is merged into master, or you can, whenever.ā€

Anyway, thanks everyone for the community support, which I do appreciate.

@ralphrmartin we are just trying to wind you up.

I think we all welcome bug reports as it makes the system better for everyone but thereā€™s a right way and your way :slight_smile:

2 Likes

And there is a right way to respond too. Moving my topic from ā€œBugs and Issuesā€ to ā€œI need help with my sketchā€ is rather insulting, if you ask me. :face_with_raised_eyebrow:

are you now convinced I am wound up enough?! :rofl:

Thatā€™s standard practise until something is shown to be a problem as it takes developers away from developing the project.

In your case there was never an indication that there was a problem with Blynk.

And no-one gave me any indication there was anything wrong with my project eitherā€¦ :rofl:

Check the thread again.

1 Like

That came AFTER my project was moved, and as we have seen, was a red herringā€¦

By the way, if you want a REAL, definite bug in blynk, rather than the ESP libraries - when I open my project in my (android) phone, the superchart normally just sits there showing ā€œloadingā€, more or less indefinitely, yet if I switch to a different time period and back again immediately, the chart shows up straight away. Thereā€™s clearly a logic error somewhere thereā€¦