Hey Guys,
I recently used the Blynk IoT Platform to build a project with NodeMCU8266 called "Weather Monitoring System." I started with the following code to control an LED:
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_TEMPLATE_NAME ""
#define BLYNK_AUTH_TOKEN ""
#define LED D2
// Include required libraries
#include <ESP8266WiFi.h> // Handles Wi-Fi connection
#include <BlynkSimpleEsp8266.h> // Blynk library for ESP8266
// Wi-Fi credentials (update these with your network details)
char ssid[] = ""; // Wi-Fi SSID
char pass[] = ""; // Wi-Fi Password
BLYNK_WRITE(V0)
{
int value = param.asInt(); // Read incoming value (0 or 1)
if (value == 1) {
digitalWrite(LED, HIGH); // Turn LED ON
Serial.println("LED ON");
} else {
digitalWrite(LED, LOW); // Turn LED OFF
Serial.println("LED OFF");
}
}
void setup()
{
Serial.begin(115200); // Start Serial Monitor
pinMode(LED, OUTPUT); // Configure LED pin as output
digitalWrite(LED, LOW); // Start with LED OFF
// Connect to Wi-Fi and Blynk Cloud
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop()
{
Blynk.run(); // Continuously handle Blynk events
}
Right now I have to hardcode the Wi-Fi credentials for each access point in the sketch. Since I travel between states, it’s impractical to re-upload the code every time I change networks.
Is there a way to let the device connect to any Wi-Fi and configure it without reflashing? If you have any ideas or suggestions, please share them below.
Thanks,
Rifat