Skip to main content

USB to Serial Adapter

Let's learn how to use the Blackpill board as an USB to Serial adapter.

USB to Serial Adapter

When you want to communicate with a microcontroller via USB, you can use an USB to Serial adapter. Since the Blackpill board has an USB port and multiple UART channels, you can use it as an USB to Serial adapter.

Prerequisites

In this tutorial, the following hardware is used:

Blackpill STM32 board

MCU: STM32F411CEU6
Board: WeAct Black Pill V2.0
Schematic

You can purchase a cheap clone Blackpill STM32 board under $4. You can use other STM32 boards, but you need to modify platformio.ini file and the LED pin number.

You need this to upload the firmware to the board and debug the code. You can purchase a cheap clone ST-LINK V2 under $5.

Installation

VScode with PlatformIO

You can install PlatformIO from the VSCode extension marketplace.

STM32CubeProgrammer

You need this to flash the firmware to the board.

Clone the repository

git clone https://github.com/yuichiroaoki/stm32-usb-to-serial-adapter.git 
cd stm32-usb-to-serial-adapter

Quickstart

  1. Connect the Blackpill STM32 board to the ST-LINK V2 programmer.

    ST-LINK V2 Clone
    Connect the ST-LINK V2 programmer to the Blackpill STM32 board as shown in the image above.

  2. Connect the ST-LINK V2 programmer to your computer.

  3. Open the project folder in VSCode.

  4. Click on the PlatformIO tab on the left sidebar and click on the Upload button to upload the firmware to the board.

    PlatformIO tab

  5. Power off the Blackpill board and connect PA2 to the target device's RX pin and PA3 to the target device's TX pin.

    note

    You need to connnect TX to RX and RX to TX.

  6. Connect the Blackpill board to your computer using a USB cable.

That's it! Now you can communicate with the target device using the Blackpill board as an USB to Serial adapter.

References