The STM32 F1-series was the first group of STM32 microcontrollers based on the

ARM Cortex-M3 core and considered their mainstream ARM microcontrollers. The F1-series has evolved over time by increasing CPU speed, size of internal memory, variety of peripherals.

There are five F1 lines: Connectivity (STM32F105/107), Performance (STM32F103), USB Access (STM32F102), Access (STM32F101), Value (STM32F100).

In this post we shall explore the ways to implement Arduino core on to STM32 so that programming can be done through Arduino IDE itself.You can enjoy the speed of 32 bit microcontroller with ease of Arduino IDE programming.

STM32 is a 72 MHz processor. The full part number STM32F103C8T6  decodes to

C8 = 128 KB flash, 20 KB RAM, 48-pin LQFP:

STM32 F1xx development boards are available in wide range.Here we shall use a simple board which is also called BLUEPILL . A very efficient & economy module easily available.




Programming can be done in many ways.This post is related to using Arduino core.

As  seen in above picture , STM32 pill has 3 UARTs of which UART1 (PA9, PA10) is used to upload code.For this you need a USB-TTL module .Although the STM32 is 3.3v device many GPIO pins  (shown in yellow underline in above picture) are 5V tolerant. So you can use this USB-TTL *CP2102) module without any level shifter.

The other way to upload code is through SINGLE WIRE INTERFACE ModuleInterface (SWIM) .This uses only 2 wires SWCLK, SWDIO apart from power pins .You can see this as 4 separate header pins to the right end of module.You need a ST-LINK dongle or device to connect with the SWIM.

The ST-LINK/V2 is an in-circuit debugger/programmer for the STM8 and STM32 microcontrollers. The single wire interface module (SWIM)  interfaces facilitate the communication with any STM8 or STM32 microcontroller operating on an application board.



The bare STM32F103 board only comes with a default USART boot loader. Even though there is a USB port on the board, you cannot use it to program it because it does not have the relevant bootloader.

In the next post we shall see how to upload using USB.

For now connect the USB-TTL module to STM32 .

PA9  TX    —->   Rx of USB-TTL

PA10  RX   —->   Tx of USB-TTL

5V   —>  5V

GND  —>  GND

Plug in the USB-TTL module to USB of PC. CP2102 device driver is required so that PC allots a port number to the module.




Image 1

You can see 2 yellow jumpers on board.The bottom one is BOOT 1 & the top one is BOOT 0.

For programming you need to shift the BOOT 0 jumper to make High as shown in photo below.


Image 2


The setting of Jumpers specify  the source of code for the STM32.

In the default state of both being 0, the micro-controller uses its own flash memory bootloader (factory setting is none , there is no bootloader in fresh boards)

To program the micro using USART, you need to set BOOT0 as 1 and leave BOOT1 to 0. Move the first jumper and leave the second one.




Open the Arduino IDE .

Go to   File –> Preferences


Image 3


At the bottom of the preferences screen , copy & paste the following link


If you have some other link already here ( for e.g you might have installed for NodeMCU) , put a comma after the existing one & then paste the link

Image 4

Click OK.

Now under Tools —> Boards  select Boards Manager

Internet connection is required  to install board support chain link.

Type in STM32F1 & select STM32F1xx boards by stm32duino.


Image 6

Select the latest version & click install.

It takes some time to get installed.

Image 7

Now reopen the ARDUINO IDE.

Under Tools make the following settings:

Board : Generic STM32F103C Series

Variant : 20k ram 64k flash

Very important is Upload method which is SERIAL

Port : port no. alloted to USB-TTL

Progemmer : USBasp

Image 15


Open the Blink sketch

Add this before void setup

#define LED_BUILTIN PC13

Save the file.

Image 9


As seen in picture below , the built in LED on STM32 bluepill is mapped to PC13

Image 10


Click on Upload

Image 13



Image 3


Once the code is uploaded you can see the built in LED blinking accordingly.Now you can reset the BOOT 0 jumper back to 0 position & press Reset to start the freshly uploaded code.

For next upload you need to set the BOOT 0 to position 1 & press Reset button.

Let us see the second method to upload code through SWIM.

For this you need a ST LINK V2 dongle as shown in picture below :


Image 2




The pin details of STLINK is printed on the module itself.

Pin number starts from top , as shown below



Connect STLINK to STM32 as below :

Pin2 SWCLK   —>  DCLK of STM32

Pin4 SWDIO  —>  DIO of STM32

Pin6 GND  –>  GND

Pin 8   3.3V –>  3,3V



Before connecting ST LINK to PC , download & install the driver from below link

This USB driver (STSW-LINK009) is for ST-LINK/V2 and ST-LINK/V2-1 boards and derivatives (STM32 discovery boards, STM32 evaluation boards, STM32 Nucleo boards)


Image 11

Once the drivers are installed you see under Device Manager – > Universal Serial Bus Device

STM32 ST Link




Open the Arduino IDE

Select board as STM32F103C Series

Upload method to be selected as ST Link

Port will be greyed out ,as No selection of port required


Image 11


Note that there is no need to shift Jumper in this method of uploading.


Image 13

Just click on upload to see the inbuilt LED blinking.