Mega Relays HIGH WHEN ENERGY OUT

Hi blynkers! i keep loving blynk and i added 3 wemos in my house i love all !

Now i have problem , when Energy Out my “Arduino Mega” start with Relays in HIGH, i need all relays in LOW.

Any help ?

#define BLYNK_PRINT Serial

#define BLYNK_TEMPLATE_ID "";
#define BLYNK_DEVICE_NAME "Arduino Mega";
#define BLYNK_AUTH_TOKEN ""

#define BLYNK_FIRMWARE_VERSION        "1.2"

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

BlynkTimer timer;

#define W5100_CS  10
#define SDCARD_CS 4


const int ReflectorPatio = 24;
const int Presurizadora = 26;
const int TimerPresurizadora = 34;

const int ReflectorPorton = 48;
const int ReflectorTerreno = 43;

int EstadoReflectorPatio = LOW;
int EstadoPresurizadora = LOW;
int EstadoReflectorPorton = LOW;
int EstadoReflectorTerreno = LOW;
int EstadoTimerPresurizadora = LOW;



void setup()
{
  // Debug console
  Serial.begin(9600);

  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH);

  pinMode(ReflectorPatio, OUTPUT);
  pinMode(Presurizadora, OUTPUT);
  pinMode(TimerPresurizadora, OUTPUT);

  pinMode(ReflectorPorton, OUTPUT);
  pinMode(ReflectorTerreno, OUTPUT);

  Blynk.begin(BLYNK_AUTH_TOKEN);

}


BLYNK_WRITE(V2) {
  EstadoReflectorPatio = param.asInt();
  digitalWrite(ReflectorPatio, EstadoReflectorPatio);
  Blynk.virtualWrite(V2, EstadoReflectorPatio);
}
BLYNK_WRITE(V3) {
  EstadoPresurizadora = param.asInt();
  digitalWrite(Presurizadora, EstadoPresurizadora);
  Blynk.virtualWrite(V3, EstadoPresurizadora);

  if (EstadoPresurizadora == 0) {
    Blynk.virtualWrite(V14, "Presurizada");
  }
  else {
    Blynk.virtualWrite(V14, "Normal");
  }

}

BLYNK_WRITE(V4) {
  EstadoTimerPresurizadora = param.asInt();
  digitalWrite(TimerPresurizadora, EstadoTimerPresurizadora);
  Blynk.virtualWrite(V4, EstadoTimerPresurizadora);
}

BLYNK_WRITE(V5) {
  EstadoReflectorPorton = param.asInt();
  digitalWrite(ReflectorPorton, EstadoReflectorPorton);
  Blynk.virtualWrite(V5, EstadoReflectorPorton);
}
BLYNK_WRITE(V6) {
  EstadoReflectorTerreno = param.asInt();
  digitalWrite(ReflectorTerreno, EstadoReflectorTerreno);
  Blynk.virtualWrite(V6, EstadoReflectorTerreno);
}


BLYNK_WRITE(V7)
{
  EstadoTimerPresurizadora = param.asInt();
  digitalWrite(TimerPresurizadora, EstadoTimerPresurizadora);
  Blynk.virtualWrite(V7, EstadoTimerPresurizadora);
}

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

add this to your void setup

digitalWrite(ReflectorPatio, LOW);
digitalWrite(Presurizadora, LOW);
digitalWrite(TimerPresurizadora, LOW);
digitalWrite(ReflectorPorton, LOW);
digitalWrite(ReflectorTerreno, LOW);

if you’re using an active high relay, or change LOW to HIGH if you’re using an active low relay.

@John93 yep i try that but when Mega restarted not sync from app.

Look cloud:
imagen
Datastream:
imagen

When Mega Restarted not sync from app to relays , if i put DigitalWrite… just put offline but not sync…

When i try this :
// This function will run every time Blynk connection is established

BLYNK_CONNECTED() {
  Blynk.syncAll();
}

Nothing happend just app start ALL OFF if i define in SETUP but NEVER sync from app.

Can you show me how did you configure your datastream ?

@John93


Turn this on

@John93 daaaaaam hahaha thx i need read more all stuff ! thx mate.

1 Like

You’re welcome buddy :slightly_smiling_face: