News:

The Latest electronic and computer Tips that work!

Main Menu

Wemos D1_R1 Relay switch Blynk 2.0

Started by branx86, May 22, 2022, 07:22:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

branx86



//Brandon Relay controller on WeMos GPIO pin D9 on Blynk 2.0
// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPLPHrQlpSL" //Change to match yours in Blynk 2
#define BLYNK_DEVICE_NAME "RelayONOFF" //Chnage to match yours in Blynk 2

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

#include "BlynkEdgent.h"

BLYNK_WRITE(V0) //This is set in the Blynk app
{
  if(param.asInt ()==0) {  //Change 0 to 1 if you want to change button state
   digitalWrite(2, HIGH);  //WeMos GPIO D9
    }
  else{
    digitalWrite(2, LOW); //WeMos GPIO D9
  }
}
BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0); //This is set in the Blynk app
}
void setup()
{
  pinMode (2, OUTPUT); //WeMos GPIO D9
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
}

void loop() {
  BlynkEdgent.run();
}