A comprehensive development template for the Waveshare ESP32-C6-Touch-AMOLED-2.06 board, demonstrating initialization and usage of all onboard hardware components.
- Overview
- Hardware Specifications
- Quick Start
- Hardware Components
- Project Structure
- Configuration
- Usage Examples
- Troubleshooting
- References
This template provides a complete reference implementation for the ESP32-C6-Touch-AMOLED-2.06 board. All hardware components are initialized with extensive inline documentation, making it easy to understand and modify for your own projects.
Features:
- β Complete hardware initialization for all onboard components
- β Extensive inline comments explaining each driver
- β Example code for common use cases (commented out by default)
- β LVGL v9 graphics library integration
- β Modular design - easily enable/disable components
- β Production-ready error handling
- β Optimized for performance (SPIRAM, compiler optimization)
- MCU: ESP32-C6 (RISC-V 32-bit, up to 160 MHz)
- RAM: 512KB SRAM + 16KB LP-SRAM
- Flash: 16MB external flash memory
- Wireless: WiFi 6 (802.11ax), Bluetooth 5 (LE), IEEE 802.15.4 (Zigbee/Thread)
- Display: 2.06" AMOLED, 410Γ502 pixels, 16.7M colors
- Driver IC: SH8601 (CO5300 variant)
- Interface: QSPI (4-bit data lines)
- Brightness: Up to 600 nits
- Touch: FT3168 capacitive touch controller (I2C)
- Touch Points: Multi-touch support
- IMU: QMI8658 6-axis sensor (I2C)
- 3-axis accelerometer (Β±2G to Β±16G)
- 3-axis gyroscope (Β±16 to Β±2048 dps)
- RTC: PCF85063 real-time clock (I2C)
- Battery backup support
- Alarm and timer functions
- Codec: ES8311 audio codec (I2S + I2C)
- Input: Dual digital microphones
- Output: Onboard speaker with amplifier
- Sample Rates: 8-48 kHz
- Bit Depth: 16/24/32-bit
- PMIC: AXP2101 power management IC (I2C)
- Battery: Support for 3.7V Li-Po battery (JST connector)
- Charging: Configurable charging current (up to 1A)
- Monitoring: Voltage, current, and temperature monitoring
- Power Rails: Multiple DC-DC and LDO regulators
- Flash: 16MB for code and assets
- SPIFFS: 7MB partition for files (configurable)
- ESP-IDF: Version 5.3 or later (tested with 5.5.1)
- Python: 3.8 or later
- USB Cable: USB-C cable for programming
-
Install ESP-IDF (if not already installed):
# Follow instructions at: # https://docs.espressif.com/projects/esp-idf/en/latest/esp32c6/get-started/
-
Clone or copy this template:
cd ~/your-projects cp -r path/to/template my-project cd my-project
-
Set ESP-IDF environment:
. $HOME/esp/esp-idf/export.sh
# Set the target (ESP32-C6)
idf.py set-target esp32c6
# Configure the project (optional - defaults are provided)
idf.py menuconfig
# Build the project
idf.py build
# Or use the build script
./build.sh# Flash to device
idf.py -p /dev/ttyUSB0 flash
# Flash and monitor serial output
idf.py -p /dev/ttyUSB0 flash monitorReplace /dev/ttyUSB0 with your actual port (Windows: COM3, macOS: /dev/cu.usbserial-*).
After flashing, you should see:
- Display turns on with AMOLED backlight
- Simple UI showing available hardware
- Serial output showing initialization status for all components
1. Display & Touch (main.c:163)
Driver: SH8601 via BSP Resolution: 410Γ502 pixels Interface: QSPI
// Initialize display
lv_display_t *disp = bsp_display_start();
bsp_display_backlight_on();
// Set brightness (0-100)
bsp_display_brightness_set(80);
// LVGL UI creation
bsp_display_lock(0);
lv_obj_t *label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "Hello World!");
bsp_display_unlock();Features:
- Hardware-accelerated rendering via LVGL
- Double-buffering for smooth animations
- Touch input integration
- Power-efficient AMOLED technology
2. IMU - Accelerometer & Gyroscope (main.c:258)
Sensor: QMI8658 Interface: I2C (0x6B)
// Initialize IMU
qmi8658_init(&imu_device, i2c_bus_handle, QMI8658_ADDRESS_HIGH);
// Read sensor data
qmi8658_data_t data;
qmi8658_read_sensor_data(&imu_device, &data);
ESP_LOGI(TAG, "Accel: X=%.2f Y=%.2f Z=%.2f m/sΒ²",
data.accelX, data.accelY, data.accelZ);Use Cases:
- Motion detection and gesture recognition
- Step counting and activity tracking
- Screen orientation detection
- Vibration monitoring
3. Real-Time Clock (main.c:325)
IC: PCF85063 Interface: I2C (0x51)
// Initialize RTC
pcf85063a_init(i2c_bus_handle, PCF85063_I2C_ADDRESS, &rtc_device);
// Set time
pcf85063a_time_t time = {
.year = 24, .month = 12, .day = 15,
.hour = 14, .minute = 30, .second = 0
};
pcf85063a_set_time(rtc_device, &time);
// Read time
pcf85063a_get_time(rtc_device, &time);Features:
- Battery backup (time persists without power)
- Alarm with interrupt
- Timer functionality
4. Audio - Speaker & Microphone (main.c:395)
Codec: ES8311 Interface: I2S (data) + I2C (control)
// Initialize audio
bsp_extra_codec_init();
bsp_extra_codec_set_fs(16000, 16, I2S_SLOT_MODE_STEREO);
// Set volume (0-100)
int volume;
bsp_extra_codec_volume_set(60, &volume);
// Play audio file
bsp_extra_player_init();
bsp_extra_player_play_file("/spiffs/audio.wav");
// Record audio
uint8_t buffer[1024];
size_t bytes_read;
bsp_extra_i2s_read(buffer, sizeof(buffer), &bytes_read, 100);Use Cases:
- Music playback
- Voice recording
- Voice UI / wake word detection
- Audio spectrum analysis
- Real-time audio effects
5. Power Management (main.c:210)
IC: AXP2101 Interface: I2C (0x34)
// Initialize PMU
pmu_init();
// Print status (voltage, current, temperature)
pmu_print_status();
// Access PMU directly (C++ code)
// PMU.getBatteryVoltage();
// PMU.isCharging();
// PMU.getTemperature();Features:
- Battery charging management
- Voltage and current monitoring
- Temperature monitoring
- Multiple power rails (DC-DC, LDO)
- Power event interrupts
template/
βββ main/
β βββ main.c # Main application with all drivers
β βββ idf_component.yml # Component dependencies
β βββ CMakeLists.txt # Build configuration
βββ components/
β βββ XPowersLib/ # AXP2101 PMU driver (C++)
β β βββ src/ # Library source
β β βββ port_axp2101.cpp # C wrapper for main.c
β β βββ CMakeLists.txt
β βββ bsp_extra/ # Audio utilities
β βββ src/bsp_board_extra.c
β βββ include/bsp_board_extra.h
β βββ CMakeLists.txt
βββ CMakeLists.txt # Top-level build config
βββ sdkconfig.defaults # Default ESP-IDF configuration
βββ partitions.csv # Flash partition table
βββ README.md # This file
βββ HARDWARE.md # Detailed pinout reference
βββ DRIVERS.md # Driver API documentation
# Performance
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
# SPIRAM (PSRAM)
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_SPEED_80M=y
# LVGL
CONFIG_LV_DEF_REFR_PERIOD=15 # 60 FPS refresh rate
CONFIG_LV_DRAW_SW_DRAW_UNIT_CNT=2 # Parallel rendering
# Audio
CONFIG_BSP_I2S_NUM=1
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096
# C++ Support (for XPowersLib)
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_COMPILER_CXX_RTTI=yEnable/Disable Components: Edit main.c and comment out components you don't need:
// Disable IMU initialization
// ret = init_imu();
// if (ret != ESP_OK) {
// ESP_LOGW(TAG, "IMU initialization failed");
// }Modify Dependencies: Edit main/idf_component.yml:
dependencies:
waveshare/esp32_c6_touch_amoled_2_06: "*"
# Add your dependencies hereUncomment the imu_read_task in main.c:462 and enable it in app_main():
xTaskCreate(imu_read_task, "imu_read", 4096, NULL, 5, NULL);Uncomment pmu_monitor_task in main.c:437:
xTaskCreate(pmu_monitor_task, "pmu_monitor", 4096, NULL, 5, NULL);Uncomment rtc_display_task in main.c:506:
xTaskCreate(rtc_display_task, "rtc_display", 4096, NULL, 5, NULL);- Place an audio file (WAV format) in the SPIFFS partition
- Uncomment
audio_playback_example()in main.c:543 - Call it from
app_main()
Problem: fatal error: XPowersLib.h: No such file or directory
Solution: Ensure XPowersLib component is in components/ directory
Problem: Component dependency not found
Solution: Run idf.py reconfigure to download managed components
Problem: Display stays black Solution:
- Check USB power supply (needs sufficient current)
- Verify
bsp_display_backlight_on()is called
Problem: PMU initialization fails Solution: Battery might not be connected (this is expected and safe to ignore)
Problem: Audio not working Solution:
- Ensure I2S pins are not used by other peripherals
- Check that
CONFIG_BSP_I2S_NUM=1in sdkconfig
Enable verbose logging:
idf.py menuconfig
# Component config β Log output β Default log verbosity β VerboseMonitor serial output:
idf.py monitorThis template is provided as-is for educational and development purposes. Individual components may have their own licenses:
- ESP-IDF: Apache 2.0
- LVGL: MIT
- XPowersLib: MIT
- Board schematics and hardware design: Waveshare
Feel free to:
- Report issues
- Suggest improvements
- Add more examples
- Improve documentation
- Espressif Systems - ESP-IDF and ESP32-C6
- Waveshare - Hardware design and BSP
- LVGL Team - Graphics library
- Community Contributors - Driver development and testing
Happy Building! π
For detailed hardware pinout, see HARDWARE.md For driver API documentation, see DRIVERS.md
