This STM32 Blue Pill board project shows how to build a digital counter with TM1637 4-digit 7-segment display module. This counter automatically increments from 0 to 9999 with a predefined delay time between each two increments.
The STM32 Blue Pill development board is based on STMicroelectronics ARM Cortex-M3 microcontroller STM32F103C8T6 running at maximum clock frequency of 72MHz. This particular development board gained popularity due to its low cost and compact size, making it a popular choice for hobbyists, students, and developers.
To use the STM32 Blue Pill, a hardware programmer, such as the ST-Link, is required to upload the code to the board. A USB-to-Serial converter module can also be used to upload the code to the board, one example of this converter is the popular one from FTDI which is FT232RL module.
The TM1637 Module:
The TM1637 module is a display module based on TM1637 driver chip integrated with 4-digit 7-segment LED display. Due to its simplicity, the TM1637 display module is commonly used by students and hobbyists electronics projects for displaying numerical information such as time, temperature, or other sensor data. It simplifies the interface between a microcontroller based system (such as: Arduino, STM32 Blue Pill, ESP32…) and a 4-digit 7-segment display.
TM1637 Module Features:
The TM1637 display module has several features that make it useful for a variety of applications, including:
- Low power consumption: The driver IC can operate at a low voltage of 3.3V and has a low power consumption (typical operating voltage is always 5V), making it suitable for battery-powered applications.
- Built-in oscillator: The TM1637 has an integrated RC oscillator that can generate a signal for the display without requiring an external crystal or clock source.
- Brightness control: The TM1637 has a built-in 8-level brightness control function that can be adjusted through software.
- Flexible interface: The two-wire interface used by the TM1637 is simple and easy to use, allowing it to be connected to a variety of microcontrollers.
- Low pin count: Only requires two pins from the microcontroller (CLK and DIO).
The TM1637 is commonly used in various applications such as digital clocks, timers, and scoreboards. Its simplicity and ease of use make it a popular choice for hobbyists and makers. Additionally, there are many libraries and code examples available for using this type of display with various microcontrollers, making it easy to get started with.
TM1637 Module Pinout:
The TM1637 module used in this project is shown below:
The TM1637 module has a total of 4 pins, which include the following:
- VCC: This pin is connected to the positive terminal of the power supply, typically 5V.
- GND: This pin is connected to the ground.
- DIO: This pin is connected to a digital pin on the Arduino board and used for data signal input/output.
- CLK: This pin is connected to a digital pin on the Arduino board and used for clock signal input.
Note that the pinout can vary slightly between different models or manufacturers of the TM1637 module. It is always a good idea to refer to the datasheet or documentation provided by the manufacturer for the specific module you are using.
TM1637 Module Circuit Schematic Diagram:
The circuit diagram of the TM1637 module is very simple, the basic components are the TM1637 IC and the 4-digit 7-segment display, there are also 4 SMD capacitors and 3 SMD resistors and 1 SMD LED (Light-Emitting Diode). Circuit schematic diagram of the TM1637 display module is shown below.
Interfacing STM32 Blue Pill Board with TM1637 7-Segment Display Module Circuit:
Project interfacing circuit of the Blue Pill board with TM1637 module is shown below.
Project circuit diagram is very simple as shown above, only 4 wires are required to connect the STM32 Blue Pill board with the TM1637 display module.
The TM1637 module is connected to the STM32 board as follows:
- CLK pin of the TM1637 is connected to pin PB11 of the STM32 board.
- DIO pin of the TM1637 is connected to pin PB10 of the STM32 board.
- GND pin of the TM1637 is connected to GND pin of the STM32 board.
- VCC pin of the TM1637 is connected to 5V pin of the STM32 board.
Note that PB10 and PB11 are 5V tolerant pins.
Hardware required:
This is a summary of project required parts.
- STM32 Blue Pill board —> STM32F103C8T6 32-bit Arm Cortex-M3 MCU
- TM1637 display module —> TM1637 IC datasheet
- Jumper wires
- STM32 Microcontroller programmer (ST-Link, USB-to-Serial converter…)
Interfacing STM32 Blue Pill with TM1637 Module Code:
Arduino IDE (Integrated Development Environment) is used to write project code, the STM32 Blue Pill board has to be added to the IDE before code compilation.
The STM32 Blue Pill board can be installed using Arduino IDE Boards Manager.
The FT232RL USB to serial UART converter is used to program the STM32F103C8T6 microcontroller, the ST-LINK V2 programmer also can be used and it is supported by the Arduino IDE.
A library for the TM1637 simplify the interfacing code of the STM32 Blue Pill board with the display module. This library is written by ‘Avishay Orpaz’ and contains a useful built-in functions that control the display.
The TM1637 library can be installed through Arduino IDE Library Manager, in the search filter box write “TM1637” and install the one written by ‘Avishay Orpaz’. It also can be downloaded and installed manually, GitHub link is below:
TM1637 Module Arduino Library
After installing the library, it’s included in the Arduino as:
1 2 | // include TM1637 display module library #include <TM1637Display.h> |
And the TM1637 display module pins are defined in the Arduino code as:
1 2 3 | // define TM1637 Module connection pins #define CLK PB11 // clock pin #define DIO PB10 // data pin |
Rest of code is described through comments.
Full Arduino code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /****************************************************************************** * STM32F103C8T6 Blue Pill board Interface with TM1637 4-Digit seven segment * display module. * This example shows how print an incremented number on the TM1637 display from 0 to 9999. * This is a free software with NO WARRANTY. * https://simple-circuit.com/ /*******************************************************************************/ // Include TM1637 display module library #include <TM1637Display.h> // Define TM1637 Module connection pins #define CLK PB11 // clock pin #define DIO PB10 // data pin // Initialize TM1637 display module library TM1637Display display(CLK, DIO); void setup() { // Set display brightness (7 maximum brightness and 0 minimum) display.setBrightness(7); } uint16_t i = 0; void loop() { // Print variable 'i' on the display (decimal format with leading zeros) display.showNumberDec(i, true); i++; // Increment 'i' if(i > 9999) i = 0; delay(1000); // Wait 1 second } // end of code. |
Interfacing STM32 Blue Pill Board with TM1637 Module Video:
The video below shows a hardware test circuit of the STM32 Blue Pill board with TM1637 display module.
STM32 Blue Pill Board with TM1637 Display Module Proteus Simulation:
Proteus simulation software contains models required to simulate the STM32 Blue Pill board with the TM1637 display module, simulation shown in the following video:
STM32 Blue Pill board with TM1637 module Proteus simulation file download:
Proteus simulation file of this project can be downloaded from the below Google Drive link.
DOWNLOAD
Related Projects:
Interfacing TM1637 4-Digit 7-Segment Display with Arduino
Discover more from Simple Circuit
Subscribe to get the latest posts sent to your email.