VirtualWrite crashes the execution of sketch

The problem is that when in my sketch I include Blynk.virtualWrite, the program hangs at Blynk.begin(). If I comment out all the writes or the whole function that sends data to blynk the program works.

For Software, I’m using Arduino IDE 1.8.9. with AVR boards 1.6.21 and Blynk 0.6.1.
Hardware is Nano with ESP8266 as shield via software serial.

Serial output without any writes:

13:46:01.859 -> Starting in debug mode
13:46:01.859 -> ----------------------------
13:46:01.892 -> 
13:46:02.268 -> 1
13:46:02.268 -> 2
13:46:02.334 -> 3
13:46:02.334 -> [462] 
13:46:02.334 ->     ___  __          __
13:46:02.368 ->    / _ )/ /_ _____  / /__
13:46:02.368 ->   / _  / / // / _ \/  '_/
13:46:02.403 ->  /____/_/\_, /_//_/_/\_\
13:46:02.437 ->         /___/ v0.6.1 on Arduino Nano
13:46:02.471 -> 
13:46:02.946 -> [1057] Connecting to SYRION13417
13:46:06.113 -> [4231] AT version:0.51.0.0(Nov 27 2015 13:37:21)
13:46:06.147 -> SDK version:1.5.0
13:46:06.181 -> compile time:Nov 27 2015 13:57:56
13:46:06.181 -> OK
13:46:11.376 -> [9511] +CIFSR:STAIP,"192.168.254.107"
13:46:11.409 -> +CIFSR:STAMAC,"cc:50:e3:55:65:e2"
13:46:11.443 -> [9522] Connected to WiFi
13:46:21.739 -> [19865] Ready (ping: 25ms).
13:46:22.214 -> 4
13:46:22.283 -> bmeInside data:
13:46:22.283 -> t °C:	h %:	p hPa:
13:46:22.317 -> 28.86	48.32	981.33
13:46:22.317 -> state of charge: 0%
13:46:22.351 -> adc1 data:
13:46:22.351 -> BatV:20.65V

And with writes:

14:39:16.022 -> Starting in debug mode
14:39:16.022 -> ----------------------------
14:39:16.056 -> 
14:39:16.397 -> 1
14:39:16.397 -> 2
14:39:16.499 -> 3
14:39:16.499 -> [462] 
14:39:16.499 ->     ___  __          __
14:39:16.533 ->    / _ )/ /_ _____  / /__
14:39:16.533 ->   / _  / / // / _ \/  '_/
14:39:16.567 ->  /____/_/\_, /_//_/_/\_\
14:39:16.601 ->         /___/ v0.6.1 on Arduino Nano
14:39:16.635 -> 
14:39:17.078 -> [1057] Connecting to SYRION13417
14:39:20.243 -> [4230] AT version:0.51.0.0(Nov 27 2015 13:37:21)
14:39:20.277 -> SDK version:1.5.0
14:39:20.311 -> compile time:Nov 27 2015 13:57:56
14:39:20.345 -> OK
14:39:25.550 -> [9510] +CIFSR:STAIP,"192.168.254.107"
14:39:25.550 -> +CIFSR:STAMAC,"cc:50:e3:55:65:e2"
14:39:25.585 -> [9521] Connected to WiFi
14:39:35.898 -> [19868] Ready (ping: 25ms).

The sketch is all over the place with syntax and comments.


#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>

#include <Adafruit_ADS1015.h>

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define DEBUGMODE 1

#define SERIALDATRATE 9600
#define ESP8266_BAUD 9600

Adafruit_ADS1115 adc1;
Adafruit_BME280 bmeInside;

SoftwareSerial EspSerial(3, 2); // RX, TX

ESP8266 wifi(&EspSerial);

char auth[] = "";
char ssid[] = "";
char pass[] = "";


typedef const uint8_t pin;

struct adc0 {
	pin NTC = 0;
	pin MotorI = 1;
	pin AcIn = 2;
	pin AcOut = 3;
} pinAdc0;

struct adc1 {
	pin PvV = 0;
	pin PvI = 1;
	pin BatV = 2;
	pin BatI = 3;
} pinAdc1;

struct blynkPins {
	pin graphWattIn = V20;
	pin graphWattOut = V21;
	pin graphKWhSolar = V22;
	pin graphKWhAC = V23;
	
	pin graphBatCharge = V24;
	pin graphInTemperature = V25;
	pin graphBatVolt = V26;
	pin graphInPressure = V27;
	
	pin LCD0 = V5;
	pin LCD1 = V6;
	pin menuSwitch = V10;

	pin terminal = V0;
} pinBlynk;

// how often to update the data in ms
struct updateRateStruct {
	const uint16_t sensor = 1 * 1000;
	const uint16_t blynk = 1 * 60000;
	const uint32_t thing = 10 * 60000;
} updateRate;

struct sensorData {
	float inTemperature;
	float inHumidity;
	float inPressure;

	float pvVolt;
	
	float batVolt;
	int8_t batCharge;
} sensor;

// 1 000 000, 110 000
const float PvVoltageDividerRatio = 10.0919;

// 1 000 000, 147 000
const float BatVoltageDividerRatio = 8.1966;

#define ADC1REFVOLT 5.0
const float adc1BitPerVolt = 0.125;
adsGain_t adc1Gain = GAIN_ONE;

// voltage when battery is considered empty/full
const float batteryChargeVoltage[2] = {22.0, 27.15};

// -------------------------------------------------------------------

void sendBlynk(void);

void updateSensors(void);

void pollBmeInside(void);
void pollAdc1(void);

float calculateVoltage(int16_t adcOutput, float bitPerVolt, float voltageDividerRatio);

int8_t calculateBatteryCharge (float voltage);

uint8_t menuSwitch = 0;
uint32_t currentMillis = 0;

