The ESP-WROOM-32 is a powerful microcontroller module built on the ESP32 chip, renowned for its versatility in IoT (Internet of Things) and embedded systems. Whether you're developing smart home devices or automation systems, mastering the basics is crucial. This tutorial will guide you through the LED blink project, a perfect starting point for ESP-WROOM-32 beginners.
Why Learn the LED Blink Tutorial?
The LED blink tutorial is a foundational exercise for understanding microcontroller programming. It helps you familiarize yourself with GPIO pin manipulation and the basic setup required for more complex ESP32 projects, such as Wi-Fi-controlled devices or sensor-based control systems.
What You'll Need
Gather the following components before starting:
- ESP-WROOM-32 module
- Breadboard
- LED (any color)
- 220-ohm resistor
- Jumper wires
- USB cable (to connect the ESP-WROOM-32 to your computer)
Pro Tip: Double-check the resistor value to ensure the LED doesn’t get damaged during operation.
Step 1: Setting Up the Arduino IDE for ESP-WROOM-32
To program the ESP-WROOM-32, we’ll use the Arduino IDE, which is beginner-friendly and supports ESP32 programming.
Installing the ESP32 Board in Arduino IDE
- Open the Arduino IDE.
- Navigate to
File
>Preferences
. - In the "Additional Board Manager URLs" field, paste the following URL:https://dl.espressif.com/dl/package_esp32_index.json
- Click OK.
- Go to
Tools
>Board
>Boards Manager
. - Search for ESP32 in the Boards Manager window.
- Install the package labeled "ESP32 by Espressif Systems".
Once installed, the ESP32 board options will appear in the Arduino IDE.
Step 2: Connecting the Hardware
Here’s how to wire the components:
- Place the ESP-WROOM-32 module on the breadboard.
- Connect the anode (longer leg) of the LED to GPIO pin 16 of the ESP-WROOM-32.
- Connect the cathode (shorter leg) of the LED to one end of the 220-ohm resistor.
- Connect the other end of the resistor to the GND (ground) pin on the ESP-WROOM-32.
- Use a USB cable to connect the ESP-WROOM-32 to your computer.
Tip: Double-check all connections to avoid damaging the components.
Circuit Diagram:
Step 3: Writing the Code
Now that the hardware is ready, write the following Arduino sketch to blink the LED:
// Define the LED pin
const int ledPin = 16;
// The setup function runs once when the board starts
void setup() {
pinMode(ledPin, OUTPUT); // Configure the LED pin as an output
}
// The loop function runs repeatedly
void loop() {
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(1000); // Wait for 1 second
digitalWrite(ledPin, LOW); // Turn the LED off
delay(1000); // Wait for 1 second
}