Nodemcu disconnection using analog reading

i’m using
-NodeMCU V2
-Conection with wifi
-module sensor rain
-link sensor exemple (https://www.amazon.com.br/Módulo-Sensor-Detector-Arduino-Automação/dp/B07GJ614MG/ref=asc_df_B07GJ614MG/?tag=googleshopp00-20&linkCode=df0&hvadid=379721266747&hvpos=&hvnetw=g&hvrand=8038990947468667752&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=1001536&hvtargid=pla-919966941783&psc=1)

good morning i was testing a project and was having a continuous disconnection so i went testing part by part to find out where the error could be and got to the analog reading of a rain sensor. I did some basic tests with just a simple reading and it’s there. As soon as I start the node, blynk disconnects several times. I don’t know what could be wrong with this. This simple example seems very clear and correct.



#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = " -";
  char ssid[] = " ";
  char pass[] = " ";
BlynkTimer timer;


void myTimerEvent()
{
 int  sensorData = analogRead(A0);
  Blynk.virtualWrite(V7,sensorData);    
 
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  
  timer.setInterval(8000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run(); 
}

The sensor you have has the ability to be used in analogue mode, where the output voltage will vary depending on the amount of moisture present, or digital mode where the output will flip from LOW to HIGH when the threshold is reached.
The threshold for the digital output is adjusted using the potentiometer on the board.

It would be useful if you explain EXACTLY how raw sensor is connected to your NodeMCU, and whether you have any other connections to the NodeMCU (other than the USB connection to your PC).

What widgets do you have set-up in your app?

Also, have you tried using the sensor without any Blynk code, writing the results to the serial monitor?

Pete.

yes Peter. I tested everything before without the blynk and it is working normal without problems.
Is connected
vcc ----> 3.3v
gnd ----- gnd
A0 ------ A0
I’m not using it in digital mode.
I am using only one display in app with pin V7 for testing at the moment … to show the values ​​read. it is connected via usb to record the code and power during the tests

And does your NodeMCU run one of the simple Blynk sketches (such as Blynk blink) without any disconnection issues?

Pete.

Yes. I use it normally without this problem. I just did one more test just to be sure and there was no disconnection

I ended up realizing that whenever a timer in the code has this disconnection … using the blynk blynk there is no problem … I tested another example with a timer and same problem.

@PeteKnight i did other test with more two nodeMCU and both showed the same problem…so i think this problem it’s not with hardware.

Maybe you have a corrupted library file, or some other issues with your libraries?
Presumably your serial monitor gives some exception decoder info?

Pete.

I believe not, Pete, I haven’t had any recent problems that have been a library.
when open the monitor serial:

[20845] Connected to WiFi
[20845] IP: 192.168.0.116
[20845]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.6.1 on NodeMCU

[20925] Connecting to blynk-cloud.com:80
[23417] Ready (ping: 1237ms).

And what do you see in the serial monitor when the disconnections occur?

Pete.

[20877] Connecting to blynk-cloud.com:80
[25170] Login timeout
[27170] Connecting to blynk-cloud.com:80
[32325] Connecting to blynk-cloud.com:80
[35519] Login timeout
[37519] Connecting to blynk-cloud.com:80
[42677] Connecting to blynk-cloud.com:80
[45850] Login timeout
[47850] Connecting to blynk-cloud.com:80
[83784] Heartbeat timeout
[85787] Connecting to blynk-cloud.com:80
[90788] Connecting to blynk-cloud.com:80
[95789] Connecting to blynk-cloud.com:80

@PeteKnight could you tell me the version of the library you are using esp8266, blynk? and arduino too please…because I know that there are versions of arduino in which there is a bug that cannot be recorded on esp.

Blynk Library 0.6.1
Arduino IDE 1.8.13
ESP Core 2.7.4

Pete.