void setup() {

	#if DEBUGMODE
		Serial.begin(SERIALDATRATE);
		Serial.println("Starting in debug mode");
		Serial.println("----------------------------\n");
	#endif
	adc1.setGain(adc1Gain);
	adc1.begin();
	
	bmeInside.begin(0x76);
	Serial.println("1");
	
	EspSerial.begin(ESP8266_BAUD);
	Serial.println("2");
	delay(50);
	
	Serial.println("3");
	Blynk.begin(auth, wifi, ssid, pass);
	Serial.println("4");
}

void loop() {
	currentMillis = millis();
 
	Blynk.run();
  
	updateSensors();
	
	sendBlynk();
}

void updateSensors(){
	static uint32_t previousMillis = 0;
	
	if ((currentMillis - previousMillis) >= updateRate.sensor){
		previousMillis = currentMillis;
		
		pollBmeInside();
		pollAdc1();
	}
}

void pollBmeInside(){
	sensor.inTemperature = bmeInside.readTemperature();
	sensor.inHumidity = bmeInside.readHumidity();
	sensor.inPressure = (bmeInside.readPressure() / 100.0F);
	
	#if DEBUGMODE
		Serial.println("bmeInside data:");
		Serial.println("t °C:\th %:\tp hPa:");
		Serial.print(sensor.inTemperature);
		Serial.print("\t");
		Serial.print(sensor.inHumidity);
		Serial.print("\t");
		Serial.println(sensor.inPressure);
	#endif
}

void pollAdc1 (){
	
	int16_t adc1BatV = 0;
	
	adc1BatV = adc1.readADC_SingleEnded(pinAdc1.BatV);
	
	sensor.batVolt = calculateVoltage(adc1BatV, adc1BitPerVolt, BatVoltageDividerRatio);
	sensor.batCharge = calculateBatteryCharge(sensor.batVolt);
	
	#if DEBUGMODE
		Serial.println("adc1 data:");
		Serial.print("BatV:");
		Serial.print(sensor.batVolt);
		Serial.println("V");
	#endif
}

float calculateVoltage(	int16_t adcOutput,
						float bitPerVolt,
						float voltageDividerRatio){
	return (( (float) adcOutput * bitPerVolt) / 1000.0) * voltageDividerRatio;
}

int8_t calculateBatteryCharge (float voltage){
	
	int8_t val = (voltage - batteryChargeVoltage[0]) * 100 /
	(batteryChargeVoltage[1] - batteryChargeVoltage[0]);
	
	val = constrain(val, 0, 100);
	
	#if DEBUGMODE
		Serial.print("state of charge: ");
		Serial.print(val);
		Serial.println("%");
	#endif

	return val;
}

void sendBlynk(){
	static uint32_t previousMillis = 0;
	
	if ((currentMillis - previousMillis) >= updateRate.blynk){
		previousMillis = currentMillis;
		
		//Blynk.virtualWrite(pinBlynk.graphInTemperature, sensor.inTemperature);
		//Blynk.virtualWrite(pinBlynk.graphInHumidity, sensor.inHumidity);
		//Blynk.virtualWrite(pinBlynk.graphInPressure, sensor.inPressure);
		
		//Blynk.virtualWrite(V24, sensor.batCharge);
		Blynk.virtualWrite(V26, 10);
		
		#if DEBUGMODE
			Serial.println("blynk trig\n");
		#endif
	}
}
1 Like

And with the logic too!

