QS-WiFi-D01 150W Dimmer

QS-WiFi-D01 150W

Template

    {"NAME":"WiFi-Dimmer","GPIO":[0,148,0,149,0,0,0,0,0,42,37,0,0],"FLAG":0,"BASE":18}

The Wi-Fi Smart Dimmer Module 150W is an in-wall push-button dimmer switch sold as white-label and by various brands e.g., Moes, MoesHouse MS-105, HomCloud, Malmbergs, TOOGOO, Baakey, …

dimmer-1

Art. No. QS-WIFI-D01-TRIAC

  • Trailing-Edge Phase Dimmer, definitely not TRIAC but Power MOSFET driven
  • for dimmable LED light bulbs, dimmable power supplies, incandescent/halogen bulbs,…

Technical Data:

  • Smart Wi-Fi Push-Button Dimmer Module
  • Rated Voltage AC 220-240V / 50Hz
  • Rated Current 0.6A
  • Load max. 150W for LED lamp
  • Size LxWxH 51mm x 47mm x 22mm

The Dimmer has a LM1 ESP8266 module with 1MB Flash onboard, combined with a STM8 MCU on a separate board.

dimmer-flash-lingan

Flashing Guide

OTA

This dimmer is based on Smart Life / Tuya App. Tuya-Convert currently works, but could be patched with future firmware updates.

Serial

  • ⚠️️ Special Attention ⚠️️
  • Do not connect AC power and the serial connection at the same time!
  • The dimmer circuit is directly connected to the AC wires!

Follow all the recommended serial flashing procedures outlined in the Tasmota Flashing Guide.

The case can easily be opened by pressing both sides of the lower half of the case. One method to flash the device is to desolder the ESP/MCU module from the main PCB.

dimmer-flash-1-LM1

It’s also possible to flash the ESP8266 when the PCB is not desoldered, but it is a bit difficult to reach RX and TX. To get the module into Flash Mode, you have to connect RE and GPIO0 to GND (RE to GND disables the STM8 MCU while flashing).

dimmer-flash-3-mcu

dimmer-flash-2

dimmer-flash-4

Configuration

Use the Template from above or set the module as Generic (18) and assign the following components:

GPIO Component
1 Serial Tx (148)
3 Serial Rx (149)
13 Counter1 (42)
14 PWM1 (37)
(or any unused GPIO)

dimmer-module

Wiring Diagram:

dimmer-wiring-diagram

The S switch input is intended for push-button / conventional momentary switch control and detects the mains frequency when the button is pressed. This makes it special and therefore it requires a Tasmota Script for ON/OFF and HOLD (long press) dimming operation.

Tasmota WiFi-Dimmer-Script

>D
sw=0
tmp=0
cnt=0
tmr=0
hold=0
powert=0
slider=0
dim=""
shortprl=2 ;short press lo limit
shortpru=10;short press up limit
dimdir=0   ;dim direction 0/1
dimmlp=2.2 ;dim multiplier 1..2.55
dimstp=2   ;dim step/speed 1..5
dimll=15   ;dim lower limit min. 0
dimul=95   ;dim upper limit max. 100
dimval=70  ;start dim level 0..100

>B
=>print > WiFi-Dimmer-Script-v1.0 <
=>Counter1 0
=>Baudrate 9600
; boot sequence
=#senddim(dimval)
delay(1000)
=#senddim(0)

>F
cnt=pc[1]
if chg[cnt]>0
; sw pressed
then sw=1
else sw=0
; sw not pressed
endif

; 100ms timer
tmr+=1
; short press
if sw==0
and tmr>shortprl
and tmr<shortpru
then
powert^=1
; change light on/off
if powert==1
then
=#senddim(dimval)
else
=#senddim(0)
endif
endif

; long press
if sw>0
then
if hold==0
then
; change dim direction
dimdir^=1
endif
if tmr>shortpru
then
hold=1
if powert>0
; dim when on & hold
then
if dimdir>0
then
; increase dim level
dimval+=dimstp
if dimval>dimul
then
; upper limit
dimval=dimul
endif
=#senddim(dimval)
else
; decrease dim level
dimval-=dimstp
if dimval<dimll
then
; lower limit
dimval=dimll
endif
=#senddim(dimval)
endif
endif
endif
else
tmr=0
hold=0
endif

>E
slider=Dimmer
; slider change
if chg[slider]>0
then
; dim according slider
if slider>0
then
dimval=slider
else
powert=0
endif
endif

if pwr[1]==1
; on/off webui
then
powert=1
=#senddim(dimval)
else
powert=0
=#senddim(0)
endif

; subroutine dim
#senddim(tmp)
dim="FF55"+hn(tmp*dimmlp)+"05DC0A"
=>SerialSend5 %dim%
=>Dimmer %tmp%
#

To use the script, you have to compile Tasmota (v6.6.0.3 or higher) with Scripting enabled. You can use GitPod or TasmoCompiler.

A precompiled binary is also here: Tasmota-v7.0.0.1-w-Scripting-2.6.x-1MB.zip

Once the device is flashed with Tasmota, open Configuration -> Edit script in the web UI and paste the contents of the script in the window. Then set the script enable checkbox and push Restart. To hide “Counter1” in the WebUI you can enter WebSensor1 0 on the Tasmota Console.

How it works:

Whenever the button is pressed there are 50/60 Hz pulses on the S switch input. The frequency detection circuit (below) is connected to GPIO13 of the ESP8266 chip.

pushbutton-input

These pulses must be processed as a switching signal with a counter. The ESP8266 then sends commands accordingly via the hardware serial interface for dimming operation, which are handled by a second microcontroller (STM8S003F3 MCU). The serial communication at 9600 baud is simple, just one command with changing brightness xx values: FF 55 xx 05 DC 0A

What the Script does:

Switching in Tasmota is usually done by High/Low (+3.3V/GND) changes on a GPIO. Here, however, this is achieved by a pulse frequency when connected to a GPIO. These pulses are captured by Counter1 in Tasmota.

  • When the light is OFF and there is a short period of pulses -> then turn the light ON at the previous dimmer level.
  • When the light is ON and there is a short period of pulses -> then turn the light OFF.
  • When there is a longer period of pulses (i.e., HOLD) -> toggle dimming direction and then adjust the brightness level as long as the button is pressed or until the limits are reached.

In the Data Section >D at the beginning of the script, the following initialization variables may be changed:

  • dim step -> 1..5 - sets the dimming increment value
  • dim multiplier -> 1..2.55 - values lower than 2.55 reduce the dimmer range (100..255)
  • dim lower limit -> min 0 - lower limit for the dimmer value for push-button operation (set according to your bulb)
  • dim upper limit -> max 100 - upper limit for the dimmer value for push-button operation (set according to your bulb)
  • start dim level -> 0..100 - initial dimmer level after power-up or restart

Further Information:

Support for Wi-Fi Dimmer? #5737
Switching by Mains Power Frequency #6085

Additional Pictures:

dimmer-2

dimmer-3

dimmer-4

dimmer-5

dimmer-6