🛠 Controlling GPIOs and a Simple Display on Metro ESP32-P4 Hydra
Objectifs
This tutorial guides you through discovering the digital inputs/outputs (GPIO) of the Adafruit Metro ESP32-P4 Hydra board. You will learn to configure a pin as an output to control an LED and use the serial interface to monitor system status. Although the board features advanced video interfaces (MIPI DSI), this beginner level focuses on standard GPIOs and USB-C communication to validate your development environment.
Required Hardware
- 1x Adafruit Metro ESP32-P4 Hydra Board
- 1x USB-C Data Cable
- 1x PC with Arduino IDE installed
- (Optional) 1x LED and 1x 220 Ohm resistor if using an external LED
Steps
- Environment Setup: Open Arduino IDE. Go to
File>Preferencesand add the ESP32 board manager URL in the "Additional Board Manager URLs" field. Save. - Add Board: Go to
Tools>Board>Boards Manager. Search for "esp32" and install the latest version by Espressif Systems. Restart the IDE. - Select Model: Connect the board to your PC via the USB-C port. In
Tools>Board, selectESP32-P4 Dev Module. Ensure the correct serial port is selected inTools>Port. - Write Code: Create a new sketch. Copy the following code:
const int ledPin = 2; // Standard GPIO pin on the board
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
Serial.println("LED ON");
delay(1000);
digitalWrite(ledPin, LOW);
Serial.println("LED OFF");
delay(1000);
}
- Upload: Click the "Verify" button to compile, then "Upload". Wait for compilation to finish.
- Observe: Open the Serial Monitor (Ctrl+Shift+M). Set the speed to 115200 bauds.
Verification
You should see "LED ON" and "LED OFF" messages alternating in the serial monitor every second. If your board has a user LED connected to pin 2, it will blink in sync with these messages. This confirms that USB communication works and GPIOs are correctly controlled.
Going Further
Explore MIPI DSI interfaces to connect a Raspberry Pi-compatible display. Consult ESP-IDF documentation to use the ESP32-C6 coprocessor to enable WiFi and transmit GPIO data via MQTT.
Other tutorials for this board
Code examples for this board
esp32-p4-hydra-gpio-blink.inoC++ (Arduino)esp32-p4-hydra-mpu6050-i2c.inoC++ (Arduino)esp32-p4-hydra-wifi-http.inoC++ (Arduino)esp32-p4-hydra-sdcard-write.inoC++ (Arduino)esp32-p4-hydra-usb-host-mouse.inoC++ (Arduino)esp32-p4-hydra-gpio-led-blink.inoC++ (Arduino)