|
|
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)
- 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...
-
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 ...
-
Build a $10 Function Generator with Frequency Meter for Your Lab
A function generator is a piece of electronic test equipment used to generate various types of elec...
-
From Unboxing to Coding - Radar Clock on Elecrow’s 2.1 HMI Display
Today I received a shipment with a large round LCD display from Elecrow. The device is packed in two...
-
Making a Retro Analog NTP Clock with Unihiker K10 - Arduino IDE Tutorial
Some time ago I presented you a way to use standard Arduino libraries on the Unihiker k10 developme...
-
Build a Cheap & Easy HF Preselector - Antenna Tuner
HF antenna preselector is an electronic device connected between an HF radio antenna, and a radio r...
-
DIY Static Charge Monitor - Electrostatic Field Detector (Arduino & TL071)
A Static Charge Monitor also known as a Static Field Meter or Electrostatic Voltmeter is a device u...
-
XHDATA D-219 Radio Short Review with complete disassembly
Some time ago I received an offer from XHDATA to be one of the first test users of their new radio m...
-
How to make Simplest ever Oscilloscope Clock
An oscilloscope clock is a unique and creative way to display the time using an oscilloscope, which...
-
DIY Digital Barograph with BME280 and ESP32 - 24 Hour Pressure Trends
A barograph is a self-recording barometer that continuously measures and records atmospheric pressu...
-
Build a Raspberry Pi Pico SDR Radio with Waterfall Display
Software-defined radio (SDR) is a radio communication system where components that have traditional...
-
DIY Magnet Polarity Detector - How to Identify Poles with a Hall Sensor from a PC Fan
Recently, while working on a project, I needed to determine the polarity of several permanent magne...
-
Light Meter Project - Making Dfrobot Unihiker K10 Work with Standard Arduino Libraries
The other day I received a shipment with a UNIHIKER K10 development board from DFRobot, which I rec...
-
DIY Simple Arduino Whack-a-Mole Game
A "Whack-a-Mole" game is a classic arcade-style game where moles pop up randomly from holes, and th...
-
Wireless Power Transmission, Long-Distance and High-Efficiency with Class-E Tesla Coil
Wireless energy transfer also known as wireless power transmission is a method of getting useful el...
-
-
AEL-2011 Power Supply Module
321 0 1 -
AEL-2011 50W Power Amplifier
295 0 1 -
-
-
Custom Mechanical Keyboard
564 0 0 -
Tester for Touch Screen Digitizer without using microcontroller
229 2 2 -
Audio reactive glow LED wristband/bracelet with NFC / RFID-Tags
235 0 1 -
-
-







