W1219 Thermostat module
The XH-W1219 is a thermostat module with basic I/O (sensor input, keys, double display, relay) and an STM8S003F3P6 controller that can be re-programmed. Besides temperature control possible applications are automation tasks, e.g. timing, closed loop control, or counting. At a price of about $3.00 it's a bit more expensive than the popular W1209 but the circuit is well designed, and it's easy to work with.
- when shopping for the W1219 please be aware that vendors often offer a different board than the one described below, even if the offer shows a picture of the W1219! The only hint those vendors provide is the dimensions "47x40mm", much smaller than the 60x43mm² of the real W1219 board.
- Some W1219 boards purchased in August 2018 came with a Nuvoton chip (see issue #247). The warning here applies.
If you receive a board that doesn't have a STM8S003F3P6 chip or that is otherwise different to the description below, please let us know it by writing an issue.
The board has the following features:
- STM8S003F3P6 (16MHz, 8K Flash, 1K RAM 128-640 bytes EEPROM)
- 3 digit red and 3 digit green 7S-LED display with a 74HC164 segment driver
- 3 keys (set, +, -)
- 1 independent LED
- 1 relay rated 20A/125VAC
- sensor header, for the included 10k NTC temperature sensor
- pads for programming header (refer to serial console)
W1219 Board Support
A HEX file for the XH-W1219, optimized for embedded control tasks, is part of the binary release. The default configuration provides a complete interactive Forth system with sufficient free Flash memory for typical control applications.
With minor modifications, most STM8 eForth programs written for the W1209 should work on the XH-W1219 (e.g.
5 ADC! instead of
6 ADC!, adaptions to dual display). The page Board W1209 provides more examples on programming W12xx thermostat boards in STM8 eForth.
The analog header is designed for the "Wxxxx standard 10k NTC sensor", and it has a 20k pull-up resistor to +5.0V. The input can be used with many sensors that change resistance (LDR, PTC, certain types of pressure sensors etc), and with minor modifications (e.g. removal of the 20k pull-up) it can be used for other purposes.
Note that there is no voltage reference, and that any analog input signal should be formed with the internal 5V power supply as the reference ("ratiometric input").
The following code snippet reads and displays the sensor header's analog input on the upper (red) 7S-LED display, and the timer ticker on the lower (green) 7S-LED display:
: read_Ain ( -- n ) 5 ADC! ADC@ ; : show_Ain ( -- ) read_Ain . TIM 65 / U. CR ; ' show_Ain BG !
Board Digital Outputs
The relay and the blue LED are mapped to bits B0 and B1 of the
OUT! word and
OUT register. The following code shows how to set relay and LED.
1 OUT! \ relay on, LED off 2 OUT! \ relay off, LED on 3 OUT! \ relay on, LED on
Board UI Character IO
The W1219 board provides 3 keys and two 3-digit 7S-LED displays (red and green).
The usage of keys is very similar to that explained in the W1209 UI section. STM8 eForth code that runs on an W1209 can be easily ported to the W1219 (the UI can use one of the two 3 digit 7S-LED displays). Please refer to the Wiki page on STM8 eForth Board Character IO.
The LED display is organized in right-aligned 3-digit groups that each work similar to the display of a pocket calculator.
SPACE switching between the groups works, and
CR moves to the upper group.
The following code demonstrates the group output feature:
: show 11 . 22 . CR ; ' show BG !
show from the command line results in
11 22<new line>. Running it in the background displays
11 in the upper 3-digit group, and
22 on the lower group (both right aligned).
The board support provides half-duplex console access through PD1/SWIM on the ICP header. An example picocom configuration for half-duplex communication is described here.
The following sketch shows how to connect a serial interface adapter using the SWIMCOM method:
XH-W1219 . . e.g. "CH340 USB serial converter" . .----o serial TxD "TTL" . | ICP header . --- . / \ 1N4148 VCC ---------- --- . | PD1/SWIM------<2>-----*----o serial RxD "TTL" . NRST----------<3> . GND-----------<4>----------o serial GND . ................
W1219 Hardware Description
Pin STM Connected to 1 PD4 blue LED cathode (PD4-LED-10k-5V) 2 PD5 AIN5 with pull-up (20k, 5.0V), sensor header pin 2 3 PD6 key "-" 4 NRST (ICP header pin 3) 5 PA1 key "+" 6 PA2 key "set" 7 VSS GND 8 Vcap Cap 9 VDD 10 PA3 relay R10-(R14-GND)-Q1 11 PB5 (not connected) 12 PB4 Dig6g grn.8 470R 13 PC3 Dig5g grn.9 470R 14 PC4 Dig4g grn.12 470R 15 PC5 Dig3r red.8 47R 16 PC6 Dig2r red.9 47R 17 PC7 Dig1r red.12 47R 18 PD1/SWIM (ICP header pin2) 19 PD2 DSA-DSB 74HC164 20 PD3 CP 74HC164
Red and Green 3 Digit 7S-LED Displays
Common Anode type green display marked "YBSP820281 G".
Dig1r red.12 STM8S.17 PC7 47R Dig2r red.9 STM8S.16 PC6 47R Dig3r red.8 STM8S.15 PC5 47R Dig1g grn.12 STM8S.14 PC4 470R Dig2g grn.9 STM8S.13 PC3 470R Dig3g grn.8 STM8S.12 PB4 470R
74HC164 and LED segments
1 DSA STM8.19 PD2 2 DSB-DSA 3 Q0 SegA 4 Q1 SegDP 5 Q2 SegD 6 Q3 SegE 7 GND 8 CP STM8.20 PD3 9 /MR (+VCC) 10 Q4 SegB 11 Q5 SegG 12 Q6 SegC 13 Q7 SegF 14 VCC