close
close
Getting started with STM32 Blue Pill in Arduino IDE

This comprehensive tutorial will walk you through the process of setting up and programming the STM32 Blue Pill using the Arduino IDE and a DSD TECH SH-U09C5 USB to TTL converter. The STM32 Blue Pill is a powerful yet affordable microcontroller board based on the STM32F103C8T6 ARM Cortex-M3 processor. Known for its robustness and versatility, the Blue Pill is an excellent choice for hobbyists, makers, and professionals looking to harness the power of the 32-bit ARM architecture in their projects.

Why the STM32 Blue Pill?

The STM32 Blue Pill offers an impressive range of features at a fraction of the cost of similar microcontrollers. With a clock speed of 72 MHz, 20 KB of RAM and 64 KB of flash memory, it outperforms many 8-bit microcontrollers, making it suitable for more demanding applications such as real-time data processing, motor control and advanced sensor integration. Its wide range of peripherals, including SPI, I2C, USART and ADC, enables seamless interfacing with various components, sensors and modules.

Additionally, the STM32 Blue Pill is well supported by the open source community and has various development environments available, including the Arduino IDE, making it accessible to those familiar with Arduino but looking to move on to more advanced hardware.

Why use a USB to TTL converter?

Unlike many Arduino boards, the STM32 Blue Pill does not have a built-in USB to serial converter, which is typically used for uploading code and debugging. Instead, the board is equipped with UART (Universal Asynchronous Receiver-Transmitter) pins, which require an external converter to communicate with your computer. The DSD TECH SH-U09C5 USB to TTL converter acts as a bridge between your computer’s USB port and the UART pins on the Blue Pill, allowing you to upload code, monitor serial output, and debug your programs. This converter is an essential tool for working with the STM32 Blue Pill, enabling seamless communication between the board and your development environment.

Getting started with a pre-soldered board

For those who want to get straight into development without having to deal with soldering, there are pre-soldered STM32 Blue Pill boards available at Schillehtek. These boards are delivered ready to use, so you can immediately focus on implementing your projects.

— — –

Before we delve deeper into the topic, we invite you to support our ongoing efforts and explore our different platforms to enhance your IoT projects:

  • Subscribe to our YouTube channel: Stay up to date with our latest tutorials and project information by subscribing to our channel at YouTube – Shilleh.
  • Support us: Your support is invaluable. Please consider buying me a coffee at Buy me a coffeeor help us continue to create high-quality content.
  • Hire experts for IoT services: For personal support with your IoT projects, contact me at UpWork.

ShillehTek Website (Exclusive Discounts):

https://shillehtek.com/collections/all

ShillehTekAmazon Store:

ShillehTek Amazon Store – USA

ShillehTek Amazon Store – Canada

ShillehTek Amazon Store – Japan

Step 1: Connect the STM32 Blue Pill to the USB to TTL converter

To begin, you need to connect your STM32 Blue Pill to your computer using the DSD TECH SH-U09C5 USB to TTL converter. This converter allows your computer to communicate with the STM32 Blue Pill via its UART interface.

Cabling structure:

  • RXD-SH-U09C5 -> PA9 (RX on blue pill)
  • TXD (SH-U09C5) -> PA10 (TX on blue pill)
  • Mass (SH-U09C5) -> GND (Blue Pill)
  • VCC-SH-U09C5 -> 3.3 V (blue pill)

Set the BOOT0 jumper:

  • Set the BOOT0 jumper on the Blue Pill to 1 Position (this will put the Blue Pill into UART bootloader mode). See the diagram below for the bootloader mode.

Make sure to connect the TTL converter to power. You can simply connect it to your computer if it has a USB port!

Step 2: Install STM32 support in Arduino IDE

Before you can program the STM32 Blue Pill in the Arduino IDE, you need to install support for STM32 boards.

Step 1: Open the Arduino IDE settings

  • Open the Arduino IDE.
  • Go to File > Preferences.

Step 2: Add STM32 Board Manager URL

In the Additional Boards Manager URLs field, add the following URL:

