• Hardware model + communication type : ESP01S-RELAY (ESP8266 based)
• Smartphone IOS 16.6.1
• Blynk server region : EU
• Blynk Library version : 1.3.2
Hello
I’m a blynk server user since manby years and i would like to evalutate the native cloud version of Blynk.
I’m trying to use a relay but it doesn’t work. The relay is never change his state (LOW - HIGH).
This is the code i use.
Mobile app is working fine, and i can see the ‘MARK’ in the text zone.
It seems it’s the digitalWrite than does’nt work but i don’t know why. I know we have to avoid delay(), but this code was working fine with my own Blynk Server.
Any ideas ?
Thanks in advance
#define PIN_TEXT V4
#define PIN_CONTACT V5
#define RELAY 0
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
BLYNK_WRITE(PIN_CONTACT)
{
int BTN = param.asInt();
if (BTN == 1) {
digitalWrite(RELAY, LOW);
delay(2000);
digitalWrite(RELAY, HIGH);
delay(2000);
Blynk.virtualWrite(PIN_TEXT, "MARK");
delay(2000);
}
}
// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
// Change Web Link Button message to "Congratulations!"
Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
Blynk.setProperty(V3, "onImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop()
{
Blynk.run();
Blynk.virtualWrite(PIN_TEXT, " ");
}