ESP8266 Relay Module working with Blynk

the code is written for the blynk application for the esp8266 realy module

   #include <SoftwareSerial.h>
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
     
    char auth[] = "you_blink_pin";
    char ssid[] = "you_wifi_ssid";
    char pass[] = "you_wifi_password";
     
    BLYNK_WRITE(V0)
    {
      int pinValue = param.asInt();
      if (pinValue == 1) {
            const byte RelayON[] = {0xA0, 0x01, 0x01, 0xA2};
            Serial.write(RelayON, sizeof(RelayON));
         }else {
            const byte RelayOFF[] = {0xA0, 0x01, 0x00, 0xA1};
            Serial.write(RelayOFF, sizeof(RelayOFF));
        }
    }
     
    void setup()
    {
      Serial.begin(9600);
      Blynk.begin(auth, ssid, pass);
    }
     
    void loop()
    {
      Blynk.run();
    }
1 Like