|
|
STM32F103C8 -Blue Pill |
x 1 | |
|
|
TM1637 - 4 Digit 7 Segment Display |
x 1 | |
|
|
DS3231 Realtime clock midule |
x 1 | |
|
|
Pushbutton |
x 4 | |
|
|
Buzzer |
x 1 | |
|
|
Resistor 10k ohm |
x 4 |
|
Soldering Iron Kit |
|
|
arduino IDEArduino
|
DIY STM32 Alarm Clock with 7-Segment Display (Using Arduino IDE)
This time I will present you a classic 7 segment display alarm clock which will represent another one from my series of DIY unusual and ordinary clocks which you can watch on my playlist. In this case, it is characteristic that is used the STM32 microcontroller board known as "Blue Pill".

It is a popular and inexpensive development board based on the STM32F103C8T6 microcontroller from STMicroelectronics. The ARM Cortex-M3 core offers much more processing power and peripherals compared to typical 8-bit microcontrollers like those found in the Arduino.

Its price is also significantly lower than many other development boards with similar capabilities. The code is taken from the RCL-Radio blog where you can also find detailed instructions.
The device is extremely simple to build and the total cost does not exceed 5-6 dollars. It consists of several components:
- STM32 Microcontroller board
- TM1637 4-digit 7-segment display module
- DS3231 Realtime clock midule
- 4 Buttons
- and small Buzzer

First, let me explain how to install the code on the Blue Pill board.
To start programming in the Arduino IDE, you need to add the STM32 board
- File > Settings > Additional links for board manager
Add line: http://dan.drown.org/stm32duino/package_STM32duino_index.json

- Then, Open the board manager
Tools > Boards > Board Manager and type STM32 -> install

- Now we select "GenericSTM32 F103C series", and in the Upload method section, select Serial

- The simplest way to upload the code is to use a small USB to COM adapter and connect it as shown in the diagram.

- First we need to set the jumper on the STM32 to "Program mode" as shown in the image.

- Then, We select the COM port that corresponds to the USB to COM adapter and press upload.

When the upload is complete, we return the jumper to its original position, and remove the USB to COM adapter from the PC.
Now the code has been successfully uploaded and we can mount all the components.
In the style of a classic alarm clock, use a real-time clock module with a built-in battery to store the set time when not connected to power.

Thanks to the four buttons, setting is extremely simple. To adjust the time and alarm time, you need to press and hold the time set or alarm button and use the hours++ and minutes++ buttons to set the desired time. Тo set the seconds accurately, set the minutes 1 minute more; when changing the minutes, press the "Time adjustment" button to reset the seconds.

You can also adjust the display brightness by simply pressing the h+ and m+ buttons. The DS3231 real time clock contains a temperature sensor, and the temperature sensor readings are displayed on the display every 10 seconds.

