How to program STM32F103C8T6 with ArduinoIDE

Nov 15th, 2021 | by: Noob 7868
Category: Electronics Arduino
Views 951
The STM32F103C8T6 board-also known as Blue Pill-is the development board M3 microcontroller of ARM Cortex. It looks very similar to Arduino Nano, but it contains more functions.

In this article, I will show you how to set up STM32 using Arduino IDE and show you how to program directly from the USB UART module.

STM32 overview "Blue Pill"

If you look at this $2 microcontroller, the first thing you see is its jumper pins, which are used to use the default USART bootloader. There is also a micro USB port on the board, but unfortunately it cannot be used for programming because it does not have an associated bootloader.

Compared with the official Arduino boards, these boards are very cheap and the hardware is open source. In addition to the microcontroller, the board can also accommodate two crystal oscillators-an 8MHz crystal and a 32KHz crystal-which can be used to drive the internal RTC (Real Time Clock). Therefore, the MCU can work in deep sleep mode, which is very suitable for battery-powered applications.

To program the board, we need to use a simple USB to UART converter, and then we can program it directly from the computer via USB.

STM32 pinout

Required materials
STM32 F103C8T6
USB to UART converter (FTDI)
Arduino IDE

Wiring project
Connect the circuit boards according to the connections shown in the Fritzing diagram below and connect them to the computer.

Fritzing diagram
Use the build settings with jumpers in place.
Connect the jumper as shown in the figure below, set the circuit board to DFU mode (device firmware upgrade), and then press the "reset" button.
PIC03 04

Set up STM32 on Arduino IDE

Open the Arduino IDE and select preferences.

Click the "Other Board URL" option and add this URL after the comma:
PIC06. 07

Then click Tools→Boards→Board Manager.

After performing the above steps, you can see STM32 in the board list. Now select STM32F103C.

Because we use the UART module to upload code, we choose Upload Method as Serial.

Select Blink sketch from the example.

Use "PC13" to change the LED pin number, as shown in the screenshot below. This is the name of the built-in LED in the circuit board

Project source code

void setup() {

// change pin PC13

pinMode(PC13, OUTPUT);


//infinite loop

void loop() {

digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second


Upload the code to the Arduino IDE

Upload the code now.

Uploaded successfully!

in conclusion
If the program has been uploaded successfully, you should see the green LED flashing at 1 second intervals. You can also use this program to increase or decrease the delay of the LED lights.
After uploading the program, you should change the jumper back to the normal mode so that the uploaded program will automatically start to execute when the circuit board is turned on next time.




Login or Sign Up to post comments on this project.