I’m using ESP32 Dev Module board with following:
• Blynk Library version 1.3.2
• ESP32 board version 2.0.14
I’ve tested the code without Edgenet by using simple Blynk examples and it is working fine. Now in order to configure wifi-credentials I have used same code with Edgenet example and I’m using Blynk application to configure the device. On application I can see the device successfully
• Configuring Devices
• Reconnecting Back to Cloud
Failed when
• Waiting for device Online
Help me in this why it’s not getting online.
If I use Blynk Edgenet example alone without adding my code it gets online easily by Copying Template_ID and Name.
#define BLYNK_TEMPLATE_ID "TMPL"
#define BLYNK_TEMPLATE_NAME "Testxxxx"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
// Uncomment your board, or configure a custom board in Settings.h
#define USE_ESP32_DEV_MODULE
#include "BlynkEdgent.h"
#include <TimeLib.h>
#include <WidgetRTC.h>
const byte blockPin = 22; // Pin that we can use to block variablY
BlynkTimer timer;
WidgetRTC rtc;
#define RXp2 16
#define TXp2 17
// Blynk virtual pin assignments
#define VIRTUAL_ENABLE_VALUE V0
#define VIRTUAL_TIME_PIN V1 // time virtual pin
#define VIRTUAL_variablY_COUNT V2 // variablY count
#define VIRTUAL_variablX_COUNT V3 // variablX count
#define VIRTUAL_ERROR_COUNT V4 // Error count
#define VIRTUAL_WIFI V5 // wifi signal strength
#define VIRTUAL_BUTTON_DISABLE V6 // Disable button
#define VIRTUAL_variablZ_COUNT V7 // variablZ count
#define VIRTUAL_ERROR_FLAG V8 // error flag
#define VIRTUAL_BUTTON_TIME V9 // error flag
#define VIRTUAL_BUTTON_HOURS V10 // error flag
#define VIRTUAL_BUTTON_MINS V11 // error flag
#define VIRTUAL_BUTTON_SEC V12 // error flag
int variablYCount = 0; // Variable to hold variablY count
int variablXCount = 0; // variable to hold variablX count
int errorCount = 0; // variable to hold error count
int variablZCount = 0; // variable to hold variablZ count
int errorFlag = 0; // variable to hold error flag
void clockDisplay() {
// You can call hour(), minute(), ... at any time
// Please see Time library examples for details
String currentTime = String(hour()) + ":" + minute() + ":" + second();
String currentTimeDisp = String(hour()) + ":" + minute();
String currentDate = String(day()) + " " + month() + " " + year();
// Send time to the App
Blynk.virtualWrite(VIRTUAL_TIME_PIN, currentTime);
}
void getWifiStrength() {
Blynk.virtualWrite(VIRTUAL_WIFI, WiFi.RSSI());
}
BLYNK_CONNECTED() {
// Synchronize time on connection
rtc.begin();
// Blynk.syncAll();
}
void requestVariableValue(void);
void setup() {
Serial.begin(115200);
delay(100);
BlynkEdgent.begin();
// Synchronize values from server
// Serial.begin(9600, SERIAL_8N1, RXp2, TXp2);
pinMode(blockPin, OUTPUT); // Set Block pin as output
digitalWrite(blockPin, HIGH); // Initially keep the pin high until blynk works
Blynk.syncVirtual(VIRTUAL_BUTTON_DISABLE);
setSyncInterval(10 * 60); // sync interval in seconds (10 minutes)
// Display digital clock every 10 seconds
timer.setInterval(5000L, getWifiStrength); // Get wifi strength after every 5 seconds
timer.setInterval(1500L, requestVariableValue); // Get clock after every 1 seconds
timer.setInterval(1000L, clockDisplay); // Get clock after every 1 seconds
}
void loop() {
BlynkEdgent.run();
timer.run();
}
void requestVariableValue() {
if (Serial.available() > 0) {
String inc = Serial.readStringUntil('x');
inc.trim(); // Trim new line characters
if (inc.startsWith("s,")) { // Check if incoming data starts's with 's'
variablYCount = getValue(inc, ',', 1).toInt(); // get variablY count
variablXCount = getValue(inc, ',', 2).toInt(); // get variablX count
errorCount = getValue(inc, ',', 3).toInt(); // get error count
Blynk.virtualWrite(VIRTUAL_variablY_COUNT, variablYCount); // update values on blynk
Blynk.virtualWrite(VIRTUAL_variablX_COUNT, variablXCount); // update values on blynk
Blynk.virtualWrite(VIRTUAL_ERROR_COUNT, errorCount); // update values on blynk
} else if (inc.startsWith("e,")) { // Check if incoming data starts's with 'e'
variablZCount = getValue(inc, ',', 1).toInt(); // get variablY count
errorFlag = getValue(inc, ',', 2).toInt(); // get variablX count
Blynk.virtualWrite(VIRTUAL_variablZ_COUNT, variablZCount); // update values on blynk
Blynk.virtualWrite(VIRTUAL_ERROR_FLAG, errorFlag); // update values on blynk
} else if (inc.startsWith("b,")) { // Check if incoming data starts's with 'b' take it as button press
//Serial.println("Button Press Flag Received");
String currentTime = String(hour()) + ":" + minute() + ":" + second();
// Send time to the App
Blynk.virtualWrite(VIRTUAL_BUTTON_TIME, currentTime);
Blynk.virtualWrite(VIRTUAL_BUTTON_HOURS, int(hour()));
Blynk.virtualWrite(VIRTUAL_BUTTON_MINS, int(minute()));
Blynk.virtualWrite(VIRTUAL_BUTTON_SEC, int(second()));
}
}
}
BLYNK_WRITE(VIRTUAL_BUTTON_DISABLE) // this command is listening if variablY disable button was used
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
if (pinValue == 1) {
Blynk.virtualWrite(VIRTUAL_ENABLE_VALUE, 1);
//Serial.println("Disable variablY");
digitalWrite(blockPin, HIGH); // Set block pin as high
} else if (pinValue == 0) {
Blynk.virtualWrite(VIRTUAL_ENABLE_VALUE, 0);
//Serial.println("Enable variablY");
digitalWrite(blockPin, LOW); // Set block pin as LOW
}
}
String getValue(String data, char separator, int index) {
int found = 0;
int strIndex[] = { 0, -1 };
int maxIndex = data.length() - 1;
for (int i = 0; i <= maxIndex && found <= index; i++) {
if (data.charAt(i) == separator || i == maxIndex) {
found++;
strIndex[0] = strIndex[1] + 1;
strIndex[1] = (i == maxIndex) ? i + 1 : i;
}
}
return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}
Following is the Serial monitor Output.
06:17:04.842 -> [18343] WAIT_CONFIG => CONFIGURING
06:17:04.842 -> [18343] Sending board info...
06:17:13.047 -> [26557] Applying configuration...
06:17:13.047 -> [26557] WiFi SSID: Internet Pass: 285xxxx
06:17:13.047 -> [26557] Blynk cloud: l12b-Cyjq5HeM5XFn-fvzMl_3FF4zra- @ blynk.cloud:443
06:17:13.047 -> [26570] CONFIGURING => SWITCH_TO_STA
06:17:13.105 -> [26575] Switching to STA...
06:17:14.081 -> CORRUPT HEAP: Bad tail at 0x3ffafcdc. Expected 0xbaad5678 got 0x00000000
06:17:14.081 ->
06:17:14.081 -> assert failed: multi_heap_free multi_heap_poisoning.c:259 (head != NULL)
06:17:14.081 ->
06:17:14.081 ->
06:17:14.081 -> Backtrace: 0x40083f01:0x3ffcc2c0 0x4008e14d:0x3ffcc2e0 0x40093871:0x3ffcc300 0x40093469:0x3ffcc430 0x40084471:0x3ffcc450 0x400938a1:0x3ffcc470 0x401412c2:0x3ffcc490 0x40148d6d:0x3ffcc4b0 0x401471e4:0x3ffcc4d0 0x4018051d:0x3ffcc4f0
06:17:14.116 ->
06:17:14.116 ->
06:17:14.116 ->
06:17:14.116 ->
06:17:14.116 -> ELF file SHA256: 6114ebfdf1df462e
06:17:14.116 ->
06:17:14.397 -> Rebooting...