When the alarm is activated, a sound signal is emitted from the piezo emitter for one minute, and if we press any of the buttons in the meantime, the sound stops.
Finally, a short conclusion. With its simple design, low cost, and easy setup, this STM32 alarm clock is a perfect DIY project for beginners and electronics enthusiasts alike.
#include <Wire.h>
#include <STM32_TM1637.h> // http://rcl-radio.ru/wp-content/uploads/2020/02/STM32_TM1637_V1_3.zip
#include <uRTCLib.h> // https://github.com/Naguissa/uRTCLib.git
#include <EEPROM.h> // http://rcl-radio.ru/wp-content/uploads/2019/12/Arduino_STM32-master.zip
STM32_TM1637 tm ( PB0,PB1 ) ; // CLK, DIO
uRTCLib rtc ( 0x68 ) ;
// PB7 = SDA DS1307 (DS3231)
// PB6 = SCL DS1307 (DS3231)
// PB0 = CLK TM1637
// PB1 = DIO TM1637
// PB5 = time correction
// PB10 = hours++, brightness++
// PB11 = minutes++, brightness--
// PA7 = alarm correction
// PA1 = piezo buzzer
float h;
int i,hh,mm,brig,al_hh,al_mm;
byte w,alarm,w1;
void setup ( ) {
Wire. begin ( ) ;
EEPROM.init(0x801F000, 0x801F800, 0x400); // 1024 byte
brig = EEPROM. read ( 10 ) ;al_hh = EEPROM. read ( 11 ) ;al_mm = EEPROM. read ( 12 ) ;
// rtc.set(30, 37, 23, 2, 17, 12, 19);
// RTCLib::set(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year)
pinMode ( PB5,INPUT ) ; pinMode ( PB10,INPUT ) ; pinMode ( PB11,INPUT ) ; pinMode ( PA7,INPUT ) ;
pinMode ( PA1, PWM ) ;
if ( brig > 4 ) { brig= 4 ; } tm. brig ( brig ) ;
}
void loop ( ) { alarm= 0 ;
//////////////////////////////////// time output
if ( digitalRead ( PB5 ) ==LOW && alarm== 0 && digitalRead ( PA7 ) ==LOW ) {
hh=rtc. hour ( ) ;mm=rtc. minute ( ) ;
rtc. refresh ( ) ; // time poll
h = rtc. hour ( ) * 100 + rtc. minute ( ) ;tm. print_time ( h, 0 ) ;delay ( 500 ) ;
tm. print_time ( h, 1 ) ;delay ( 500 ) ;i++;
//if(i==10){i=0;tm.print_float(rtc.temp()/100,0 ,0b1111000,0,0,0);delay(2000);}// DS3231 temperature output (t 27)
if ( i== 10 ) { i= 0 ;tm. print_float ( rtc. temp ( ) , 0 , 0 , 0 , 0b01100011 , 0b00111001 ) ; delay ( 2000 ) ; } // output temperature DS3231 (27*C)
}
///////////////////////////////////////// time correction - hours and minutes
if ( digitalRead ( PB5 ) ==HIGH && digitalRead ( PB10 ) ==HIGH ) { w= 1 ;hh++; if ( hh > 23 ) { hh= 0 ; } delay ( 300 ) ;tm. print_time ( hh * 100 +mm, 1 ) ; }
if ( digitalRead ( PB5 ) ==HIGH && digitalRead ( PB11 ) ==HIGH ) { w= 1 ;mm++; if ( mm > 59 ) { mm= 0 ; } delay ( 300 ) ;tm. print_time ( hh * 100 + mm, 1 ) ; }
if ( digitalRead ( PB5 ) ==HIGH && digitalRead ( PB10 ) ==LOW && digitalRead ( PB11 ) ==LOW ) { rtc. set ( 0 , mm , hh , - 1 , - 1 , - 1 , - 1 ) ; }
if ( w== 1 ) { w= 0;rtc. set ( 0 , mm , hh , - 1 , - 1 , - 1 , - 1 ) ; }
////////////////////////////////// indicator brightness
if ( digitalRead ( PB10 ) ==HIGH && digitalRead ( PA7 ) ==LOW && digitalRead ( PB5 ) ==LOW ) { brig++; if ( brig > 4 ) { brig= 4 ; } tm. brig ( brig ) ;EEPROM. update ( 10 , brig ) ; }
if ( digitalRead ( PB11 ) ==HIGH && digitalRead ( PA7 ) ==LOW && digitalRead ( PB5 ) ==LOW ) { brig--; if ( brig < 0 ) { brig= 0 ; } tm. brig ( brig ) ;EEPROM. update ( 10 , brig ) ; }
/////////////////////////////////// alarm clock
if ( digitalRead ( PA7 ) ==HIGH && digitalRead ( PB10 ) ==HIGH ) { w1= 0 ;al_hh++; if ( al_hh > 23 ) { al_hh= 0 ; } delay ( 300 ) ;EEPROM. update ( 11 , al_hh ) ; }
if ( digitalRead ( PA7 ) ==HIGH && digitalRead ( PB11 ) ==HIGH ) { w1= 0 ;al_mm++; if ( al_mm > 59 ) { al_mm= 0 ; } delay (300 ) ;EEPROM. update ( 12 , al_mm ) ; }
if ( digitalRead ( PA7 ) ==HIGH ) { tm. print_time ( al_hh * 100 + al_mm, 1 ) ; }
if ( hh * 100 +mm==al_hh * 100 +al_mm && w1== 0 ) { alarm= 1 ; } else { alarm= 0 ; }
if ( alarm== 1 && ( digitalRead ( PA7 ) ==HIGH || digitalRead ( PB5 ) ==HIGH || digitalRead ( PB10 ) ==HIGH || digitalRead ( PB11 ) ==HIGH ) ) { alarm= 0 ;w1= 1 ; }
if ( alarm== 1 ) { pwmWrite ( PA1, 35000 ) ;delay ( 200 ) ; pwmWrite ( PA1, 0 ) ;delay ( 100 ) ; } else { pwmWrite ( PA1, 0 ) ; }
} // loop
DIY STM32 Alarm Clock with 7-Segment Display (Using Arduino IDE)
Raspberry Pi 5 7 Inch Touch Screen IPS 1024x600 HD LCD HDMI-compatible Display for RPI 4B 3B+ OPI 5 AIDA64 PC Secondary Screen(Without Speaker)
BUY NOW- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Mirko Pavleski
-
Arduino 3D Printed self Balancing Cube
Self-balancing devices are electronic devices that use sensors and motors to keep themselves balanc...
-
Building a Vintage Tube-Style Internet Radio with Raspberry Pi & Rotary Encoder
Internet radio (also known as web radio or net radio) is a digital audio service transmitted via th...
-
DIY Smart Code Lock with CrowPanel 1.28 ESP32 Rotary Display
A code lock is a keyless security device—either mechanical or electronic—that restricts access to d...
-
SDR Panadapter for Vintage Tube Radios – Step-by-Step Tutorial
A radio panadapter (or panoramic adapter) is a device or software tool used in amateur radio and ot...
-
Oscilloscope Clock Simulation on a Round ESP32 Display
An oscilloscope clock is a circuit that turns an old analog oscilloscope into a stylish, retro-them...
-
DIY Simple GU32 Tube Stereo Amplifier (2x3W on 12VDC)
Vacuum tube amplifiers are often favored for their smooth harmonic distortion, especially in the low...
-
DIY 3-Display OLED Clock with Arduino and I2C Multiplexer
In this video I want to present you another unusual clock to add to my large collection of such DIY...
-
Build a 5-Day forecast Raspberry Pi Weather Dashboard (Step-by-Step)
Recently in one of my previous videos,I introduced you to the 7 inch Elecrow Pi Terminal and how to...
-
ESP32 Aneroid Barometer using Squareline Studio and LVGL on CrowPanel Round display
A barometer is a scientific instrument used to measure atmospheric pressure. Rising Pressure genera...
-
LINAMP Project – Winamp-Style Audio Front Panel on Raspberry Pi 5
Winamp is one of the most iconic and historically significant digital media players ever created. I...
-
Retro Style radio with CrowPanel 2.1inch round Display (TEA5767)
Some time ago I presented you a clock project with CrowPanel 2.1inch-HMI ESP32 Rotary Display 480*4...
-
Pi-Pico RX - SDR Radio with New Firmware and Features
A few months ago I presented you a wonderful SDR radio project by DawsonJon 101 Things. In short, i...
-
How to make simple Variable HIGH VOLTAGE Power Supply
High Voltage Power Supply is usually understood as a device that is capable of generating a voltage...
-
DIY 5-Day Rainfall Forecast Device - ESP32 E-Paper Project
In several of my previous projects I have presented ways to make weather stations, but this time I ...
-
Build simple Retro Style VFO (Variable frequency oscillator) with Crowoanel 1.28 inch Round Display
Today I received a shipment with a Small round LCD display from Elecrow. The device is packed in tw...
-
Human vs Robot – Rock Paper Scissors with MyCobot 280 M5Stack
Today I received a package containing the few Elephant Robotics products. The shipment is well pack...
-
How to Build a Simple Audio Spectrum Analyzer with Adjustable Settings
An audio spectrum analyzer is an electronic device or software tool that measures and visually disp...
-
How to Make a Digital Clock on a Vintage B&W TV using Arduino
These days I accidentally came across this small retro Black and White TV with a built-in Radio, so ...
-
-
ARPS-2 – Arduino-Compatible Robot Project Shield for Arduino UNO
878 0 2 -
-
A Compact Charging Breakout Board For Waveshare ESP32-C3
1440 3 6 -
AI-driven LoRa & LLM-enabled Kiosk & Food Delivery System
1390 2 0 -
-
-
-
ESP32-C3 BLE Keyboard - Battery Powered with USB-C Charging
1580 0 1 -
-
mammoth-3D SLM Voron Toolhead – Manual Drill & Tap Edition
1205 0 1







