Hello everyone, I have a simple project, an Amica nodemcu connected to a 1 channel relay module to turn on and off a heating device.
I’m using the 1.0.1 library version.
The sketch works, I can turn on and off the switch from the Blynk website or the iOS app but then goes offline after a few seconds. Below is my serial monitor output and sketch:
22:16:56.959 -> [4289] Connected to WiFi
22:16:56.959 -> [4290] IP: 192.168.1.3
22:16:57.006 -> [4290]
22:16:57.006 -> ___ __ __
22:16:57.006 -> / _ )/ /_ _____ / /__
22:16:57.006 -> / _ / / // / _ \/ '_/
22:16:57.006 -> /____/_/\_, /_//_/_/\_\
22:16:57.006 -> /___/ v1.0.1 on ESP8266
22:16:57.006 ->
22:16:57.006 -> [4296] Connecting to blynk.cloud:80
22:16:57.844 -> [5166] Ready (ping: 62ms).
22:18:26.752 -> [94083] Heartbeat timeout
22:18:27.076 -> [94384] Connecting to blynk.cloud:80
22:18:33.237 -> [100547] Connecting to blynk.cloud:80
22:18:39.396 -> [106713] Connecting to blynk.cloud:80
22:18:45.565 -> [112879] Connecting to blynk.cloud:80
#define BLYNK_TEMPLATE_ID "xxxxxxx"
#define BLYNK_DEVICE_NAME "Boiler"
#define BLYNK_AUTH_TOKEN "xxxxxx"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxx";
char pass[] = "xxxxxxxxxx";
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
WiFi.setAutoReconnect(true);
WiFi.persistent(true);
pinMode(5, OUTPUT);
digitalWrite(5, HIGH);
}
BLYNK_WRITE(V0) // Executes when the value of virtual pin 0 changes
{
if(param.asInt() == 1)
{
// execute this code if the switch widget is now ON
digitalWrite(5,HIGH); // Set digital pin 5 HIGH
}
else
{
// execute this code if the switch widget is now OFF
digitalWrite(5,LOW); // Set digital pin 5 LOW
}
}
void loop()
{
Blynk.run();
}