Blynk provisioning project automatically resets and enters config mode after some time

I started messing around with the Esp8266 Template for Hardware Provisioning and managed to set up a dummy project that controlled a simple LED, and implemented the Blynk Provisioning Flow.

I connected the project for hours and had no problem with the provisioning or the Board automatically entering config mode on its own.

But then I added a DHT 11 sensor to the project that reads the values of Temp and Humidity and sends them to the app to be displayed in two Gauges. This is done with a BlynkTimer with 1 sec frequency.

When I added this the provisioning part started to fail. The board cannot stay connected more than 2 Hours before automatically entering config mode on its OWN and becoming a WiFi AP to start the provisioning process again.

Does anyone know about this issue? Maybe my board is sending to many values to the Blynk server (Temp and Humidity every 1 sec, only if they changed) and is getting disconnected and somehow entering config mode on its own.

I have set the value BUTTON_ACTIVE_LOW as FALSE in SETTINGS.H and grounded the Reset pin (in my case I set it to D5), so that cannot be the issue.

The board works fine when I comment out all of the DHT sensor code and only leave the LED blinking part, so this issue must have something to do with the sensor part of the code.

I’m glad if anyone can help me solve this issue.

This is the simple code in my sketch:


//define USE_SPARKFUN_BLYNK_BOARD    // Uncomment the board you are using
#define USE_NODE_MCU_BOARD        // Comment out the boards you are not using
//#define USE_WITTY_CLOUD_BOARD
//#define USE_CUSTOM_BOARD          // For all other ESP8266-based boards -
                                    // see "Custom board configuration" in Settings.h

#define APP_DEBUG        // Comment this out to disable debug prints

#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h>
#include "BlynkProvisioning.h"

#include <DHT.h>
#define DHTPIN 5          // What digital pin we're connected to: 5 (D1)
#define DHTTYPE DHT11     // DHT 11
DHT dht(DHTPIN, DHTTYPE);

BlynkTimer timer;

void setup() {
  delay(500);
  
  pinMode(0,OUTPUT); //Sets Pin D3 as output pin for controlling the LED
  digitalWrite(0,LOW); //Initializes D3 pin as LOW
  
  Serial.begin(115200);

  BlynkProvisioning.begin();
  timer.setInterval(1000L, sendSensor);
}

void loop() {
  // This handles the network and cloud connection
  BlynkProvisioning.run();
  timer.run();
}

BLYNK_WRITE(V1) {
  int pinData = param.asInt();

  if(pinData == 1) {
    //When BUTTON 1 binded to V1 in APP is pressed then turn LED ON
    digitalWrite(0,HIGH);
  }
}

BLYNK_WRITE(V2) {
  int pinData = param.asInt();

  if(pinData == 1) {
    //When BUTTON 2 binded to V2 in APP is pressed then turn LED OFF
    digitalWrite(0,LOW);
  }
}

float dh, dt = 0;

void sendSensor()
{
  float h = dht.readHumidity();
  delay(100);
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  } else { 
      //Only send value to server if Humidity differs from previous sent value
      if(h != dh) {
        dh = h;
        Blynk.virtualWrite(V5, h);
      }
    
      //Only send value to server if Temperature differs from previous sent value
      if(t != dt) {
        dt = t;
        Blynk.virtualWrite(V6, t);
      }
  }
  
}


A DHT11 is a very slow sensor… It is recommended not to try reading it any faster then once every 5 seconds… and even then, why???.. unless you are doing scientific research (with a DHT :stuck_out_tongue: ) in some very strange climate conditions, every 5 -10 minutes is plenty sufficient.

Hahahah, I have to admit I was lazy while trying to view the DHT outputs and not have to wait 10 seconds for them to update.

I will set the refresh rate to 5 sec and see what happens.

But deep inside me it still bugs me and I still want to know how is it that the DHT sensor is somehow interfering with the Hardware Provisioning part, you can see in my code that it has absolutely no access to it.

I’ll check back with updates :grinning:

I don’t know how Blynk Provisioning works… no need for it in my uses. But it may be more susceptible to overactive tasks, causing a heartbeat timeout or something?

Yeah but even if that was the issue, the board should just reset and reconnect with the previous credentials the user passed in the last Provisioning config call. But instead it resets and becomes a WiFi AP, wich happens when you start the Provisioning process.

This provisioning config call (to pass NEW credentials to the board) is only made when you press the RST button (setting the D5 pin to HIGH) for 10 secs. This really has nothing to do with the sensor.

I have no clue how the config flow is being automatically called, given that D5 is grounded all the time.

Are you sure you didn’t mix something up and thinking you set the provisioning button for D5 (GPIO14) you set it for the same pin 5 (GPIO5 - AKA D1) as is the DHT sensor?

Mixing the silkscreened designations with the GPIO/Arduino designations can cause mixups like that… always best to use the GPIO/Arduino designations.

You can see in my sketch that I use the Arduino designations. The RST pin is set to GPIO 14 (D5) in Settings.h and DHT pin is set to GPIO 5 (D1) in the sketch. There is no confusion there.

I have now read online that maybe I need a pull-up resistor between Vcc and Data pins in the DHT 11, maybe that could be the issue. I’ve put a 300 Ohm resistor connecting them. I’ll check back with the results.

In one of the examples of the DHT’s library it says:
“Reading temperature or humidity takes about 250 milliseconds!”
I.e. at least 600ms delay in the “sendSensor()” function used here.
This could cause a wdt reset at some point in time.

I would suggest to separate the reading of humidity and temperature into two separate functions that don’t run simultaneously and to delete the delay(100).

This issue was reported multiple times already, we need to investigate.
Currently, could not reproduce on our side. The more info we get on the issue - the better.

2 Likes

Hey guys, checking back here.

I left the board connected all night last night and this issue no longer ocurrs.

All I did was what I told you guys in my last answer: I added a 300 Ohm Pull-up resistor between Vcc and Data pins of my DHT.

The frequency of the timer is still 1 sec, and I haven’t touched the sketch I sent above. But I will incorporate every precaution you guys pointed out.

So apparently just adding a Pull-up resistor between Vcc and Data pins has stopped the auto resetting issue. Maybe, without this resistor, the DHT was setting the D5 pin to HIGH after some time, given that I grounded the D5 in the same node where the DHT GND pin connects to ground. It sounds dumb, but I cannot imagine any other explanation.

I will send you the schematics, and a copy of the project to see if anyone interested can reproduce it on their side, @vshymanskyy. Let’s use the scientific method for once :slight_smile: .

I’ll be back with the files

So this is the original schematic (without the Pull-up resistor) that makes the Nodemcu Board enter into config mode by itself:

And this is the project:

If anyone is interested in trying to reproduce this error.

Note: Vcc is +5V supplied by an LG phone charger. Charger output specs are: 5V DC, 1.2A.
Note 2 The DHT11 sensor I use is the 4 pin blue sensor. I see online that there are some versions that come with an IC that includes the pull up resistor between Vcc and Data pins.

Pic of the exact DHT11 I use:

1 Like