You’re using a static local variable to store previousMillis and declaring it as zero each time this function is called (which is each time the void loop executes. Then you’re saying that if currentMillis minus zero is greater than the refresh rate of your sensor then execute two additional functions.
Millis() starts at zero and increments once every millisecond continuously until it reaches a number that’s too large to store as an unsigned long value (that takes around 49 days, at which point it resets to zero.
Assuming that the refresh rate of your sensor is around 1000 milliseconds then this “if” yest is going top be true from 1 second after boot-up until 49 days in the future, then it’s be false for a second, then true again.

So, you’re trying to take readings from your sensors every time the void loop executes (which could be thousands of times per second) and, more importantly, you’re calling the sendBlynk() function from your void loop every time the void loop is processed. This function also has the same flay as far as the previousMillis logic is concerned.

Read the document linked by @Blynk_Coeur until you fully understand it, then implement timers to call these functions and scrap your Millis() processing.

Pete.

2 Likes

You’re using a static local variable to store previousMillis and declaring it as zero each time this function is called

This is not how static keyword works.

more importantly, you’re calling the sendBlynk() function from your void loop every time the void loop is processed.

That is also false, as there is timer inside the sendBlynk() that executes every updateRate.blynk (60 seconds)

void sendBlynk(){
	static uint32_t previousMillis = 0;

	if ((currentMillis - previousMillis) >= updateRate.blynk){
		previousMillis = currentMillis;
		
		Blynk.virtualWrite(V26, 10);
		
		#if DEBUGMODE
			Serial.println("blynk trig\n");
		#endif
	}
}
13:42:38.587 -> bmeInside data:
13:42:38.587 -> t °C:	h %:	p hPa:
13:42:38.621 -> 28.94	48.17	981.34
13:42:38.621 -> state of charge: 0%
13:42:38.654 -> adc1 data:
13:42:38.654 -> BatV:20.64V
13:42:38.723 -> blynk trig
...
13:43:38.477 -> bmeInside data:
13:43:38.477 -> t °C:	h %:	p hPa:
13:43:38.511 -> 28.82	48.32	981.31
13:43:38.511 -> state of charge: 0%
13:43:38.545 -> adc1 data:
13:43:38.545 -> BatV:20.64V
13:43:38.682 -> blynk trig

The problem is that Blynk.begin() doesn’t finish it’s processing when there is virtualWrite anywhere in a sketch, you can see in the terminal that there is no “4” after 14:39:35.898 -> [19868] Ready (ping: 25ms). Meaning that the function Blynk.begin() didn’t finish executing.

Here is longer part of the terminal output, where there is no virtualWrites:

13:41:38.731 -> Starting in debug mode
13:41:38.731 -> ----------------------------
13:41:38.765 -> 
13:41:39.138 -> 1
13:41:39.138 -> 2
13:41:39.206 -> 3
13:41:39.206 -> [462] 
13:41:39.206 ->     ___  __          __
13:41:39.240 ->    / _ )/ /_ _____  / /__
13:41:39.240 ->   / _  / / // / _ \/  '_/
13:41:39.274 ->  /____/_/\_, /_//_/_/\_\
13:41:39.308 ->         /___/ v0.6.1 on Arduino Nano
13:41:39.344 -> 
13:41:39.786 -> [1057] Connecting to wifi
13:41:42.981 -> [4230] AT version:0.51.0.0(Nov 27 2015 13:37:21)
13:41:43.015 -> SDK version:1.5.0
13:41:43.049 -> compile time:Nov 27 2015 13:57:56
13:41:43.049 -> OK
13:41:44.027 -> [5298] Failed to enable MUX
13:41:47.240 -> [8501] +CIFSR:STAIP,"192.168.254.107"
13:41:47.274 -> +CIFSR:STAMAC,"mac"
13:41:47.308 -> [8511] Connected to WiFi
13:41:57.648 -> [18922] Ready (ping: 26ms).
13:41:58.157 -> 4
13:41:58.191 -> bmeInside data:
13:41:58.191 -> t °C:	h %:	p hPa:
13:41:58.224 -> 28.95	48.27	981.31
13:41:58.224 -> state of charge: 0%
13:41:58.258 -> adc1 data:
13:41:58.258 -> BatV:20.64V
13:41:59.212 -> bmeInside data:
13:41:59.212 -> t °C:	h %:	p hPa:
13:41:59.247 -> 28.95	48.27	981.31
13:41:59.247 -> state of charge: 0%
13:41:59.281 -> adc1 data:
13:41:59.281 -> BatV:20.64V
13:42:00.204 -> bmeInside data:
13:42:00.204 -> t °C:	h %:	p hPa:
13:42:00.238 -> 28.95	48.22	981.32
13:42:00.238 -> state of charge: 0%
13:42:00.272 -> adc1 data:
13:42:00.272 -> BatV:20.65V
13:42:01.221 -> bmeInside data:
13:42:01.221 -> t °C:	h %:	p hPa:
13:42:01.254 -> 28.95	48.18	981.33
13:42:01.254 -> state of charge: 0%
13:42:01.288 -> adc1 data:
13:42:01.288 -> BatV:20.65V
13:42:02.229 -> bmeInside data:
13:42:02.229 -> t °C:	h %:	p hPa:
13:42:02.263 -> 28.96	48.20	981.30
13:42:02.263 -> state of charge: 0%
13:42:02.297 -> adc1 data:
13:42:02.297 -> BatV:20.64V
13:42:03.216 -> bmeInside data:
13:42:03.216 -> t °C:	h %:	p hPa:
13:42:03.250 -> 28.95	48.18	981.26
13:42:03.250 -> state of charge: 0%
13:42:03.284 -> adc1 data:
13:42:03.284 -> BatV:20.65V
13:42:04.235 -> bmeInside data:
13:42:04.235 -> t °C:	h %:	p hPa:
13:42:04.269 -> 28.96	48.17	981.28
13:42:04.269 -> state of charge: 0%
13:42:04.303 -> adc1 data:
13:42:04.303 -> BatV:20.65V
13:42:05.253 -> bmeInside data:
13:42:05.253 -> t °C:	h %:	p hPa:
13:42:05.298 -> 28.96	48.16	981.32
13:42:05.298 -> state of charge: 0%
13:42:05.338 -> adc1 data:
13:42:05.338 -> BatV:20.65V
13:42:06.235 -> bmeInside data:
13:42:06.235 -> t °C:	h %:	p hPa:
13:42:06.274 -> 28.96	48.16	981.30
13:42:06.274 -> state of charge: 0%
13:42:06.301 -> adc1 data:
13:42:06.301 -> BatV:20.65V
13:42:07.254 -> bmeInside data:
13:42:07.254 -> t °C:	h %:	p hPa:
13:42:07.288 -> 28.95	48.14	981.30
13:42:07.288 -> state of charge: 0%
13:42:07.322 -> adc1 data:
13:42:07.322 -> BatV:20.65V
13:42:08.310 -> bmeInside data:
13:42:08.310 -> t °C:	h %:	p hPa:
13:42:08.344 -> 28.94	48.15	981.30
13:42:08.344 -> state of charge: 0%
13:42:08.378 -> adc1 data:
13:42:08.378 -> BatV:20.64V
13:42:09.261 -> bmeInside data:
13:42:09.261 -> t °C:	h %:	p hPa:
13:42:09.295 -> 28.94	48.17	981.32
13:42:09.295 -> state of charge: 0%
13:42:09.329 -> adc1 data:
13:42:09.329 -> BatV:20.65V
13:42:10.276 -> bmeInside data:
13:42:10.276 -> t °C:	h %:	p hPa:
13:42:10.309 -> 28.95	48.22	981.31
13:42:10.309 -> state of charge: 0%
13:42:10.342 -> adc1 data:
13:42:10.342 -> BatV:20.65V
13:42:11.287 -> bmeInside data:
13:42:11.287 -> t °C:	h %:	p hPa:
13:42:11.321 -> 28.95	48.22	981.34
13:42:11.321 -> state of charge: 0%
13:42:11.354 -> adc1 data:
13:42:11.354 -> BatV:20.65V
13:42:12.306 -> bmeInside data:
13:42:12.306 -> t °C:	h %:	p hPa:
13:42:12.340 -> 28.94	48.19	981.32
13:42:12.340 -> state of charge: 0%
13:42:12.340 -> adc1 data:
13:42:12.340 -> BatV:20.65V
13:42:13.293 -> bmeInside data:
13:42:13.293 -> t °C:	h %:	p hPa:
13:42:13.327 -> 28.93	48.19	981.31
13:42:13.327 -> state of charge: 0%
13:42:13.360 -> adc1 data:
13:42:13.360 -> BatV:20.65V
13:42:14.318 -> bmeInside data:
13:42:14.318 -> t °C:	h %:	p hPa:
13:42:14.318 -> 28.93	48.18	981.32
13:42:14.318 -> state of charge: 0%
13:42:14.352 -> adc1 data:
13:42:14.352 -> BatV:20.65V
13:42:15.303 -> bmeInside data:
13:42:15.303 -> t °C:	h %:	p hPa:
13:42:15.338 -> 28.93	48.19	981.31
13:42:15.338 -> state of charge: 0%
13:42:15.372 -> adc1 data:
13:42:15.372 -> BatV:20.65V
13:42:16.318 -> bmeInside data:
13:42:16.318 -> t °C:	h %:	p hPa:
13:42:16.352 -> 28.93	48.25	981.31
13:42:16.352 -> state of charge: 0%
13:42:16.386 -> adc1 data:
13:42:16.386 -> BatV:20.64V
13:42:17.334 -> bmeInside data:
13:42:17.334 -> t °C:	h %:	p hPa:
13:42:17.369 -> 28.93	48.22	981.30
13:42:17.369 -> state of charge: 0%
13:42:17.403 -> adc1 data:
13:42:17.403 -> BatV:20.65V
13:42:18.384 -> bmeInside data:
13:42:18.384 -> t °C:	h %:	p hPa:
13:42:18.418 -> 28.94	48.18	981.33
13:42:18.418 -> state of charge: 0%
13:42:18.451 -> adc1 data:
13:42:18.451 -> BatV:20.65V
13:42:19.366 -> bmeInside data:
13:42:19.366 -> t °C:	h %:	p hPa:
13:42:19.400 -> 28.94	48.18	981.30
13:42:19.400 -> state of charge: 0%
13:42:19.434 -> adc1 data:
13:42:19.434 -> BatV:20.65V
13:42:20.386 -> bmeInside data:
13:42:20.386 -> t °C:	h %:	p hPa:
13:42:20.420 -> 28.95	48.19	981.33
13:42:20.420 -> state of charge: 0%
13:42:20.454 -> adc1 data:
13:42:20.454 -> BatV:20.65V
13:42:21.371 -> bmeInside data:
13:42:21.371 -> t °C:	h %:	p hPa:
13:42:21.404 -> 28.95	48.18	981.32
13:42:21.404 -> state of charge: 0%
13:42:21.438 -> adc1 data:
13:42:21.438 -> BatV:20.65V
13:42:22.394 -> bmeInside data:
13:42:22.394 -> t °C:	h %:	p hPa:
13:42:22.428 -> 28.96	48.16	981.32
13:42:22.428 -> state of charge: 0%
13:42:22.462 -> adc1 data:
13:42:22.462 -> BatV:20.65V
13:42:23.414 -> bmeInside data:
13:42:23.414 -> t °C:	h %:	p hPa:
13:42:23.448 -> 28.95	48.14	981.32
13:42:23.448 -> state of charge: 0%
13:42:23.482 -> adc1 data:
13:42:23.482 -> BatV:20.65V
13:42:24.401 -> bmeInside data:
13:42:24.401 -> t °C:	h %:	p hPa:
13:42:24.435 -> 28.94	48.15	981.31
13:42:24.435 -> state of charge: 0%
13:42:24.468 -> adc1 data:
13:42:24.468 -> BatV:20.64V
13:42:25.426 -> bmeInside data:
13:42:25.426 -> t °C:	h %:	p hPa:
13:42:25.426 -> 28.93	48.17	981.30
13:42:25.426 -> state of charge: 0%
13:42:25.461 -> adc1 data:
13:42:25.461 -> BatV:20.65V
13:42:26.416 -> bmeInside data:
13:42:26.416 -> t °C:	h %:	p hPa:
13:42:26.450 -> 28.93	48.16	981.30
13:42:26.450 -> state of charge: 0%
13:42:26.484 -> adc1 data:
13:42:26.484 -> BatV:20.65V
13:42:27.436 -> bmeInside data:
13:42:27.436 -> t °C:	h %:	p hPa:
13:42:27.470 -> 28.93	48.16	981.31
13:42:27.470 -> state of charge: 0%
13:42:27.504 -> adc1 data:
13:42:27.504 -> BatV:20.65V
13:42:28.494 -> bmeInside data:
13:42:28.494 -> t °C:	h %:	p hPa:
13:42:28.528 -> 28.91	48.20	981.30
13:42:28.528 -> state of charge: 0%
13:42:28.562 -> adc1 data:
13:42:28.562 -> BatV:20.65V
13:42:29.480 -> bmeInside data:
13:42:29.480 -> t °C:	h %:	p hPa:
13:42:29.514 -> 28.90	48.20	981.30
13:42:29.514 -> state of charge: 0%
13:42:29.549 -> adc1 data:
13:42:29.549 -> BatV:20.65V
13:42:30.472 -> bmeInside data:
13:42:30.472 -> t °C:	h %:	p hPa:
13:42:30.505 -> 28.89	48.20	981.28
13:42:30.505 -> state of charge: 0%
13:42:30.538 -> adc1 data:
13:42:30.538 -> BatV:20.65V
13:42:31.483 -> bmeInside data:
13:42:31.483 -> t °C:	h %:	p hPa:
13:42:31.517 -> 28.89	48.19	981.31
13:42:31.517 -> state of charge: 0%
13:42:31.550 -> adc1 data:
13:42:31.550 -> BatV:20.64V
13:42:32.504 -> bmeInside data:
13:42:32.504 -> t °C:	h %:	p hPa:
13:42:32.537 -> 28.90	48.19	981.31
13:42:32.537 -> state of charge: 0%
13:42:32.571 -> adc1 data:
13:42:32.571 -> BatV:20.64V
13:42:33.488 -> bmeInside data:
13:42:33.488 -> t °C:	h %:	p hPa:
13:42:33.522 -> 28.90	48.20	981.31
13:42:33.522 -> state of charge: 0%
13:42:33.557 -> adc1 data:
13:42:33.557 -> BatV:20.64V
13:42:34.508 -> bmeInside data:
13:42:34.508 -> t °C:	h %:	p hPa:
13:42:34.542 -> 28.91	48.20	981.27
13:42:34.542 -> state of charge: 0%
13:42:34.576 -> adc1 data:
13:42:34.576 -> BatV:20.65V
13:42:35.523 -> bmeInside data:
13:42:35.523 -> t °C:	h %:	p hPa:
13:42:35.557 -> 28.92	48.21	981.31
13:42:35.557 -> state of charge: 0%
13:42:35.591 -> adc1 data:
13:42:35.591 -> BatV:20.64V
13:42:36.509 -> bmeInside data:
13:42:36.509 -> t °C:	h %:	p hPa:
13:42:36.543 -> 28.93	48.19	981.32
13:42:36.543 -> state of charge: 0%
13:42:36.577 -> adc1 data:
13:42:36.577 -> BatV:20.65V
13:42:37.530 -> bmeInside data:
13:42:37.530 -> t °C:	h %:	p hPa:
13:42:37.564 -> 28.94	48.19	981.31
13:42:37.564 -> state of charge: 0%
13:42:37.598 -> adc1 data:
13:42:37.598 -> BatV:20.64V
13:42:38.587 -> bmeInside data:
13:42:38.587 -> t °C:	h %:	p hPa:
13:42:38.621 -> 28.94	48.17	981.34
13:42:38.621 -> state of charge: 0%
13:42:38.654 -> adc1 data:
13:42:38.654 -> BatV:20.64V
13:42:38.723 -> blynk trig
13:42:38.723 -> 
13:42:39.571 -> bmeInside data:
13:42:39.571 -> t °C:	h %:	p hPa:
13:42:39.605 -> 28.94	48.16	981.32
13:42:39.605 -> state of charge: 0%
13:42:39.639 -> adc1 data:
13:42:39.639 -> BatV:20.65V
13:42:40.591 -> bmeInside data:
13:42:40.591 -> t °C:	h %:	p hPa:
13:42:40.625 -> 28.91	48.15	981.33
13:42:40.625 -> state of charge: 0%
13:42:40.658 -> adc1 data:
13:42:40.658 -> BatV:20.64V
13:42:41.573 -> bmeInside data:
13:42:41.573 -> t °C:	h %:	p hPa:
13:42:41.608 -> 28.90	48.18	981.31
13:42:41.608 -> state of charge: 0%
13:42:41.642 -> adc1 data:
13:42:41.642 -> BatV:20.64V
13:42:42.594 -> bmeInside data:
13:42:42.594 -> t °C:	h %:	p hPa:
13:42:42.628 -> 28.91	48.22	981.32
13:42:42.628 -> state of charge: 0%
13:42:42.663 -> adc1 data:
13:42:42.663 -> BatV:20.64V
13:42:43.584 -> bmeInside data:
13:42:43.584 -> t °C:	h %:	p hPa:
13:42:43.618 -> 28.91	48.20	981.31
13:42:43.618 -> state of charge: 0%
13:42:43.651 -> adc1 data:
13:42:43.651 -> BatV:20.65V
13:42:44.607 -> bmeInside data:
13:42:44.607 -> t °C:	h %:	p hPa:
13:42:44.641 -> 28.89	48.19	981.32
13:42:44.641 -> state of charge: 0%
13:42:44.675 -> adc1 data:
13:42:44.675 -> BatV:20.64V
13:42:45.593 -> bmeInside data:
13:42:45.593 -> t °C:	h %:	p hPa:
13:42:45.627 -> 28.87	48.21	981.31
13:42:45.627 -> state of charge: 0%
13:42:45.661 -> adc1 data:
13:42:45.661 -> BatV:20.64V
13:42:46.614 -> bmeInside data:
13:42:46.614 -> t °C:	h %:	p hPa:
13:42:46.649 -> 28.87	48.22	981.29
13:42:46.649 -> state of charge: 0%
13:42:46.683 -> adc1 data:
13:42:46.683 -> BatV:20.65V
13:42:47.602 -> bmeInside data:
13:42:47.602 -> t °C:	h %:	p hPa:
13:42:47.635 -> 28.87	48.22	981.31
13:42:47.635 -> state of charge: 0%
13:42:47.669 -> adc1 data:
13:42:47.669 -> BatV:20.64V
13:42:49.029 -> bmeInside data:
13:42:49.029 -> t °C:	h %:	p hPa:
13:42:49.063 -> 28.87	48.23	981.29
13:42:49.063 -> state of charge: 0%
13:42:49.097 -> adc1 data:
13:42:49.097 -> BatV:20.64V
13:42:50.017 -> bmeInside data:
13:42:50.017 -> t °C:	h %:	p hPa:
13:42:50.050 -> 28.87	48.23	981.30
13:42:50.050 -> state of charge: 0%
13:42:50.084 -> adc1 data:
13:42:50.084 -> BatV:20.64V
13:42:51.037 -> bmeInside data:
13:42:51.037 -> t °C:	h %:	p hPa:
13:42:51.070 -> 28.88	48.24	981.29
13:42:51.070 -> state of charge: 0%
13:42:51.105 -> adc1 data:
13:42:51.105 -> BatV:20.65V
13:42:52.036 -> bmeInside data:
13:42:52.036 -> t °C:	h %:	p hPa:
13:42:52.060 -> 28.88	48.24	981.33
13:42:52.060 -> state of charge: 0%
13:42:52.092 -> adc1 data:
13:42:52.092 -> BatV:20.65V
13:42:53.039 -> bmeInside data:
13:42:53.039 -> t °C:	h %:	p hPa:
13:42:53.073 -> 28.89	48.22	981.29
13:42:53.073 -> state of charge: 0%
13:42:53.107 -> adc1 data:
13:42:53.107 -> BatV:20.64V
13:42:54.029 -> bmeInside data:
13:42:54.029 -> t °C:	h %:	p hPa:
13:42:54.063 -> 28.90	48.22	981.29
13:42:54.063 -> state of charge: 0%
13:42:54.097 -> adc1 data:
13:42:54.097 -> BatV:20.65V
13:42:55.054 -> bmeInside data:
13:42:55.054 -> t °C:	h %:	p hPa:
13:42:55.088 -> 28.91	48.20	981.29
13:42:55.088 -> state of charge: 0%
13:42:55.133 -> adc1 data:
13:42:55.133 -> BatV:20.65V
13:42:56.070 -> bmeInside data:
13:42:56.070 -> t °C:	h %:	p hPa:
13:42:56.132 -> 28.91	48.19	981.34
13:42:56.132 -> state of charge: 0%
13:42:56.132 -> adc1 data:
13:42:56.132 -> BatV:20.65V
13:42:57.045 -> bmeInside data:
13:42:57.045 -> t °C:	h %:	p hPa:
13:42:57.079 -> 28.90	48.18	981.32
13:42:57.079 -> state of charge: 0%
13:42:57.112 -> adc1 data:
13:42:57.112 -> BatV:20.64V
13:42:58.062 -> bmeInside data:
13:42:58.062 -> t °C:	h %:	p hPa:
13:42:58.096 -> 28.91	48.18	981.33
13:42:58.096 -> state of charge: 0%
13:42:58.130 -> adc1 data:
13:42:58.130 -> BatV:20.64V
13:42:59.145 -> bmeInside data:
13:42:59.145 -> t °C:	h %:	p hPa:
13:42:59.180 -> 28.90	48.19	981.28
13:42:59.180 -> state of charge: 0%
13:42:59.213 -> adc1 data:
13:42:59.213 -> BatV:20.64V
13:43:00.119 -> bmeInside data:
13:43:00.119 -> t °C:	h %:	p hPa:
13:43:00.153 -> 28.90	48.20	981.32
13:43:00.153 -> state of charge: 0%
13:43:00.187 -> adc1 data:
13:43:00.187 -> BatV:20.65V
13:43:01.138 -> bmeInside data:
13:43:01.138 -> t °C:	h %:	p hPa:
13:43:01.172 -> 28.89	48.22	981.30
13:43:01.172 -> state of charge: 0%
13:43:01.206 -> adc1 data:
13:43:01.206 -> BatV:20.65V
13:43:02.129 -> bmeInside data:
13:43:02.129 -> t °C:	h %:	p hPa:
13:43:02.163 -> 28.88	48.22	981.30
13:43:02.163 -> state of charge: 0%
13:43:02.197 -> adc1 data:
13:43:02.197 -> BatV:20.64V
13:43:03.152 -> bmeInside data:
13:43:03.152 -> t °C:	h %:	p hPa:
13:43:03.183 -> 28.87	48.21	981.27
13:43:03.183 -> state of charge: 0%
13:43:03.219 -> adc1 data:
13:43:03.219 -> BatV:20.64V
13:43:04.136 -> bmeInside data:
13:43:04.136 -> t °C:	h %:	p hPa:
13:43:04.168 -> 28.87	48.23	981.27
13:43:04.168 -> state of charge: 0%
13:43:04.201 -> adc1 data:
13:43:04.201 -> BatV:20.64V
13:43:05.142 -> bmeInside data:
13:43:05.142 -> t °C:	h %:	p hPa:
13:43:05.177 -> 28.88	48.26	981.30
13:43:05.177 -> state of charge: 0%
13:43:05.212 -> adc1 data:
13:43:05.212 -> BatV:20.64V
13:43:06.161 -> bmeInside data:
13:43:06.161 -> t °C:	h %:	p hPa:
13:43:06.194 -> 28.88	48.26	981.32
13:43:06.194 -> state of charge: 0%
13:43:06.231 -> adc1 data:
13:43:06.231 -> BatV:20.64V
13:43:07.176 -> bmeInside data:
13:43:07.176 -> t °C:	h %:	p hPa:
13:43:07.210 -> 28.88	48.26	981.30
13:43:07.210 -> state of charge: 0%
13:43:07.245 -> adc1 data:
13:43:07.245 -> BatV:20.64V
13:43:08.160 -> bmeInside data:
13:43:08.160 -> t °C:	h %:	p hPa:
13:43:08.195 -> 28.88	48.25	981.30
13:43:08.195 -> state of charge: 0%
13:43:08.229 -> adc1 data:
13:43:08.229 -> BatV:20.64V
13:43:09.255 -> bmeInside data:
13:43:09.255 -> t °C:	h %:	p hPa:
13:43:09.289 -> 28.89	48.27	981.31
13:43:09.289 -> state of charge: 0%
13:43:09.323 -> adc1 data:
13:43:09.323 -> BatV:20.65V
13:43:10.233 -> bmeInside data:
13:43:10.233 -> t °C:	h %:	p hPa:
13:43:10.266 -> 28.90	48.26	981.31
13:43:10.266 -> state of charge: 0%
13:43:10.299 -> adc1 data:
13:43:10.299 -> BatV:20.65V
13:43:11.242 -> bmeInside data:
13:43:11.242 -> t °C:	h %:	p hPa:
13:43:11.276 -> 28.89	48.24	981.29
13:43:11.276 -> state of charge: 0%
13:43:11.310 -> adc1 data:
13:43:11.310 -> BatV:20.65V
13:43:12.231 -> bmeInside data:
13:43:12.231 -> t °C:	h %:	p hPa:
13:43:12.265 -> 28.88	48.23	981.29
13:43:12.265 -> state of charge: 0%
13:43:12.299 -> adc1 data:
13:43:12.299 -> BatV:20.65V
13:43:13.248 -> bmeInside data:
13:43:13.248 -> t °C:	h %:	p hPa:
13:43:13.283 -> 28.87	48.23	981.31
13:43:13.283 -> state of charge: 0%
13:43:13.317 -> adc1 data:
13:43:13.317 -> BatV:20.64V
13:43:14.269 -> bmeInside data:
13:43:14.269 -> t °C:	h %:	p hPa:
13:43:14.303 -> 28.87	48.27	981.30
13:43:14.303 -> state of charge: 0%
13:43:14.336 -> adc1 data:
13:43:14.336 -> BatV:20.64V
13:43:15.253 -> bmeInside data:
13:43:15.253 -> t °C:	h %:	p hPa:
13:43:15.287 -> 28.87	48.30	981.32
13:43:15.287 -> state of charge: 0%
13:43:15.321 -> adc1 data:
13:43:15.321 -> BatV:20.65V
13:43:16.272 -> bmeInside data:
13:43:16.272 -> t °C:	h %:	p hPa:
13:43:16.306 -> 28.85	48.33	981.31
13:43:16.306 -> state of charge: 0%
13:43:16.340 -> adc1 data:
13:43:16.340 -> BatV:20.64V
13:43:17.284 -> bmeInside data:
13:43:17.284 -> t °C:	h %:	p hPa:
13:43:17.318 -> 28.84	48.31	981.29
13:43:17.318 -> state of charge: 0%
13:43:17.353 -> adc1 data:
13:43:17.353 -> BatV:20.64V
13:43:18.297 -> bmeInside data:
13:43:18.297 -> t °C:	h %:	p hPa:
13:43:18.331 -> 28.84	48.30	981.31
13:43:18.331 -> state of charge: 0%
13:43:18.331 -> adc1 data:
13:43:18.331 -> BatV:20.64V
13:43:19.352 -> bmeInside data:
13:43:19.352 -> t °C:	h %:	p hPa:
13:43:19.385 -> 28.85	48.30	981.30
13:43:19.385 -> state of charge: 0%
13:43:19.419 -> adc1 data:
13:43:19.419 -> BatV:20.65V
13:43:20.334 -> bmeInside data:
13:43:20.334 -> t °C:	h %:	p hPa:
13:43:20.369 -> 28.85	48.29	981.27
13:43:20.369 -> state of charge: 0%
13:43:20.403 -> adc1 data:
13:43:20.403 -> BatV:20.64V
13:43:21.350 -> bmeInside data:
13:43:21.350 -> t °C:	h %:	p hPa:
13:43:21.386 -> 28.85	48.29	981.31
13:43:21.386 -> state of charge: 0%
13:43:21.418 -> adc1 data:
13:43:21.418 -> BatV:20.65V
13:43:22.341 -> bmeInside data:
13:43:22.341 -> t °C:	h %:	p hPa:
13:43:22.375 -> 28.85	48.28	981.31
13:43:22.375 -> state of charge: 0%
13:43:22.409 -> adc1 data:
13:43:22.409 -> BatV:20.65V
13:43:23.359 -> bmeInside data:
13:43:23.359 -> t °C:	h %:	p hPa:
13:43:23.393 -> 28.85	48.29	981.29
13:43:23.393 -> state of charge: 0%
13:43:23.427 -> adc1 data:
13:43:23.427 -> BatV:20.64V
13:43:24.348 -> bmeInside data:
13:43:24.348 -> t °C:	h %:	p hPa:
13:43:24.382 -> 28.86	48.28	981.31
13:43:24.382 -> state of charge: 0%
13:43:24.416 -> adc1 data:
13:43:24.416 -> BatV:20.64V
13:43:25.365 -> bmeInside data:
13:43:25.365 -> t °C:	h %:	p hPa:
13:43:25.399 -> 28.86	48.28	981.30
13:43:25.399 -> state of charge: 0%
13:43:25.433 -> adc1 data:
13:43:25.433 -> BatV:20.64V
13:43:26.388 -> bmeInside data:
13:43:26.388 -> t °C:	h %:	p hPa:
13:43:26.388 -> 28.86	48.28	981.27
13:43:26.388 -> state of charge: 0%
13:43:26.421 -> adc1 data:
13:43:26.421 -> BatV:20.64V
13:43:27.372 -> bmeInside data:
13:43:27.372 -> t °C:	h %:	p hPa:
13:43:27.406 -> 28.86	48.27	981.30
13:43:27.406 -> state of charge: 0%
13:43:27.440 -> adc1 data:
13:43:27.440 -> BatV:20.65V
13:43:28.390 -> bmeInside data:
13:43:28.390 -> t °C:	h %:	p hPa:
13:43:28.423 -> 28.84	48.28	981.31
13:43:28.423 -> state of charge: 0%
13:43:28.456 -> adc1 data:
13:43:28.456 -> BatV:20.64V
13:43:29.440 -> bmeInside data:
13:43:29.440 -> t °C:	h %:	p hPa:
13:43:29.474 -> 28.84	48.30	981.29
13:43:29.474 -> state of charge: 0%
13:43:29.508 -> adc1 data:
13:43:29.508 -> BatV:20.64V
13:43:30.428 -> bmeInside data:
13:43:30.428 -> t °C:	h %:	p hPa:
13:43:30.462 -> 28.84	48.30	981.27
13:43:30.462 -> state of charge: 0%
13:43:30.496 -> adc1 data:
13:43:30.496 -> BatV:20.64V
13:43:31.446 -> bmeInside data:
13:43:31.446 -> t °C:	h %:	p hPa:
13:43:31.478 -> 28.84	48.31	981.30
13:43:31.478 -> state of charge: 0%
13:43:31.511 -> adc1 data:
13:43:31.511 -> BatV:20.64V
13:43:32.429 -> bmeInside data:
13:43:32.429 -> t °C:	h %:	p hPa:
13:43:32.463 -> 28.83	48.32	981.28
13:43:32.463 -> state of charge: 0%
13:43:32.497 -> adc1 data:
13:43:32.497 -> BatV:20.65V
13:43:33.480 -> bmeInside data:
13:43:33.480 -> t °C:	h %:	p hPa:
13:43:33.480 -> 28.82	48.31	981.29
13:43:33.480 -> state of charge: 0%
13:43:33.518 -> adc1 data:
13:43:33.518 -> BatV:20.65V
13:43:34.465 -> bmeInside data:
13:43:34.465 -> t °C:	h %:	p hPa:
13:43:34.499 -> 28.81	48.31	981.29
13:43:34.499 -> state of charge: 0%
13:43:34.533 -> adc1 data:
13:43:34.533 -> BatV:20.65V
13:43:35.454 -> bmeInside data:
13:43:35.454 -> t °C:	h %:	p hPa:
13:43:35.488 -> 28.81	48.32	981.28
13:43:35.488 -> state of charge: 0%
13:43:35.523 -> adc1 data:
13:43:35.523 -> BatV:20.64V
13:43:36.472 -> bmeInside data:
13:43:36.472 -> t °C:	h %:	p hPa:
13:43:36.506 -> 28.81	48.33	981.28
13:43:36.506 -> state of charge: 0%
13:43:36.540 -> adc1 data:
13:43:36.540 -> BatV:20.64V
13:43:37.459 -> bmeInside data:
13:43:37.459 -> t °C:	h %:	p hPa:
13:43:37.493 -> 28.82	48.32	981.31
13:43:37.493 -> state of charge: 0%
13:43:37.527 -> adc1 data:
13:43:37.527 -> BatV:20.65V
13:43:38.477 -> bmeInside data:
13:43:38.477 -> t °C:	h %:	p hPa:
13:43:38.511 -> 28.82	48.32	981.31
13:43:38.511 -> state of charge: 0%
13:43:38.545 -> adc1 data:
13:43:38.545 -> BatV:20.64V
13:43:38.682 -> blynk trig
13:43:38.682 -> 
13:43:39.531 -> bmeInside data:
13:43:39.531 -> t °C:	h %:	p hPa:
13:43:39.566 -> 28.83	48.31	981.28
13:43:39.566 -> state of charge: 0%
13:43:39.600 -> adc1 data:
13:43:39.600 -> BatV:20.65V
13:43:40.517 -> bmeInside data:
13:43:40.517 -> t °C:	h %:	p hPa:
13:43:40.551 -> 28.83	48.30	981.29
13:43:40.551 -> state of charge: 0%
13:43:40.585 -> adc1 data:
13:43:40.585 -> BatV:20.65V


because of your loop 1st

void loop() {
	currentMillis = millis();
 
	Blynk.run();
  
	updateSensors();
	
	sendBlynk();
}

need to be :

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

nothing else :wink:

After deleting code function by function, I’ve found the issue – it’s the BME280 sensor, as soon as I initialize it the Blynk.begin() doesn’t execute fully. Now I need to only find why. I’ve tried the adafruit and groove library, both don’t work.

1 Like

so…
but your loop will flood the server and you will get disconnections, or heartbeat or rst issue.
read other posts through the forum, you will see, it’s a common error of all blynk beginners.:joy:
blynk needs a clean loop.

All I can say here,is the BME280 works fine with Blynk and ESP as a “shield” on Arduino (Mega32 in my case). I’ve no idea why there are issues. I do believe your timers are working fine. “You have control” in this case, so it’s your “job” to check them :slight_smile: .
@Blynk_Coeur, there is no need to use Blynk Timer, as it uses the same principle of operation as @Oxmstr uses here. I’m often using the same instead of Blynk Timer.

1 Like

Me neither, I tried like 5 different libs for bme280, but it always hangs. Tomorrow I will put Serial prints into the blynk begin function to see where it hangs.

Just thought, what if I init the bme after I begin the blynk.

If I do remember correctly, I’m with SparkFun.

Try to call Blynk.begin(); before name.begin();?

My plan to init the bme somewhere else in the code doesn’t work, even if the init code is not executed (if statement that is always false). Recently I’ve updated all my libs and boards, and I had to downgrade the AVR boards to 1.6.21 from 23 because there is gcc bug that won’t let you compile. What version of AVR boards and blynk are you using?

It seems that it hangs on while(this->connect() != true) {} in Arduino\libraries\Blynk\src\BlynkSimpleShieldEsp8266.h

Can’t say it currently, as I’m away till next Thursday, but since the device was last flashed about a year ago, that wasn’t the latest one.
The Blynk.begin() is a blocking function (actually you already found it by yourself) and actually I’m not using it. I’ve put here on the forum other method which is working exactly in the device I mentioned here (as this is the only one which uses the ESP as a shield). This is how it goes for me:

And this:

I think that I found a “solution”, I’ve downgraded to Blynk 0.5.4. and it works. I tried 0.6.1 and 0.6.0, both don’t work. I’m going to create a bug report on the forum.

1 Like