2024-03-05 15:07:54 +08:00
| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | -------- | -------- | -------- |
2022-03-23 17:23:08 +01:00
2023-03-19 12:27:51 +01:00
# USB CDC-ACM Virtual COM Port example
2022-03-23 17:23:08 +01:00
(See the README.md file in the upper level 'examples' directory for more information about examples.)
2024-10-29 12:01:11 +01:00
This example shows how to extend CDC-ACM driver for Virtual Communication Port (VCP) devices, such as CP210x, FTDI FT23x or CH34x devices.
2022-05-17 14:15:54 +02:00
2024-05-30 15:55:25 +02:00
The drivers are fetched from [ESP Component Registry ](https://components.espressif.com/ ) together with VCP service that automatically loads correct driver for plugged-in device.
2022-03-23 17:23:08 +01:00
## How to use example
2024-10-29 12:01:11 +01:00
1. Connect your USB<->UART converter to ESP board, the device will be automatically enumerated and correct driver will be loaded
2022-05-17 14:15:54 +02:00
2. Change baudrate and other line coding parameters in [cdc_acm_vcp_example_main.cpp ](main/cdc_acm_vcp_example_main.cpp ) to match your needs
3. Now you can use the usual CDC-ACM API to control the device and send data. Data are received in `handle_rx` callback
2022-03-23 17:23:08 +01:00
4. Try disconnecting and then reconnecting of the USB device to experiment with USB hotplugging
### Hardware Required
2024-10-29 12:01:11 +01:00
* Development board with USB-OTG support
* A USB cable for Power supply and programming
2022-05-17 14:15:54 +02:00
* Silicon Labs CP210x, FTDI FT23x or CP34x USB to UART converter
2022-03-23 17:23:08 +01:00
#### Pin Assignment
2024-10-29 12:01:11 +01:00
Follow instruction in [examples/usb/README.md ](../../../README.md ) for specific hardware setup.
2022-03-23 17:23:08 +01:00
### Build and Flash
Build this project and flash it to the USB host board, then run monitor tool to view serial output:
```bash
idf.py -p PORT flash monitor
```
(Replace PORT with the name of the serial port to use.)
(To exit the serial monitor, type ``Ctrl-]` `.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.