https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json

Click OK.

Step 3: Install STM32 cards

  • Go to Tools > Board > Board Manager.
  • Search for STM32 and click on Install next to the “STM32 MCU-based Boards” package.

Step 3: Select the STM32 Blue Pill board in the Arduino IDE

After installing STM32 support, you need to configure the Arduino IDE to use the correct settings for your STM32 Blue Pill.

Step 1: Select the board

  • Go to Tools > Boards > STM32 boards and select Generic STM32F1 series.

Step 2: Configure board settings

  • Under Tools > Board part numberchoose BluePill F103C8 (or BluePill F103CB if you have the 128 KB Flash version).
  • Place the Upload method To STM32CubeProgrammer (Serial).
  • Place the Harbor to the port connected to the device.

Step 4: Install STM32CubeProgrammer

To upload code to the STM32 Blue Pill via the serial interface, STM32CubeProgrammer is required.

Step 1: Download and install STM32CubeProgrammer

  • Download STM32CubeProgrammer from : STMicroelectronics.
  • Make sure you create a free account if you haven’t already.
  • Install it on your system by following the on-screen instructions. Downloads are available for various operating systems.

Step 2: Set environment variables

Open a terminal and add the path STM32CubeProgrammer to the STM32_PRG_PATH Environment variable.

For macOS, add the following line to your ~/.zshrc or ~/.bash_profile File:

  • export STM32_PRG_PATH=/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin

Apply the changes by doing the following:

or

For Windows:

  • Open the Start menu and search for “Environment Variables”.
  • From the search results, select Edit system environment variables.
  • In the System Properties window, click the Environment Variables button.
  • Under System Variables (or User Variables if you prefer), click New.
  • Variable name:STM32_PRG_PATH
  • Variable value: The path to the STM32CubeProgrammer bin Directory, such as:
  • C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin

Click OK to save the new environment variable.

Close the Environment Variables and System Properties windows.

Step 5: Upload your first program

Now that everything is set up, you can upload your first program to the STM32 Blue Pill.

Step 1: Write the code

  • Open a new sketch in the Arduino IDE and write a simple program. Here is an example that prints a message to the serial monitor:
void setup() {
// Start the Serial communication at 9600 baud
Serial.begin(9600);

// Wait for the serial port to connect (necessary for some boards)
while (!Serial) {
; // Wait
}
}

void loop() {
// Print a message to the Serial Monitor
Serial.println("Hello, Blue Pill!");

// Wait for 1 second
delay(1000);
}

Step 2: Reset the blue pill

  • Before you click the Upload button in Arduino IDE, press the Reset button on the Blue Pill board. This ensures that the board is ready to receive the program.

Step 3: Upload the code

  • Click on the Upload Button in the Arduino IDE.
  • After the upload is complete, you will see the onboard LED blinking in intervals. If you want to upload another script, you can press the reset button, change the script and upload again!

Troubleshooting

  • If you have problems uploading:
  • Make sure the correct port is selected.
  • Check your wiring and jumper settings.
  • Check if the STM32_PRG_PATH Environment variable is set correctly.
  • Make sure your board is authentic, like the board of STM32 ShillehTek Amazon Store. The circuit board is also delivered pre-soldered.

Diploma

Congratulations! You have successfully set up and programmed your STM32 Blue Pill using the Arduino IDE and the DSD TECH SH-U09C5 USB to TTL converter. This powerful microcontroller opens up a world of possibilities for your projects, offering the power of a 32-bit ARM Cortex-M3 processor at an affordable price. Whether you are a beginner or an experienced developer, the STM32 Blue Pill is a versatile tool that will help you bring your ideas to life.

If you found this tutorial helpful, be sure to check out more content on my YouTube channel where I regularly share tips, tutorials and project ideas to help you get the most out of your development boards and microcontrollers. Don’t forget to subscribe at MM Shilleh on YouTube to stay updated with the latest videos. Good luck with your projects!

By Bronte

Leave a Reply

Your email address will not be published. Required fields are marked *