logo elektroda
logo elektroda
X
logo elektroda

Avatto DMS16-W1 CBU Dimmer + Puya PY32F002A MCU: OpenBeken Flashing and Autoexec Setup

divadiow  Cool? (+2)
📢 Listen (AI):
Hello. It's me again with another device. This is the Avatto DMS16-W1 1-channel dimmer smart switch with CBU talking to a Puya PY32F002A (TSSOP-20) MCU.

Box on a blue table background with the text Smart Dimmer Module. Packaging of Avatto DMS16-W1 single-channel smart dimmer switch. 1-channel Wi-Fi dimmer module Avatto DMS16-W1 Components of the Avatto DMS16-W1 smart dimmer switch on a blue mat. 1-channel smart switch Avatto DMS16-W1 on a blue background PCB of Avatto DMS16-W1 smart dimmer switch with components. Photo of Avatto DMS16-W1 smart dimmer switch with electronic components. Close-up view of a smart dimmer switch Avatto DMS16-W1 showing the CBU module and electronic components. 1-channel smart dimmer switch Avatto DMS16-W1 with CBU module and electronic components. Avatto DMS16-W1 module with CBU and Puya MCU on a blue background Avatto DMS16-W1 smart dimmer switch board on a blue background Avatto DMS16-W1 smart dimmer switch on a blue background Avatto DMS16-W1 smart dimmer switch with a CBU module on a blue background. Close-up of the Avatto DMS16-W1 smart dimmer switch circuit board.

The Puya MCU is well documented and has had some interesting followings on Elektroda https://www.elektroda.com/rtvforum/topic3946116.html

Code: Text
Log in, to see the code


CBU log out from power-on

Code: Text
Log in, to see the code

After de-soldering the CBU riser the factory firmware was dumped using Easy Flasher, attached. The extracted config was "baud":"115200".

With a multimeter I determine the following traces

The photo shows the Avatto DMS16-W1 smart dimmer switch with a Puya PY32F002A microcontroller in a TSSOP-20 package.

so I have everything I need to capture communications between the Puya and the CBU and potentially to use J-Link to read the flash of the Puya. Sadly I was not able to get a connection from J-Link to the MCU despite my best efforts. Even with NRST-reset pulled low.

SEGGER J-Flash programming interface showing connection error

Moving onto the communication between the CBU and the Puya, TuycaMCU Analyser was a winner for capturing all I could toggle and set within the official Tuya app. Those features being:

App interface for controlling a dimmer module with brightness set to 19%. Power-on status setting screen in mobile app Mobile app interface for setting the dimmer brightness range. Device update screen showing no updates available. App interface for setting the dimmer brightness range with switch type selection.

And with the CBU rise de-soldered we can easily switch between OpenBeken and the factory firmware to recheck default behaviour by removing the Puya from the equation in this setup:
Electronic projects on a desk with various modules and cables connected to devices.

And with two USB-TTL adaptors in the mix we can capture communications in real-time when setting up OBK autoexec.

Screenshot of TuyaMCU Explorer software analyzing communication between modules.

The full extent of the dpIDs being

Code: Text
Log in, to see the code


Code: Text
Log in, to see the code


I did not see dpIDs 13 and 47 in all my fiddling in the Tuya app trying every function, boot communication or tuyaMcu_sendQueryState.

Fast-forward to the current state of the autoexec

Code: Text
Log in, to see the code


which gives us

OpenBK7231N interface with various switch and control options.

The countdown to power-on timer field numerical value will change every ~30s as the CBU receives an update from the MCU on time remaining.

This is as far as I have gone for now. Most functions appear to be working in OpenBeken, though I've not yet tested with mains power and an incandescent bulb. Certainly the communications I'm watching in the MCU analyser mirror what was seen in factory firmware.

There is one thing I don't yet know how to replicate. The brightness range, dpID3, allows you to customise the range from both ends. This is this screen in the Tuya app

App screen for setting the dimmer brightness range.

The yellow indicator can be toggled from the left to right to reduce the minimum, as well as from right to left to reduce maximum. This can be seen in factory with these comms. It also involves dpID 2, I'm not sure how this can be replicated in OBK.

Screenshot showing communication between Wi-Fi module and device, displaying data related to dimmer settings.

One thing I did notice was that although I've set the dimmer range to tuyaMcu_setDimmerRange 200 1000, same as factory, OpenBeken only displays a fixed 0-100 value range in the GUI for that channel when using the slider. It does however communicate the right values to the MCU.

OpenBeken software configuration interface with sliders and control buttons. Log of communication between the WiFi module and device, with yellow indicators highlighting values 200 and 1000.

suggestions for improvement welcome!

About Author
divadiow
divadiow wrote 3157 posts with rating 558 , helped 279 times. Live in city Bristol. Been with us since 2023 year.

Comments

p.kaczmarek2 23 Jul 2024 13:55

Thank you for detailed presentation. This min/max (range) control seems like a very custom component, we don't have such channel type in firmware yet, especially that it would need to handle two dpIDs...... [Read more]

tomik67 30 Jul 2024 01:11

I recently received an identical AVATTO dimmer with the designation DMS 16-Y1 instead of W1. An interesting feature of this version is a timer that counts down the time until the light is switched off. I... [Read more]

groove6j 15 Feb 2025 16:58

I have the same dimmer switch, only it's the 2CH model. So I see mostly things are working fine with the 1CH unit, I will try out flashing my unit and report my findings. Seems like just the right dpIDs... [Read more]

divadiow 15 Feb 2025 19:52

you could sniff out the additional dpID(s) https://www.elektroda.com/rtvforum/topic3970199.html https://www.elektroda.com/rtvforum/topic4038151.html https://github.com/openshwprojects/OpenBK7231T_App?tab=readme-ov-file#features or... [Read more]

groove6j 15 Feb 2025 21:34

I already flashed it. Here is the full 2MB dump of Tuya FW. I had it connected to WiFi if it matters. Anyways it seems that things are very similar, because when using your autoexec.bat: *both physical... [Read more]

przemsi_ele 09 May 2025 12:57

Good job TuyaMCU is a great tool. I found another CBU and restore original tuya firmware for testing. My 2 channel wifi avatto dimmer software version https://obrazki.elektroda.pl/8674940200_1746889358_thumb.jpg... [Read more]

%}