BLYNK – ESP32 XIAO C3
Controlling a 5V DC Motor using HC-SR04 with XIAO ESP32-C3
Development of a wireless communication system using a Xiao ESP32-C3 and Blynk platform to remotely control a light bulb (LED) through WiFi.
The purpose of this assignment is to explore networking and wireless communication between devices. In this project, a Xiao ESP32-C3 is connected to WiFi and controlled remotely using the Blynk IoT platform.
A simple lighting control system was developed where a LED represents a household light bulb. Through the Blynk mobile application, the user can turn the light ON and OFF remotely using wireless communication.
Arduino IDE was used to program the Xiao ESP32-C3. The environment allows uploading the firmware, configuring the ESP32 board and managing WiFi communication libraries.
Blynk is an IoT platform that enables communication between mobile devices and microcontrollers through the internet. It provides a dashboard interface with widgets such as buttons, sliders and indicators.
The ESP32-C3 integrates WiFi communication capabilities. Using internet connectivity, the board receives commands from the Blynk application and controls the LED remotely.
The LED acts as a simulated light bulb that can be controlled remotely.
The Xiao ESP32-C3 is powered directly through the USB-C cable connected to the computer. This also allows programming and serial monitoring.
Create an account on the Blynk IoT platform and start a new template project for ESP32 devices.
Configure a new device template selecting ESP32 as hardware and WiFi as connection type.
In the Blynk mobile dashboard, add a button widget and configure it to use Virtual Pin V0.
Install the following libraries in Arduino IDE:
Add the WiFi name, password and Blynk authentication token inside the Arduino code.
Connect the Xiao ESP32-C3 through USB-C and upload the code to the board.
Press the button in the Blynk application and verify that the LED turns ON and OFF wirelessly.
The following code establishes communication between the Xiao ESP32-C3 and the Blynk platform.
#define BLYNK_TEMPLATE_ID "YOUR_TEMPLATE_ID"
#define BLYNK_TEMPLATE_NAME "ESP32 Light Control"
#define BLYNK_AUTH_TOKEN "YOUR_AUTH_TOKEN"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
char ssid[] = "YOUR_WIFI_NAME";
char pass[] = "YOUR_WIFI_PASSWORD";
int ledPin = 2;
BLYNK_WRITE(V0)
{
int buttonState = param.asInt();
digitalWrite(ledPin, buttonState);
}
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop()
{
Blynk.run();
}
This section explains the purpose of the program. The Xiao ESP32-C6 connects with the Blynk platform to control a physical LED remotely.
/******************** XIAO ESP32-C6 + Blynk Control de LED físico desde botón virtual (V1) + Mensaje dinámico en Blynk (V2) ********************/
Communication flow:
These parameters connect the ESP32 board with the Blynk cloud server. Each project has a unique authentication token.
#define BLYNK_TEMPLATE_ID "TMPL2VCa6f9pP" #define BLYNK_TEMPLATE_NAME "Industral FabAPP" #define BLYNK_AUTH_TOKEN "RhfphMdznryF3yoH_0ufmsMbR-QR9HhJ"
Libraries allow communication between the ESP32 and WiFi/Blynk services.
#include <WiFi.h> #include <BlynkSimpleEsp32.h>
Defines the pin where the LED is connected.
#define LED_PIN D10
The LED connected to pin D10 behaves as a simulated light bulb.
Stores the WiFi network name and password used by the ESP32 to connect to the internet.
char ssid[] = "iPhone de Rod"; char pass[] = "0105rodri";
This function is executed automatically every time the virtual button V1 changes state inside the Blynk app.
BLYNK_WRITE(V1)
{
int value = param.asInt();
digitalWrite(LED_PIN, value);
if (value == 1) {
Blynk.virtualWrite(V2, "Hola ZOI");
} else {
Blynk.virtualWrite(V2, " ");
}
}
The setup function runs only once when the ESP32 starts.
void setup()
{
Serial.begin(115200);
delay(1000);
Serial.println("Iniciando sistema...");
pinMode(LED_PIN, OUTPUT);
Serial.println("Conectando a WiFi y Blynk...");
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
Serial.println("Sistema listo.");
}
The loop function runs continuously while the ESP32 is powered.
void loop()
{
Blynk.run();
}
Blynk.run() keeps the communication active between the ESP32 and the Blynk cloud server in real time.
The final system successfully demonstrates wireless networking and communication using IoT technology.
The ESP32-C3 successfully connected to the WiFi network and received commands from the Blynk application in real time.
The LED could be controlled remotely from a smartphone, demonstrating successful networking and communication between hardware and cloud platform.
This assignment demonstrated how networking and communication technologies can be integrated into embedded systems. By using the Xiao ESP32-C3 and Blynk platform, it was possible to remotely control a light through WiFi, introducing the fundamentals of IoT systems and cloud-based device interaction.