The Blue Pill is a tiny, very cheap breakout board for the STM32F103C8T6, a 72 MHz Arm Cortex-M3 with 64 KB of flash and 20 KB of RAM. It looks like an Arduino Nano, but it runs at 3.3 V, it's programmed differently, and many boards sold today carry clone chips. Get those three things straight and it's a capable 32-bit board for very little money.
Quick answer: the onboard LED is PC13 (active LOW). Analog inputs are PA0–PA7, PB0, PB1 (12-bit). USART1 is PA9/PA10, I2C1 is PB6/PB7, SPI1 is PA5/PA6/PA7, and PB10/PB11 is either I2C2 or USART3, not both. USB uses PA11/PA12. Logic is 3.3 V; most digital pins tolerate 5 V, but the ten analog pins don't. Program it with an ST-Link on the SWD header; the USB port can't flash a new board until a USB bootloader is installed.
Below: the pin function table, power and 5 V tolerance, every bus with code, the three ways to upload, the USB resistor and fake-chip problems, and how the Blue Pill compares with the Black Pill.
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
What's on the Board
- STM32F103C8T6: Cortex-M3, 72 MHz, 64 KB flash, 20 KB SRAM, no FPU
- 8 MHz crystal (main clock) and 32.768 kHz crystal (RTC) on PC14/PC15
- Micro-USB connected to the chip's USB peripheral on PA11/PA12
- Two jumpers: BOOT0 (top) and BOOT1 (PB2). Both on 0 for normal running
- 4-pin SWD header at the end: 3.3V, SWDIO (PA13), SWCLK (PA14), GND
- Reset button, a power LED and the PC13 user LED
The two long headers carry different pins; each side has its own set, plus power and ground at the ends. Silkscreen labels drop the "P": A9 means PA9.
40 of 40 pins match
Hover or tap any pin on the board
LEFT header · pin 1
PB12
Safe to use
Nothing else on the board depends on this pin. A good first choice for sensors, LEDs and buttons.
Can be used as
- SPI (direct)
Signals on this pad
- PB12
- SPI2_NSS
- TIM1_BKIN
Pin Function Table
| Pin | ADC | Main peripheral roles | 5 V tolerant | Notes |
|---|---|---|---|---|
| PA0 | IN0 | TIM2_CH1, USART2_CTS, WKUP | No | |
| PA1 | IN1 | TIM2_CH2, USART2_RTS | No | |
| PA2 | IN2 | USART2_TX, TIM2_CH3 | No | |
| PA3 | IN3 | USART2_RX, TIM2_CH4 | No | |
| PA4 | IN4 | SPI1_NSS | No | |
| PA5 | IN5 | SPI1_SCK | No | |
| PA6 | IN6 | SPI1_MISO, TIM3_CH1 | No | |
| PA7 | IN7 | SPI1_MOSI, TIM3_CH2 | No | |
| PA8 | — | TIM1_CH1, MCO | Yes | |
| PA9 | — | USART1_TX, TIM1_CH2 | Yes | Serial bootloader TX |
| PA10 | — | USART1_RX, TIM1_CH3 | Yes | Serial bootloader RX |
| PA11 | — | USB D−, CAN_RX, TIM1_CH4 | Yes | Leave free when using USB |
| PA12 | — | USB D+, CAN_TX | Yes | Has the USB pull-up resistor |
| PA15 | — | SPI1_NSS (remap), TIM2_CH1 (remap) | Yes | JTAG pin at reset |
| PB0 | IN8 | TIM3_CH3 | No | |
| PB1 | IN9 | TIM3_CH4 | No | |
| PB3 | — | SPI1_SCK (remap), TIM2_CH2 (remap) | Yes | JTAG pin at reset |
| PB4 | — | SPI1_MISO (remap), TIM3_CH1 (remap) | Yes | JTAG pin at reset |
| PB5 | — | SPI1_MOSI (remap), TIM3_CH2 (remap) | Check datasheet | |
| PB6 | — | I2C1_SCL, TIM4_CH1, USART1_TX (remap) | Yes | |
| PB7 | — | I2C1_SDA, TIM4_CH2, USART1_RX (remap) | Yes | |
| PB8 | — | TIM4_CH3, I2C1_SCL (remap), CAN_RX (remap) | Yes | |
| PB9 | — | TIM4_CH4, I2C1_SDA (remap), CAN_TX (remap) | Yes | |
| PB10 | — | I2C2_SCL or USART3_TX | Yes | Shared: pick one |
| PB11 | — | I2C2_SDA or USART3_RX | Yes | Shared: pick one |
| PB12 | — | SPI2_NSS, TIM1_BKIN | Yes | |
| PB13 | — | SPI2_SCK, TIM1_CH1N | Yes | |
| PB14 | — | SPI2_MISO, TIM1_CH2N | Yes | |
| PB15 | — | SPI2_MOSI, TIM1_CH3N | Yes | |
| PC13 | — | — | No | LED, active LOW; weak pin |
| PC14 | — | — | No | 32.768 kHz crystal |
| PC15 | — | — | No | 32.768 kHz crystal |
JTAG pins. PA15, PB3 and PB4 start up as JTAG debug pins. If they don't respond as GPIO, JTAG is still enabled on them; disable JTAG while keeping SWD (STM32CubeMX: Debug: Serial Wire, or __HAL_AFIO_REMAP_SWJ_NOJTAG() in code) to free them.
PC13–PC15 are weak. They can sink only about 3 mA and switch slowly. Fine for the LED, not for driving loads or fast signals.
Power Pins and 5 V Tolerance
| Pin | What it is |
|---|---|
| 5V | USB power, or an external 5 V input to the onboard 3.3 V regulator |
| 3.3 | Regulator output, or a regulated 3.3 V input |
| VB | VBAT for the RTC and backup registers; tie to 3.3 V or a coin cell |
| G | Ground |
| R | Reset (NRST) |
Outputs are always 3.3 V. As inputs, the pins marked FT in the STM32F103 datasheet tolerate 5 V, which covers most of Port B and PA8–PA15. The analog-capable pins PA0–PA7, PB0 and PB1 are not 5 V tolerant, and no pin is while it's configured as an analog input. That makes USART1 (PA9/PA10) the convenient choice for a 5 V serial device such as a GPS module, while USART2 (PA2/PA3) needs 3.3 V signals. When in doubt, divide or level-shift.
The small onboard regulator powers the chip as well as the 3.3 V pin. Sensors are fine; servos, LED strips and Wi-Fi modules belong on their own supply.
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
Blink the PC13 LED
void setup() { pinMode(PC13, OUTPUT); }
void loop() {
digitalWrite(PC13, LOW); // LED on (active LOW)
delay(500);
digitalWrite(PC13, HIGH); // LED off
delay(500);
}If the LED looks stuck on, your code is probably running with the logic inverted.
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
ADC
Two 12-bit ADCs share the same 10 channels: PA0–PA7, PB0 and PB1, with a 0–3.3 V range. In the STM32duino core, analogRead() returns 10-bit values by default for Arduino compatibility; ask for 12 bits:
void setup() {
Serial.begin(115200);
analogReadResolution(12);
}
void loop() {
int raw = analogRead(PA0); // 0–4095
Serial.println(raw * 3.3 / 4095.0, 3); // volts
delay(200);
}A 0–5 V sensor needs a divider first, because these pins aren't 5 V tolerant. For steady readings, keep the source impedance low or add 100 nF from the pin to GND.
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
PWM and Timers
Four timers drive PWM: TIM1 (advanced, with complementary outputs on PB13–PB15 for motor bridges) and TIM2, TIM3, TIM4 (general purpose), each with four channels. Any pin with a TIMx_CHy entry in the table can output PWM. With STM32duino:
analogWriteFrequency(20000); // 20 kHz for motors
analogWriteResolution(12);
analogWrite(PA8, 2048); // ~50 % on TIM1_CH1(Older tutorials use pinMode(pin, PWM) and pwmWrite(). Those belong to the retired Maple / Roger Clark core and don't compile on STM32duino.)
Channels on the same timer share one frequency and stay in phase; put a 50 Hz servo and a 20 kHz motor on different timers, for example a servo on PB6 (TIM4) and a motor on PA8 (TIM1).
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
UART, I2C and SPI
| Bus | Pins | Notes |
|---|---|---|
| USART1 | TX PA9, RX PA10 | 5 V tolerant; also the ROM serial bootloader |
| USART2 | TX PA2, RX PA3 | 3.3 V only |
| USART3 | TX PB10, RX PB11 | Same pins as I2C2 |
| I2C1 | SCL PB6, SDA PB7 | Remap: PB8, PB9 |
| I2C2 | SCL PB10, SDA PB11 | Same pins as USART3 |
| SPI1 | SCK PA5, MISO PA6, MOSI PA7, NSS PA4 | Remap: PB3, PB4, PB5, PA15 |
| SPI2 | SCK PB13, MISO PB14, MOSI PB15, NSS PB12 |
In STM32duino, declare extra serial ports with their pins:
HardwareSerial Serial2(PA3, PA2); // RX, TX
void setup() { Serial2.begin(9600); }A BME280 on I2C1, for example:
#include <Wire.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
void setup() {
Serial.begin(115200);
Wire.begin(); // PB7 = SDA, PB6 = SCL
if (!bme.begin(0x76)) {
Serial.println("BME280 not found: check wiring and address (0x76 or 0x77)");
while (1) delay(10);
}
}
void loop() {
Serial.print(bme.readTemperature()); Serial.print(" C ");
Serial.print(bme.readHumidity()); Serial.print(" % ");
Serial.print(bme.readPressure() / 100.0F); Serial.println(" hPa");
delay(1000);
}Wiring: VCC to 3.3, GND to G, SCL to B6, SDA to B7. To use the remapped I2C1 pins, call Wire.setSCL(PB8); Wire.setSDA(PB9); before Wire.begin().
USB and CAN can't run together on this chip. They share a block of internal RAM, not only the PA11/PA12 pins, so a project that needs both needs a different STM32.
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
Uploading Code: Three Options
The F103's built-in ROM bootloader supports the serial port, not USB, so a new Blue Pill can't be flashed over its USB socket.
| Method | Hardware | BOOT0 | Best for |
|---|---|---|---|
| ST-Link (SWD) | ST-Link V2 or clone | Stays at 0 | Everyone; also gives debugging |
| Serial bootloader | 3.3 V USB-serial adapter on PA9/PA10 | Set to 1 to flash, back to 0 to run | No ST-Link available |
| USB bootloader | ST-Link or serial once, to install it | Stays at 0 | Uploading over USB afterwards |
Arduino IDE setup (STM32duino): add the STMicroelectronics board manager URL https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json, install STM32 MCU based boards and STM32CubeProgrammer, then choose Generic STM32F1 series → BluePill F103C8. Pick Upload method: STM32CubeProgrammer (SWD) for an ST-Link or (Serial) for a USB-serial adapter. To get Serial over the board's USB port, set USB support: CDC (generic 'Serial' supersede U(S)ART).
ST-Link wiring: 3.3V to 3.3, GND to GND, SWDIO to DIO, SWCLK to CLK. Power the board from the ST-Link or USB, not both.
Serial bootloader: wire the adapter's TX to A10 and RX to A9, move the BOOT0 jumper to 1, press reset, upload, then move BOOT0 back to 0 and reset. Forgetting the last step leaves the board waiting in the bootloader after every reset, which looks exactly like a dead board.
Clone Boards: Two Problems to Know About
The USB pull-up resistor. USB needs 1.5 kΩ from D+ (PA12) to 3.3 V. Many Blue Pills fit 10 kΩ at R10 instead, so some computers don't detect the board as a USB device. Replace R10 with 1.5 kΩ, or add a 1.8 kΩ resistor from PA12 to 3.3 V in parallel.
Clone or relabelled chips. Many boards carry a CKS32F103, CS32F103, GD32F103 or APM32F103 instead of a genuine STM32. Most run the same code, but some are slower to start, behave differently in the flash or USB, or make STM32CubeProgrammer report an unexpected device ID. Check the chip marking and the ST logo; if an ST-Link upload fails with an ID error, a clone is the likely cause. Buy from a seller that states a genuine STM32, or consider the Black Pill, where clones are much rarer.
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
Common Mistakes
| Mistake | Fix |
|---|---|
| LED seems stuck on or blinks inverted | PC13 is active LOW |
| Board "dead" after a serial upload | Move BOOT0 back to 0 and reset |
| Not detected over USB | No USB bootloader installed, or the R10 resistor problem |
| 5 V sensor on PA0–PA7 | Those pins aren't 5 V tolerant; divide the signal |
| I2C2 and USART3 both in the code | They share PB10/PB11; use I2C1 or USART1/2 |
| PB3, PB4 or PA15 don't respond | JTAG still enabled; switch to SWD-only |
pinMode(pin, PWM) won't compile | That's the old Maple core; use analogWrite() |
| ST-Link upload fails with an ID error | Clone chip; check the marking |
Highlighted on the SolderHub Simulator STM32 Blue Pill. Explore every pin on the STM32 Blue Pill board page.
Blue Pill vs Black Pill
| Blue Pill (F103C8) | Black Pill (F411CE) | |
|---|---|---|
| Core / clock | Cortex-M3, 72 MHz | Cortex-M4F, 100 MHz |
| Flash / RAM | 64 KB / 20 KB | 512 KB / 128 KB |
| Floating point | Software | Hardware FPU |
| USB | Micro-USB, needs a bootloader | USB-C, ROM DFU built in |
| CAN bus | Yes | No |
| Clone chips | Common | Rare |
For a new project, the STM32 Black Pill is usually the better buy. The Blue Pill still makes sense if you already have one, need CAN, or are following a tutorial written for it. For a board with a built-in debugger and Arduino shield headers, see the STM32 Nucleo.
Try your pin plan on a virtual Blue Pill. The SolderHub Simulator has the same STM32 Blue Pill you see in these figures, so you can check the wiring before you flash real hardware.
FAQ
Which pin is the Blue Pill LED? PC13, active LOW.
Is the Blue Pill 5 V tolerant? Most digital pins are, as inputs. PA0–PA7, PB0, PB1 and PC13–PC15 are not. Outputs are always 3.3 V.
Can I program the Blue Pill over USB? Not out of the box. Flash it once with an ST-Link or a USB-serial adapter, or install a USB bootloader first.
What's the ADC resolution? 12-bit (0–4095) over 0–3.3 V. Call analogReadResolution(12) in STM32duino, which defaults to 10-bit.
How many GPIOs are there? 32 on the two long headers, plus PA13/PA14 on the SWD header.
Does it have 128 KB of flash? Many C8T6 chips have 128 KB physically, but only 64 KB is guaranteed. Don't rely on the extra half.
Related guides: STM32 Black Pill pinout · STM32 Nucleo pinout · BME280 vs BMP280 · Arduino Nano pinout



