Introduction to the STM32 Bluepill
What is STM32 blue pill?
The STM32 Blue Pill is a 32-bit Arduino compatible development board that features the STM32F103C8T6. a member of the STM32 family of ARM Cortex-M3 core microcontrollers. The STM32 Blue Pill board has nearly all the capabilities of the Arduino module but with a cheaper price.
Technical Specifications
STM32F103C8T6 has operating voltage equal to 3.3V, with 10 analog inputs and 37 digital I/O pins. It have flash memory of 64/128KB and SRAM 20KB. Maximum clock frequency that can be achieved is 72MHz. I2C,SPI, UART, CAN, USB these are the possible mode of communication.
The STM32 BluePill
How to power the STM32 Blue Pill
The STM32 Blue Pill development board can be powered in different ways. Power can be provided by providing 5V to 5V pin as external supply or by supplying 3.3V directly to the 3.3V pin or by using built-in USB micro connector.
Input-Output
The Blue Pill has 4 ports with total of 37 GPIO pins, different ports have different number of pins. Ports A and B has 16pins, port C has 3pins, and Port D has 3Pins. Pull-up and pull-down resistors can be enabled on each of the pins. Each pin has a current source/sink ability of 6mA. Pin 13 has built in LED. Most of the pins can perform more than one functions like PWM, SPI-serial communication, I2C ports (two-wire communication via the IIC protocol).
STM32 blue pill pinout
- Power: 3.3V, 5V, GND these three pins can be used to power board.
- Analog pins: PA0-PA7 , PB0-PB1 these pins act as ADCs.
- Serial: TX1,RX1,TX2,RX2,TX3,RX3 these are UART pins.
- External interrupts: PA0-PA15, PB0-PB15, PC13-PC15.
- PWM: PA0-PA3,P6-PA10,PB0-PB1,PB6-PB9.
- SPI: MISO0,MISI0,SCK0,CS0, MISO1,MISI1,SCK1,CS0
- I2C: SCL1,SDA1, SCL2,SDA2
- CAN: CAN0TX,CAN0RX
How to upload program
There are two ways to program it. 1st one is using an external USB/Serial converter connected to UART1 pins, it can be programmed using Arduino software. 2nd way is STLink USB Dongle – this uses the single-wire debug interface to communicate with the board. This allows it to be programmed using advanced software like Keil/CubeMX. It also allows memory access using the STLink software.
How to set up in Arduino IDE:
One can setup IDE by following given steps:
- Open Arduino IDE and select Preferences in file section, you can also select it by ctrl + comma.
- After that Click on the Additional Board URL option and add this URL, if you want to add more than one URL you can separate them with comma.
- Next go to Tools → Board → Board Manager. Then search for STM32. Then select latest version and click install.
- Now you can select board from tools- board – generic STM32F1 series.
- Select BluePill F103C8, make U(S)ART support, as Enabled (generic ‘Serial’) and Upload method, make it as STM32CubeProgrammer (Serial).
Code for blinking LED
void setup() {
pinMode(PC13, OUTPUT);
}
void loop() {
digitalWrite(PC13, HIGH);
delay(1000);
digitalWrite(PC13, LOW);
delay(1000);
}
Code for taking reading from an Analog pin on the UNO and displaying it on an LCD Display
There are 10 analog input pins. We can use any of them, for now we will use ADC0 i.e PA0 for analog input. And 16 x 2 LCD display as output device.
//Created by Devendra Sanklecha, KRSSG, IIT Kharagpur
#include <LiquidCrystal.h>
int rs = PB11, en = PB10, d4 = PB0, d5 = PB1, d6 = PA7, d7 = PA6;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int analogInput = PA0;
void setup()
{
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“KRSSG”);
lcd.setCursor(0, 1);
lcd.print(” ADC in STM32 “);
delay(2000);
lcd.clear();
}
void loop()
{
int analogVal = analogRead(analogInput);
float inputVoltage = (float(analogVal)/4096) * 3.3;
lcd.setCursor(0, 0);
lcd.print(“ADC Value:”);
lcd.print(analogVal);
lcd.setCursor(0, 1);
lcd.print(“Voltage:”);
lcd.print(inputVoltage);
}
This blog has been submitted by KRSSG, IIT-Kharagpur under the Robocraze Club Outreach Program.
Author: Devendra Sanklecha
Excerpt
Frequently Asked Questions
1. What is the STM32 Bluepill board and what processor does it use?
The STM32 Bluepill board is a compact, low-cost development board featuring the STM32F103C8T6 microcontroller. This ARM Cortex-M3 processor operates at a clock speed of 72 MHz and supports a variety of peripherals, making it ideal for embedded applications and hobby projects.
2. How does the Bluepill differ from the Arduino Uno in capabilities?
The Bluepill offers more processing power than the Arduino Uno, boasting a 32-bit ARM Cortex-M3 processor compared to the Uno's 8-bit AVR. Additionally, the Bluepill has more memory, faster clock speeds, and advanced peripherals, which enhance its capabilities for complex projects.
3. What is the pinout for the STM32 Bluepill board?
The STM32 Bluepill features a 20-pin layout, with pins for power (3.3V, GND), digital input/output, USART, SPI, and I2C communication. For detailed pin mappings, refer to the official STM32 documentation or a pinout diagram available online.
4. How do you program the STM32 Bluepill with the Arduino IDE?
To program the Bluepill via the Arduino IDE, first install the STM32 board package through the board manager. Then, connect the board via a USB-to-serial converter. Select the appropriate board and port in the IDE, and you can upload your sketches just like with an Arduino.
5. What voltage and power supply requirements does the Bluepill have?
The STM32 Bluepill operates at 3.3V and requires a stable power supply within the range of 3.0V to 3.6V. It can typically be powered via a USB-to-serial adapter or an external power source through the VCC pin.
6. What are typical beginner projects using the STM32 Bluepill?
Typical beginner projects with the STM32 Bluepill include LED blinking, temperature sensing with a sensor module, or using a simple motor driver. These projects help develop familiarity with coding and interfacing with peripherals.
7. Are all GPIO pins on the Bluepill 5 V tolerant?
No, not all GPIO pins on the STM32 Bluepill are 5V tolerant. Most pins operate at 3.3V. Connecting 5V signals directly can damage the microcontroller, so it's important to use level shifting or resistors for such connections.
8. What development tools support the STM32 Bluepill (CubeIDE, Arduino, PlatformIO)?
The STM32 Bluepill is compatible with various development tools, including STM32 CubeIDE for professional development, Arduino IDE for ease of use, and PlatformIO for integrated support in multiple environments, making it versatile for different project needs.
9. What are the limitations of the STM32 Bluepill board for advanced projects?
Limitations of the STM32 Bluepill include a lack of built-in debugging tools, fewer I/O pins compared to larger boards, and limited community support for some advanced libraries. Careful planning is needed for complex applications that require extensive resources.
10. Where should you buy a genuine STM32 Bluepill board to avoid fakes?
To avoid counterfeit products, purchase the STM32 Bluepill from reputable electronics retailers or official distributors.RoboCraze sells genuine boards, ensuring quality and reliability for your projects.
1. What is the STM32 Bluepill board and what processor does it use?
The STM32 Bluepill board is a compact, low-cost development board featuring the STM32F103C8T6 microcontroller. This ARM Cortex-M3 processor operates at a clock speed of 72 MHz and supports a variety of peripherals, making it ideal for embedded applications and hobby projects.
2. How does the Bluepill differ from the Arduino Uno in capabilities?
The Bluepill offers more processing power than the Arduino Uno, boasting a 32-bit ARM Cortex-M3 processor compared to the Uno's 8-bit AVR. Additionally, the Bluepill has more memory, faster clock speeds, and advanced peripherals, which enhance its capabilities for complex projects.
3. What is the pinout for the STM32 Bluepill board?
The STM32 Bluepill features a 20-pin layout, with pins for power (3.3V, GND), digital input/output, USART, SPI, and I2C communication. For detailed pin mappings, refer to the official STM32 documentation or a pinout diagram available online.
4. How do you program the STM32 Bluepill with the Arduino IDE?
To program the Bluepill via the Arduino IDE, first install the STM32 board package through the board manager. Then, connect the board via a USB-to-serial converter. Select the appropriate board and port in the IDE, and you can upload your sketches just like with an Arduino.
5. What voltage and power supply requirements does the Bluepill have?
The STM32 Bluepill operates at 3.3V and requires a stable power supply within the range of 3.0V to 3.6V. It can typically be powered via a USB-to-serial adapter or an external power source through the VCC pin.
6. What are typical beginner projects using the STM32 Bluepill?
Typical beginner projects with the STM32 Bluepill include LED blinking, temperature sensing with a sensor module, or using a simple motor driver. These projects help develop familiarity with coding and interfacing with peripherals.
7. Are all GPIO pins on the Bluepill 5 V tolerant?
No, not all GPIO pins on the STM32 Bluepill are 5V tolerant. Most pins operate at 3.3V. Connecting 5V signals directly can damage the microcontroller, so it's important to use level shifting or resistors for such connections.
8. What development tools support the STM32 Bluepill (CubeIDE, Arduino, PlatformIO)?
The STM32 Bluepill is compatible with various development tools, including STM32 CubeIDE for professional development, Arduino IDE for ease of use, and PlatformIO for integrated support in multiple environments, making it versatile for different project needs.
9. What are the limitations of the STM32 Bluepill board for advanced projects?
Limitations of the STM32 Bluepill include a lack of built-in debugging tools, fewer I/O pins compared to larger boards, and limited community support for some advanced libraries. Careful planning is needed for complex applications that require extensive resources.
10. Where should you buy a genuine STM32 Bluepill board to avoid fakes?
To avoid counterfeit products, purchase the STM32 Bluepill from reputable electronics retailers or official distributors.RoboCraze sells genuine boards, ensuring quality and reliability for your projects.
