// 1. Paste your unique credentials here
#define BLYNK_TEMPLATE_ID "TMPL68GIOSpsQ"
#define BLYNK_TEMPLATE_NAME "Smart Relay Controller"
#define BLYNK_AUTH_TOKEN "8EGvrtXioatD1BtnS5yaYBMoUlEwWZjh"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// WiFi Credentials for Wokwi
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// These are your relay pins from your original code
const int relayPins[] = {4, 5, 6, 7, 15, 16, 17, 18};
const int numRelays = 8;
void setup() {
Serial.begin(115200);
// Initialize all relay pins as outputs
for (int i = 0; i < numRelays; i++) {
pinMode(relayPins[i], OUTPUT);
// Most Wokwi relays are ACTIVE LOW (High = Off, Low = On)
// If your relays are backwards, change HIGH to LOW here.
digitalWrite(relayPins[i], HIGH);
}
Serial.println("Connecting to Blynk...");
Blynk.begin(auth, ssid, pass);
}
// These functions connect your Virtual Pins (V1-V8) to the physical pins
// param.asInt() ? LOW : HIGH means: Button ON (1) -> Relay LOW (ON)
// If your relay turns OFF when you press ON, swap LOW and HIGH below.
BLYNK_WRITE(V1) { digitalWrite(relayPins[0], param.asInt() ? LOW : HIGH); }
BLYNK_WRITE(V2) { digitalWrite(relayPins[1], param.asInt() ? LOW : HIGH); }
BLYNK_WRITE(V3) { digitalWrite(relayPins[2], param.asInt() ? LOW : HIGH); }
BLYNK_WRITE(V4) { digitalWrite(relayPins[3], param.asInt() ? LOW : HIGH); }
BLYNK_WRITE(V5) { digitalWrite(relayPins[4], param.asInt() ? LOW : HIGH); }
BLYNK_WRITE(V6) { digitalWrite(relayPins[5], param.asInt() ? LOW : HIGH); }
BLYNK_WRITE(V7) { digitalWrite(relayPins[6], param.asInt() ? LOW : HIGH); }
BLYNK_WRITE(V8) { digitalWrite(relayPins[7], param.asInt() ? LOW : HIGH); }
void loop() {
Blynk.run();
}Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1