Skip to main content

First Step

STM32 board is a powerful microcontroller board that can be used for various applications. In this tutorial, we will learn how to set up the STM32 board.

GitHub

Why STM32?

STM32 is a great choice for beginners because:

  • More powerful than Arduino
  • Debuggers are cheap
  • More peripherals
tip

If you need WiFi or Bluetooth, you should use ESP32, but if you need more power, you should use STM32. We will not talk about ESP32 in this tutorial.

esp32 vs stm32: which microcontroller is better for you?

What you'll need

In order to get started with STM32, you will need the following:

  • Blackpill/Bluepill STM32 board:
    • You can purchase a cheap clone Blackpill STM32 board under $4.
  • ST-LINK V2/V3:
    • You need this to upload the firmware to the board.
    • You can purchase a cheap clone ST-LINK V2 under $5.
  • VScode with PlatformIO or Arduino IDE:
    • You can download VSCode from here.
    • You can install PlatformIO from the VSCode extension marketplace.
  • STM32CubeProgrammer

Blackpill board
Blackpill STM32 board

DFU upload

While Blackpill STM32 board supports DFU, which means you can upload the firmware with USB, you should have a ST-LINK to use useful features like debugging.

We recommend the following stack for STM32 development:

  • VSCode with PlatformIO
    • You can use GitHub Copilot for code suggestions, which help you write code faster.
  • ST-LINK V2 Clone
    • Very cheap (< $5)
  • Blackpill STM32 board
    • Very cheap (< $4)
    • DFU support
      • You can upload the firmware using USB as well.
    • More powerful than Bluepill
  • Arduino framework
    • Easy to use
    • Good for beginners

ST-LINK V2 Clone

Arduino vs STM32Cube

There are two popular frameworks for STM32 development: Arduino and STM32Cube.

info

A framework is a collection of libraries and tools that help you write code for a microcontroller. It's like a set of building blocks that you can use to create your project.

Here is a comparison between the Arduino framework and the STM32Cube framework:

FeatureArduino FrameworkSTM32Cube Framework
Ease of UseVery easyModerate
Community SupportLargeModerate
PerformanceModerateHigh
Library AvailabilityExtensiveModerate
DebuggingBasicAdvanced
ConfigurationSimpleComplex
IDEArduino IDE, VSCodeSTM32CubeIDE, VSCode
Learning CurveLowHigh

Here's a breakdown of each feature:

Ease of Use:

  • Arduino: Known for its simplicity and beginner-friendliness.
  • STM32Cube: While not as straightforward as Arduino, it offers a structured approach with CubeMX, making configuration and code generation easier.

Community Support:

  • Arduino: A massive community with extensive resources, tutorials, and libraries.
  • STM32Cube: A growing community, but not as large as Arduino's.

Performance:

  • Arduino: While capable, it's generally less performant than STM32 due to the overhead of the Arduino framework.
  • STM32Cube: Offers higher performance due to direct access to hardware registers and optimized code generation.

Library Availability:

  • Arduino: A vast ecosystem of libraries for various tasks.
  • STM32Cube: A growing library ecosystem, but might not have the same breadth as Arduino.

Debugging:

  • Arduino: Basic debugging capabilities, often limited to serial output.
  • STM32Cube: Advanced debugging features, including GDB and J-Link support.

Configuration:

  • Arduino: Typically simpler configuration, especially for basic projects.
  • STM32Cube: More complex configuration options, especially for advanced features.

IDE:

  • Arduino: Arduino IDE or VSCode with Arduino extension.
  • STM32Cube: STM32CubeIDE or VSCode with STM32Cube extension.

Learning Curve:

  • Arduino: Easier to learn for beginners.
  • STM32Cube: Requires more in-depth knowledge of microcontrollers and embedded systems.

Overall, Arduino is a great choice for beginners and simple projects, while STM32Cube offers more flexibility, performance, and features for advanced applications.