ESP-12-f Standalone + Blynk+ Relays

@cristi, you need to move away from direct GPIO pins and start working with Virtual Pins.
This is the only way you will be able to make your idea work correctly.

Also your code has nothing in it! So im not surprised nothing works correctly.

You need to think of Blynk as just a way to see the data. You really need to write a sketch that can control the relay module on its own or via the Serial monitor.

Here is a quick example for you to study. Also check out my own relay project with timers etc

// define the physical pins the relays are connected to. Make sure you use GPIO numbers and not D numbers. D6 = GPIO12 etc 
#define RELAY1_PIN 12  // D6
#define RELAY1_PIN 13  // D7

// add the following setup() to your own sketch
void setup(){
  pinMode(RELAY1_PIN,OUTPUT);
  pinMode(RELAY2_PIN,OUTPUT);
  digitalWrite(RELAY1_PIN, HIGH); // most modules are LOW active... so on boot start inactive (HIGH)
  digitalWrite(RELAY2_PIN, HIGH); // most modules are LOW active... so on boot start inactive (HIGH)
}

BLYNK_WRITE(1){ // virtual pin 1... create a button widget in SWITCH mode
  if(param.asInt()){
    digitalWrite(RELAY1_PIN, LOW); // if button is HIGH, turn on relay1
  } else {
    digitalWrite(RELAY1_PIN, HIGH); // if button is LOW, turn off relay1
  }
}

BLYNK_WRITE(2){ // virtual pin 2... create a button widget in SWITCH mode
  if(param.asInt()){
    digitalWrite(RELAY2_PIN, LOW); // if button is HIGH, turn on relay1
  } else {
    digitalWrite(RELAY2_PIN, HIGH); // if button is LOW, turn off relay1
  }
}

2 Likes