My First ESP32 Adventure: From What the Hell is This? to FINALLY!
My First ESP32 Adventure: From “What the Hell is This?” to “FINALLY!”
So there I was, scrolling through GitHub on a weekend (because that’s what we do, right?), when I stumbled across this cool repo by a senior dev I know called LucidConsole. Honestly, I didn’t understand most of it, but something about playing with electronics just clicked.
The next thing I know, this guy hands me an ESP32 and says, “You can play with it.”
And that’s how my rookie ESP32 journey began.
The “How Do I Turn This Thing On?” Moment
First question any newbie asks: “How do I turn it on?”
Simple, right? Just plug in a USB-C cable and boom! Well, not exactly. I connected it, saw the ESP32 boot screen, felt like a genius for exactly 30 seconds, then checked if it appeared in /dev on my Arch Linux machine (yes, I’m an archinstall fan and yes we do exist).
Nothing. Nada. Zero.
Quick Linux Wisdom Break
Everything connected via USB on Linux shows up in the /dev directory (short for devices, I think). When you plug in an ESP32, you should see something like ttyUSB0 appear. This is how Linux talks to USB devices through serial connections, kind of like how old computers talked to peripherals through those spider leg pins.
Here’s the 10x developer masterclass for checking connections:
- List everything in
/dev/tty* - Plug in your ESP32
- List again
- The new one that appeared? That’s your ESP32
But mine wasn’t showing up at all.
After some meditation (okay, frustrated staring), I realized the cable was just for charging. Rookie mistake number one: always check if your cable actually transfers data, not just power.
Changed the cable, and boom - there it was in /dev/ttyUSB0.
Setting Up the Dev Environment
For development, you’ve got two main options: Arduino IDE or the PlatformIO extension for VS Code. I went with PlatformIO because it seemed easier to work with.
Creating My First Project
With PlatformIO, creating a new project is pretty straightforward. Pick a name, choose your board type. If you don’t know your exact board (like me), esp32dev is usually a safe bet. I couldn’t find it in my options, so I went with mhetesp32devkit and just prayed to the electronics gods.
Guess what? It worked.
Understanding the Project Structure
When you generate a project, you get something like this:
YourProject/
├── src/
│ └── main.cpp
├── platformio.ini
└── (other folders)
For newbies like us, those two files are what matter most: main.cpp (where your code lives) and platformio.ini (where the magic configuration happens).
The Magical platformio.ini File
This file tells PlatformIO which board you’re using, what platform, and what libraries you need:
[env:mhetesp32devkit]
platform = espressif32
board = mhetesp32devkit
framework = arduino
Simple enough, even if you’ve never seen it before.
My First Blink
The ESP32 I got has two LEDs - a blue one and a red one. I could only get the blue one working (pretty sure the red one isn’t connected to a controllable pin), but that’s fine. Let’s make it blink!
#include <Arduino.h>
void setup() {
Serial.begin(115200); // Remember that serial connection?
pinMode(2, OUTPUT); // Pin 2 controls the blue LED
}
void loop() {
digitalWrite(2, HIGH); // Turn LED on
Serial.println("Blue LED on");
delay(1000);
digitalWrite(2, LOW); // Turn LED off
Serial.println("Blue LED off");
delay(1000);
}
”What the Hell is Pin 2?”
Great question! Pins are basically the legs of the board - the GPIO (General Purpose Input Output) connections. Pin 2 happens to control that blue LED. HIGH means on, LOW means off. Yeah, the terminology is a bit fancy, but deal with it.
Adding Button Control
Once I figured out the LED, I wanted to control it with a button. The ESP32 has a BOOT button on pin 0:
#include <Arduino.h>
void setup() {
Serial.begin(115200);
pinMode(2, OUTPUT); // Blue LED
pinMode(0, INPUT_PULLUP); // BOOT button
}
void loop() {
if (digitalRead(0) == LOW) { // Button pressed
digitalWrite(2, HIGH); // LED on
} else { // Button released
digitalWrite(2, LOW); // LED off
}
delay(50);
}
Pretty cool, right? Press button, LED turns on. Release button, LED turns off.
Leveling Up: The 1.9-inch LCD Display
Now here’s where things get interesting. My ESP32 came with a 1.9-inch LCD display that uses the ST7789 driver. To control this bad boy, we need to learn about SPI (Serial Peripheral Interface).
SPI is basically how the ESP32 talks to connected components through specific pins:
, MOSI: Master Out Slave In (sends data to screen) , SCLK: Serial Clock (keeps everything in sync) , CS: Chip Select (tells the screen we’re talking to it) , DC: Data/Command (distinguishes between commands and data) , RST: Reset (resets the screen) , BL: Backlight control
The “Don’t Be Dumb Like Me” Tip
Before you do anything, look up the pinout diagram for your specific board and display. Don’t waste hours guessing like I did. Search for something like “ideaspark esp32 1.9inch tft lcd display board pinout” and save yourself the headache.
Making the Display Work
To control the display, I used the TFT_eSPI library. Here’s the configuration in platformio.ini:
[env:mhetesp32devkit]
platform = espressif32
board = mhetesp32devkit
framework = arduino
monitor_speed = 115200
upload_port = /dev/ttyUSB0
lib_deps =
bodmer/TFT_eSPI@^2.5.43
build_flags =
-D USER_SETUP_LOADED=1
-D ST7789_DRIVER=1
-D TFT_WIDTH=170
-D TFT_HEIGHT=320
-D TFT_MOSI=23
-D TFT_SCLK=18
-D TFT_CS=15
-D TFT_DC=2
-D TFT_BL=32
-D TFT_RST=4
-D TFT_BACKLIGHT_ON=HIGH
And finally, the moment of truth - displaying “FINALLY!” on the screen:
#include <Arduino.h>
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI();
void setup() {
Serial.begin(115200);
// Turn on backlight
pinMode(32, OUTPUT);
digitalWrite(32, HIGH);
// Initialize display
tft.init();
tft.setRotation(1);
tft.fillScreen(TFT_BLACK);
// White text in the center
tft.setTextColor(TFT_WHITE);
tft.setTextSize(4);
// Calculate center position
int textWidth = 6 * 4 * 7; // 7 chars * 6 pixels * size 4
int textHeight = 8 * 4; // 8 pixels * size 4
int x = (320 - textWidth) / 2;
int y = (170 - textHeight) / 2;
tft.setCursor(x, y);
tft.println("FINALLY!");
Serial.println("Display working! Check the screen!");
}
void loop() {
// Nothing needed here
}
When I uploaded this code and saw “FINALLY!” appear perfectly centered on that little screen, I felt like I’d just solved quantum physics.
What I Learned
Starting with ESP32 feels overwhelming, but once you break it down:
- Get the right cable (data transfer, not just charging)
- Set up PlatformIO in VS Code
- Understand pins and GPIO
- Look up your board’s pinout before coding
- Start simple (blink an LED), then build up
The ESP32 community is incredibly rich with libraries and examples. Don’t reinvent the wheel, use what others have built and focus on learning the concepts.
Now I’m hooked. Next stop: probably making this thing connect to WiFi and control my Atay maker or something equally ridiculous.
If you’re thinking about getting started with ESP32, just do it. Get a basic board, grab a USB cable that actually works, and start blinking some LEDs. The “FINALLY!” moment when everything clicks is totally worth the initial confusion.