So basically, I am trying to delve into IoT using Blynk. This mini project main purpose is to turn on and off using Blynk. Currently I have set up the connection using GP1 and GND1 for the external LED. On a side note, I followed guidance from YouTube regarding on how to setup the Blynk, I have created new template, DataStream, and Dashboard. I ran into issues with the code where I can’t find the right library to include to run the project. Any help and assistance are much appreciated.
#define BLYNK_TEMPLATE_ID "###"
#define BLYNK_TEMPLATE_NAME "###"
#define BLYNK_AUTH_TOKEN "###"
#include <WiFi.h> // WiFi library for Pico W
#include <BlynkSimpleEsp32.h> // Blynk library compatible with Pico W
// Wi-Fi credentials
const char* ssid = "###";
const char* password = "###";
// GPIO pin for the LED
const int ledPin = 2; // GPIO 2
void setup() {
// Initialize Serial Monitor
Serial.begin(115200);
// Initialize LED pin as output
pinMode(ledPin, OUTPUT);
// Turn off LED initially
digitalWrite(ledPin, LOW);
// Connect to Wi-Fi
Serial.println("Connecting to Wi-Fi...");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected to Wi-Fi");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
// Connect to Blynk
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, password);
Serial.println("Connected to Blynk");
}
void loop() {
Blynk.run(); // Handle Blynk connection
}
// Virtual pin V0 controls the LED
BLYNK_WRITE(V0) {
int value = param.asInt(); // Get value from Blynk app
digitalWrite(ledPin, value); // Set LED state
Serial.print("LED: ");
Serial.println(value ? "ON" : "OFF");
}