Skip to content

Board W1209WK

Thomas edited this page Mar 13, 2018 · 24 revisions

W1209WK Thermostat module

The W1209WK is a thermostat module for front panel mounting. Its performance is inferior to other thermostats (e.g. W1209) due to a questionable electronics design, and it's also more difficult to re-purpose. At a retail price of about $3.00 it's maybe suitable for certain use cases that require a "voltmeter style" mounting option.

The board has the following features:

  • STM8S003F3P6, 5.0V
  • 2x3 digit 7S-LED display (red and blue)
  • 2 keys on front panel
  • piezo beeper
  • relay (rated 5-15A/250VAC) with red indicator LED
  • header for "10k NTC temperature sensor"

W1209WK Board Support

The board has shortcomings, e.g. reduced accuracy caused by a questionable sensor input design, circuit-bending grade LED driving (the GPIO protection limits the LED current!), lack of accessible ports for communication, or a PCB track spacing unacceptable for anything >= 42V. However, the "board support code" is complete, and if you'd like to give it a try branch contains working code.

Please write a feature request if you'd like to use the module. If you need a well made board with 2x3 digits consider using the W1219.

W1209WK Hardware Description

The electronics assembly of the thermostat consists of two stacked PCBs:

W1209WK

After removing the electronics assembly from the case, the following signals can be accessed through pads on the front PCB:

  W1209WK 1st PCB, view on front side
  .------------------------------------------------------.
  |* VCC                    RED                        J3|    
I |* GND             ---    ---    ---   * Sens     +UB *|
C |* SWIM   ---     |   |  |   |  |   |  * VCC      GND *| 
P |* NRST  |SET|     ---    ---    ---   J4      RelBas *| 
  |         ---     |   |  |   |  |   |                  |
|  * Sens            ---    ---    ---                     |
|  * VCC             ---    ---    ---    * Beep           |
  |J1               |   |  |   |  |   |                J2|
  |         ---      ---    ---    ---    LED       GND *|
  |        |F/C|    |   |  |   |  |   |             +UB *|
  |         ---      ---    ---    ---    * VCC   RelLS *|
  |                        BLUE                    Beep *|
  '------------------------------------------------------'

The signals on headers J1 and J2 are also accessible on the rear PBB.

7S-LED Displays

Most GPIOs (14 out of 16) are used for driving segments (anode) or columns (cathode). The GPIOs PA1 (beeper) and PA2 (relay) are the only GPIOs which don't double as LEDs drivers!

There are no current limiting resistors: at the supply voltage of 5.0V, LED current is only limited by the short circuit protection of the STM8S silicon! Text book knowledge suggests that electromigration may lead to long term damage. I'd like to rate this as circuit-bending, not electronics engineering. A zero-cost alternative would have been 3.3V operation, but adding at least one resistor per digit wouldn't have been too much to ask.

Analog Header

The analog input for NTC sensors has a very unusual design, to say the least:

             .---||--GND
             |
5.0V-<-NTC->-*--10k--GND
             |
             .---1k--*--PD3 (STM8S003F3P.20)
                     |
                     .--(SegE x PA3,PB4,PB5,PD4,PD5,PD6)

PD3 also controls segment E of the 7S-LED display. There is no ADC sampling-buffer capacitor at PD3 (the capacitor with 1k resistor doesn't make it better). Most likely the capacitance of the LEDs is enough to prevent the worst.

Sampling must be synchronous to the 7S-LED MPX cycle (measure while all the LEDs are off). Note that the original firmware used 7:1 multiplex with 1ms active time per LED column which leaves 1ms for reading analog values. However. even if the ADC conversion is triggered 1ms after disabling the LEDs, a variable offset (up to several digits) depending on the LED display pattern. This is due to the voltage offset caused by the missing LED current limitation, which leads to an offset from the GPIO protection. The capacitor at the sensor input retains that error.

Board Digital Outputs

The relay and the red LED are controlled by GPIO PA2 with the usual NPN transistor for the relay.

Note: none of the W1209WK vendors makes any claims about the maximum voltage of the relay N/O contact. Although the relay is rated 5-15A/250VAC, voltage higher than Extra-Low-Voltage should never be connected to the module! The width of the copper trace to the N/O relay contacts is about 4mm, which implies a current limit of no more than 8A!

Board Keys

The W1209WK has two keys, "SET" and "C/F". The keys switch GND to PD1/SWIM ("C/F") and PC7 ("SET") with 5k1 resistors. Since both GPIOs are also used for driving the 7S-LED display, reading the keys can only be done while no LED digit is active (lack of current limiting resistors).

Note that the key "C/F" won't work if an STLINK programming adapter is conNected. Refer to serial console for more information.

Beeper

The beeper on the 2nd PCB is connected to PA1 through a capacitor (located in the 1st PCB). PA1 emits a 2000Hz square wave (duty cycle 1:1) to activate the beeper (which appears to be of the type "piezo passive"). The experimental firmware uses the LED-MXP interrupt for generating a 1KHz signal.

Serial Console

Getting a serial console through PD1/SWIM (the only GPIO accessible on header pads) is tricky:

  • PD1 also controls the 7S-LED display segment DP
  • the front panel key "C/F" connects PD1 to GND via 5k1. When a serial interface is connected, the "C/F" key either doesn't work, or it jams the serial interface when pressed.

Board-CN2596 already showed that reliable operation of the serial interface requires at least two 7S-LED segments to be lit while the serial interface is active (otherwise simulated serial port interrupts may be triggered by column MPX). However, the W1209WK has a 5.0V core supply, instead of the 3.1V of the CN2596! For reliable operation the column GPIOs have to be in state high or input which means that the display has to be dark while the serial interface is used.

Another option might be using the only GPIOs not used by the 7S-LED display, which are PA1 (beeper), and PA2 (relay):

  • without separating the PCBs (which is easiest with two strong soldering irons and four hands) the beeper signal is only accessible on the beeper facing side of a capacitor. Coupling a serial interface through a capacitor with NRZ encoding only works if the DC level can be restored (tricky), or if phase coding is used (requires interface hardware).
  • soldering a wire to the PA2 facing side of the 5k1 resistors of LED and relay driver is possible. However, for communicating it's necessary to activate the relay (unless RxD and TxD signals are both inverted with additional hardware).

The conclusion is that there are no easy options for serial communication.

STM8S003F3P6 Signals

Pin	STM	Connected to
1	PD4	Dig1b
2	PD5	Dig2b
3	PD6	DIG3b
4	NRST	(ICP header pin 3)
5	PA1	beeper (C)
6	PA2	relay, red LED, 
7	VSS	(ICP pin2)
8	Vcap	Cap
9	VDD	(ICP pin1)
10	PA3	Dig1r
11	PB5	Dig2r
12	PB4	Dig3r
13	PC3	A
14	PC4     F
15	PC5     B
16	PC6     G
17	PC7     C, key "SET"
18 PD1/SWIM    DP, key "C/F", ICP pin3
19	PD2     D
20	PD3	E, Ain (sensor header)

Red and Blue 3 Digit 7S-LED Displays

Common Cathode type red and blue displays are controlled by the STM8S003F3P6 without any current limiting resistors!

Dig1r red.12 STM8S.10 PA3
Dig2r red.9  STM8S.11 PB5
Dig3r red.8  STM8S.12 PB4
Dig1b blu.12 STM8S.3 PD6
Dig2b blu.9  STM8S.2 PD5
Dig3b blu.8  STM8S.1 PD4
You can’t perform that action at this time.