👋
Hello ESP32 A friend recently handed me a small circuit board, a QuinLED ESP32 WROOM 32E. My first thought was, “Great, another project for the drawer!” I had no idea what it was for, but a quick search revealed its primary purpose: controlling addressable LED strips. There was just one small problem—I didn’t have any LEDs.
So, what do you do with a specialized board when you don’t have its specialty components? You ignore its intended purpose and see what else it can do. At its heart, it’s an ESP32, a powerful little chip with Wi-Fi and Bluetooth. That sounded like a good place to start.
The “Hello, World!” of Hardware
Before diving into anything complex, I had to perform the mandatory ritual of any new microcontroller: the blink test. It’s the hardware equivalent of “Hello, World!”, a simple sanity check to make sure everything is working. I fired up the Arduino IDE, configured it for the ESP32, and uploaded a basic sketch to flash the onboard blue LED.
// The classic blink sketch for an ESP32
int LED_BUILTIN = 2;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
Success! The tiny blue light started blinking away. My board was alive. This simple victory confirmed that my computer could talk to the board and upload code. Now, the real fun could begin.
Becoming a Network Detective
With no LEDs to play with, I turned my attention to the ESP32’s Wi-Fi capabilities. First, I wrote a simple scanner to see all the Wi-Fi networks in my house. It worked perfectly, listing out my home network, my neighbours’ networks, and a few mysterious ones I’d never noticed before.
This sparked an idea: could I use the ESP32 to see all the devices connected to my own network?
My first attempt involved pinging every IP address on my local subnet. This required a library, ESP32Ping.h, which, of course, the Arduino IDE couldn’t find. This led to the first classic tinkerer’s hurdle: manually downloading the library from GitHub as a ZIP file and adding it to the IDE.
// A snippet from the more successful ARP scanner
#include <WiFi.h>
#include <esp_arp.h> // Built-in ARP functionality
// ... (Wi-Fi connection logic) ...
void loop() {
Serial.println("\nStarting ARP network scan...");
int arp_count = esp_arp_get_count();
if (arp_count == 0) {
Serial.println("No devices found in ARP table. Probing...");
// Probe all IPs on the subnet to populate the table
IPAddress localIP = WiFi.localIP();
for (int i = 1; i < 255; i++) {
IPAddress target(localIP[0], localIP[1], localIP[2], i);
esp_arp_find(NULL, target, 0, false);
delay(10);
}
}
// Now, print the populated ARP table
Serial.println("Detected devices (IP : MAC):");
arp_count = esp_arp_get_count();
for (int i = 0; i < arp_count; i++) {
ip4_addr_t ip;
esp_eth_mac_addr_t mac;
if (esp_arp_get_entry(i, &ip, mac)) {
// Logic to print IP and MAC address
}
}
delay(30000); // Wait 30 seconds before the next scan
}
A list of IP and MAC addresses scrolled up the screen. My laptop, my phone, my smart TV—they were all there. I had turned my little LED controller into a network surveillance tool.
The Bluetooth Gauntlet
High on my networking success, I decided to tackle the final frontier: Bluetooth. My goal was to connect a wireless mouse. How hard could it be?
As it turns out, very.
The first challenge was finding the mouse’s MAC address. The standard BLE scan showed a list of addresses, but most were nameless. Which one was my mouse? After several attempts to isolate it by turning things on and off, I hit another wall.
The next step was to try connecting directly, which led to a loop of failure:
Attempting connection...
Connection failed.
Disconnected. Attempting reconnect...
I checked everything. The MAC address was correct. The mouse was in pairing mode. It wasn’t connected to anything else. I restarted the board, reset the mouse, and moved them right next to each other. Nothing.
This is where the real debugging began. My final hypothesis is that the mouse is actively rejecting the connection. It expects to connect to a standard host like a laptop or a phone, and it sees the ESP32 as an unknown, untrusted device. The device itself is enforcing a security policy that my simple connection request isn’t satisfying.
Here’s the final code I was working with, attempting to connect and listen for events:
#include <BLEDevice.h>
#include <BLEClient.h>
// Replace with your mouse's MAC address
static BLEAddress remoteDeviceAddress("XX:XX:XX:XX:XX:XX");
// ... (UUIDs and client setup) ...
void setup() {
Serial.begin(115200);
BLEDevice::init("");
pClient = BLEDevice::createClient();
Serial.println("Attempting connection...");
if (!pClient->connect(remoteDeviceAddress)) {
Serial.println("Connection failed.");
return;
}
Serial.println("Connected!");
// ... logic to subscribe to notifications ...
}
void loop() {
// ... reconnection logic ...
}
For now, the mouse remains unconquered. But the journey has been a fantastic exploration of what this little board can do. It started as a simple LED controller and became a platform for network scanning and a lesson in the complexities of Bluetooth security.
And maybe, just maybe, I’ll buy some LEDs for it next week.
A friend recently handed me a small circuit board, a QuinLED ESP32 WROOM 32E. My first thought was, “Great, another project for the drawer!” I had no idea what it was for, but a quick search revealed its primary purpose: controlling addressable LED strips. There was just one small problem—I didn’t have any LEDs.
So, what do you do with a specialized board when you don’t have its specialty components? You ignore its intended purpose and see what else it can do. At its heart, it’s an ESP32, a powerful little chip with Wi-Fi and Bluetooth. That sounded like a good place to start.
The “Hello, World!” of Hardware
Before diving into anything complex, I had to perform the mandatory ritual of any new microcontroller: the blink test. It’s the hardware equivalent of “Hello, World!”, a simple sanity check to make sure everything is working. I fired up the Arduino IDE, configured it for the ESP32, and uploaded a basic sketch to flash the onboard blue LED.
// The classic blink sketch for an ESP32
int LED_BUILTIN = 2;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
Success! The tiny blue light started blinking away. My board was alive. This simple victory confirmed that my computer could talk to the board and upload code. Now, the real fun could begin.
Becoming a Network Detective
With no LEDs to play with, I turned my attention to the ESP32’s Wi-Fi capabilities. First, I wrote a simple scanner to see all the Wi-Fi networks in my house. It worked perfectly, listing out my home network, my neighbours’ networks, and a few mysterious ones I’d never noticed before.
This sparked an idea: could I use the ESP32 to see all the devices connected to my own network?
My first attempt involved pinging every IP address on my local subnet. This required a library, ESP32Ping.h, which, of course, the Arduino IDE couldn’t find. This led to the first classic tinkerer’s hurdle: manually downloading the library from GitHub as a ZIP file and adding it to the IDE.
// A snippet from the more successful ARP scanner
#include <WiFi.h>
#include <esp_arp.h> // Built-in ARP functionality
// ... (Wi-Fi connection logic) ...
void loop() {
Serial.println("\nStarting ARP network scan...");
int arp_count = esp_arp_get_count();
if (arp_count == 0) {
Serial.println("No devices found in ARP table. Probing...");
// Probe all IPs on the subnet to populate the table
IPAddress localIP = WiFi.localIP();
for (int i = 1; i < 255; i++) {
IPAddress target(localIP[0], localIP[1], localIP[2], i);
esp_arp_find(NULL, target, 0, false);
delay(10);
}
}
// Now, print the populated ARP table
Serial.println("Detected devices (IP : MAC):");
arp_count = esp_arp_get_count();
for (int i = 0; i < arp_count; i++) {
ip4_addr_t ip;
esp_eth_mac_addr_t mac;
if (esp_arp_get_entry(i, &ip, mac)) {
// Logic to print IP and MAC address
}
}
delay(30000); // Wait 30 seconds before the next scan
}
A list of IP and MAC addresses scrolled up the screen. My laptop, my phone, my smart TV—they were all there. I had turned my little LED controller into a network surveillance tool.
The Bluetooth Gauntlet
High on my networking success, I decided to tackle the final frontier: Bluetooth. My goal was to connect a wireless mouse. How hard could it be?
As it turns out, very.
The first challenge was finding the mouse’s MAC address. The standard BLE scan showed a list of addresses, but most were nameless. Which one was my mouse? After several attempts to isolate it by turning things on and off, I hit another wall.
The next step was to try connecting directly, which led to a loop of failure:
Attempting connection...
Connection failed.
Disconnected. Attempting reconnect...
I checked everything. The MAC address was correct. The mouse was in pairing mode. It wasn’t connected to anything else. I restarted the board, reset the mouse, and moved them right next to each other. Nothing.
This is where the real debugging began. My final hypothesis is that the mouse is actively rejecting the connection. It expects to connect to a standard host like a laptop or a phone, and it sees the ESP32 as an unknown, untrusted device. The device itself is enforcing a security policy that my simple connection request isn’t satisfying.
Here’s the final code I was working with, attempting to connect and listen for events:
#include <BLEDevice.h>
#include <BLEClient.h>
// Replace with your mouse's MAC address
static BLEAddress remoteDeviceAddress("XX:XX:XX:XX:XX:XX");
// ... (UUIDs and client setup) ...
void setup() {
Serial.begin(115200);
BLEDevice::init("");
pClient = BLEDevice::createClient();
Serial.println("Attempting connection...");
if (!pClient->connect(remoteDeviceAddress)) {
Serial.println("Connection failed.");
return;
}
Serial.println("Connected!");
// ... logic to subscribe to notifications ...
}
void loop() {
// ... reconnection logic ...
}
For now, the mouse remains unconquered. But the journey has been a fantastic exploration of what this little board can do. It started as a simple LED controller and became a platform for network scanning and a lesson in the complexities of Bluetooth security.
And maybe, just maybe, I’ll buy some LEDs for it next week.