An open-source firmware for the STM32 co-processor on the Shelly Dimmer.
See the releases page to download the latest pre-build binary.
git clone --recurse-submodules https://github.com/jamesturton/shelly-dimmer-stm32.git
cd shelly-dimmer-stm32
make -C libopencm3 # (Only needed once)
make -C src
If you have an older git, or got ahead of yourself and skipped the --recurse-submodules
you can fix things by running git submodule update --init
(This is only needed once)
To flash the firmware directly to the STM32 chip using a programmer such as the Black Magic Probe (ST-Link could also be used):
make -C src flash BMP_PORT=/dev/ttyBmpGdb
To convert the binary firmware file to a header file for use in Tasmota firmware use the binary-parser
utility in tthe scripts
directory:
gcc scripts/binary-parser.c -o scripts/binary-parser
chmod +x scripts/binary-parser
scripts/binary-parser src/shelly-dimmer-stm32.bin shelly-dimmer-stm32.h 50 1
Here is a guess of the pinout of the STM32F031K6 chip.
Pin | Name | Function - Shelly Dimmer 1 | Function - Shelly Dimmer 2 | Pin type |
---|---|---|---|---|
1 | VDD | 3V3 | 3V3 | |
2 | OCS_IN | - | - | |
3 | OCS_OUT | - | - | |
4 | NRST | NRST | NRST | |
5 | VDDA | 3V3 | 3V3 | |
6 | PA0 | CF1 HLW8012 | - | Input |
7 | PA1 | CF HLW8012 | - | Input |
8 | PA2 | - | - | Input |
9 | PA3 | - | ?? | Input |
10 | PA4 | - | - | Input |
11 | PA5 | - | Live pin sense | Analog |
12 | PA6 | TEST POINT | - | Input |
13 | PA7 | TEST POINT | Output pin sense | Analog |
14 | PB0 | - | ?? | Input |
15 | PB1 | - | Board HW version? | Input |
16 | PB2 | Zero-crossing detection | ?? | Input ExtInt |
17 | VDD | GND | GND | |
18 | PA8 | ON MOSFET 1 | - | Input |
19 | PA9 | USART_TX | USART_TX | AltFun |
20 | PA10 | USART_RX | USART_RX | AltFun |
21 | PA11 | ON MOSFET 2 | ON MOSFET 1 | Output |
22 | PA12 | - | ON MOSFET 2 | Output |
23 | PA13 | SWDIO | SWDIO | AltFun |
24 | PA14 | SWCLK | SWCLK | AltFun |
25 | PA15 | - | - | Input |
26 | PB3 | - | - | Input |
27 | PB4 | - | - | Input |
28 | PB5 | - | - | Input |
29 | PB6 | - | - | Input |
30 | PB7 | - | Pin7 A42 BAKN | Input ExtInt Live - Output |
31 | BOOT0 | BOOT0 | BOOT0 | |
32 | PB8 | SEL HLW8012 | - | Input |