Skip to content
STC DIY Clock redux (STC15F204EA, STC15W408AS)
Branch: master
Clone or download
Latest commit c4c2c8d Jun 21, 2019

STC DIY Clock Kit firmware

Firmware replacement for STC15F mcu-based DIY Clock Kit (available from banggood [see below for link], aliexpress, et al.) Uses sdcc to build and stcgal to flash firmware on to STC15F204EA (and STC15W408AS) series microcontroller.

Image of Banggood SKU972289

link to Banggood product page for SKU 972289


Basic functionality is working:

  • time display/set (12/24 hour modes)
  • date display/set (with reversible MM/YY, YY/MM display)
  • day of week
  • seconds display/reset
  • display auto-dim
  • temperature display in C or F (with user-defined offset adjustment)
  • alarm with snooze

Experimental support

  • time sync to GPS receiver outputting serial NMEA data
  • platformio support
    • see platformio build section below for platform installation instructions
    • tested on linux/vscode w/ stc15w408as based clock kit

note this project in development and a work-in-progress Pull requests are welcome.


  • chime ?
  • time sync to WWVB radio receiver module (for STC15W408AS)



P1 header UART adapter
P3.1 RXD
P3.0 TXD
5V 5V


  • linux or mac (windows untested, but should work)
  • sdcc installed and in the path (recommend sdcc >= 3.5.0)
  • stcgal (or optionally stc-isp). Note you can either do "git clone --recursive ..." when you check this repo out, or do "git submodule update --init --recursive" in order to fetch stcgal.


choose platformio or traditional make build

platformio support


  • assumes you have platformio installed
  • choose which mcu you are building for by uncommenting one env_default in platformio.ini
  • adjust upload_port as needed in platformio.ini

traditional make

make clean
make flash

make options

  • override default serial port: STCGALPORT=/dev/ttyUSB0 make flash

  • add other options: STCGALOPTS="-l 9600 -b 9600" make flash

  • flashing STC15W408AS: STCGALPROT="stc15" make flash

pre-compiled binaries

If you like, you can try pre-compiled binaries here:

use STC-ISP flash tool

Instead of stcgal, you could alternatively use the official stc-isp tool, e.g stc-isp-15xx-v6.85I.exe, to flash. A windows app, but also works fine for me under mac and linux with wine.

~~ note due to optimizations that make use of "eeprom" section for holding lookup tables, if you are using 4k flash model mcu AND if using stc-isp tool, you must flash main.hex (as code file) and eeprom.hex (as eeprom file). (Ignore stc-isp warning about exceeding space when loading code file.) To generate eeprom.hex, run:

make eeprom


clock assumptions

For STC15F204EA, some of the code assumes 11.0592 MHz internal RC system clock (set by stc-isp or stcgal). For example, delay routines might need to be adjusted if this is different. (Most timing has been moved to hardware timers.)


This code is provided as-is, with NO guarantees or liabilities. As the original firmware loaded on an STC MCU cannot be downloaded or backed up, it cannot be restored. If you are not comfortable with experimenting, I suggest obtaining another blank STC MCU and using this to test, so that you can move back to original firmware, if desired.

references (mostly in Chinese)

stc15f204ea english datasheet:

stc15w408as english datasheet:

sdcc user guide:

some examples with NRF24L01+ board:

Maxim DS1302 datasheet:

VE3LNY's adaptation of this hardware to AVR (he has some interesting AVR projects there):

original firmware operation flow state diagram

Kit instructions w/ schematic: scan | PDF


Join the chat at

You can’t perform that action at this time.