logo elektroda
logo elektroda
X
logo elektroda

[BK7231N ] Teardown and flashing of Tomzn TOMPD-63 WIFI (not to be confounded with TOMPD-63LW)

morgan_flint 
A few days ago I received this device from Aliexpress Link:
Advertisement of TUYA WiFi smart circuit breaker 63A on Aliexpress

The device is similar to others already treated here, for example Tomzn TOML-VA 63A and Earu EAMPDW-TY63, and also TOMPD-63LW mentioned in the title, although the latter is more complete and cuts both line and neutral.

But, despite the external similarities and in functionality, I see from the teardowns that they are different, so I think it's justified to create a new thread. Apart from this, is a good opportunity to put into practice the tutorial I wrote about extracting DpIDs and try to make it work with OBK starting from zero.

So let's start with some photos from the advertisement in Aliexpress, just in case the previous link gets broken:
A section of the user manual for a device from Aliexpress with technical specifications.
Screenshots of the Tuya app showing electricity statistics and other parameters. Two screenshots from a device management app showing various settings. Screenshots of the Tuya app showing add schedule and device information. Multifunction automatic circuit breaker with surge protection. Device buttons and various display screens, including voltage and current measurements. TOMZN TOMP-63WIFI device with visible labels and buttons.

Now the printed manual that came with the device:
User manual for an energy meter with voltage protection function. User manual for WiFi Smart Meter and Energy Protector.

You can already see some differences between the settings in the advertisement and those in the manual. The real thing also included another setting "t" (see next pictures), that can be set to "on" or to a number between 5 and 120.
TOMZN TOMPD-63WIFI device with active display and lit indicators. TOMZN TOMPD-63WIFI device with display and buttons

I haven't been able to deduct what is this setting for.

Now, some photos of the teardown:
View of a device from Aliexpress with visible holes and a latch. Electronic device with LCD screen and five buttons. Side view of an opened electronic device with visible components on PCB boards. Modular electronic device with a PCB and buttons. Close-up of a printed circuit board with various electronic components inside a device. Front panel of a device from Aliexpress with an LCD screen and buttons. WB3S WiFi module on a blue PCB. Close-up of a PCB from an electronic device purchased from AliExpress. Internal circuitry of a device from Aliexpress with visible capacitors and wiring. View of disassembled QY60F-C relay with PCB boards. Internal view of a disassembled electrical device.

Opening the device is very easy: just unfasten the two screws in the holes of the first photo (after pushing apart the lower side lock). It's well constructed; there are two PCBs: the bigger one supports the relay (latching type, no need to keep the coil energized to set it on), the components for the power supply (12V output for the relay and two 3.3V outputs, one with a linear regulator from 12V and the other one with a switch mode one), and the energy metering chip BL0942 (attached English datasheet). The smaller PCB has the LCD screen, push buttons, the Tuya MCU (behind the LCD screen), and the WB3S WiFi module.

Also, here are some screenshots of the Tuya App; you can see there are also differences with the ones from the advertisement:
Tuya app screen displaying energy consumption and device status. Screenshot of an app showing a log of on and off operations with date and time. Screenshot from an app showing alarm record. App screen displaying overcurrent warning Screenshot of over-current alarm settings in a mobile app. Screenshot of a mobile app displaying current electrical data. Energy expense management app screen with prepayment options. Screenshot of an expense management app with an active energy top-up field in kWh. Screenshot of a mobile app with energy expense management settings. Screenshot of a mobile app displaying electricity consumption in kWh and a no balance alarm. Screenshot of leakage alarm in the Tuya mobile app. Leakage alarm threshold settings with a value of 80. Over-current alarm threshold settings menu with on-screen keyboard. Screenshot of Tuya app's under-voltage alarm settings. Smartphone app showing an over-voltage alarm screen with threshold settings and a control switch. Screenshot of an app showing over-voltage alarm settings with threshold options. App screen showing over-voltage alarm settings. Over-current alarm screen with threshold settings and control switch. Screenshot of alarm settings in the app. Screenshot of an app with leakage alarm settings Dialog box in an app asking for confirmation of power zero. Expense management app screen with energy top-up option. Screenshot of expense management app with prepayment settings options. Device update screen on a smartphone.

Now, let's start with the DpID identification process, which should be done before flashing OBK, as we need to access the device from Tuya's developer website. Following the first process in the tutorial, we get this:
{"1":"Total forward energy","6":"Phase A","9":"Fault","11":"Switch prepayment","12":"Clear energy","13":"Balance energy","14":"charge energy","15":"Leakage current","16":"Switch","17":"Alarm set1","18":"Alarm set2","19":"Breaker id","104":"Over Vol Protect Time","105":"Over Vol Recovery Time"}

The same info, written as a list:
"1":"Total forward energy",
"6":"Phase A",
"9":"Fault",
"11":"Switch prepayment",
"12":"Clear energy",
"13":"Balance energy",
"14":"charge energy",
"15":"Leakage current",
"16":"Switch",
"17":"Alarm set1",
"18":"Alarm set2",
"19":"Breaker id",
"104":"Over Vol Protect Time",
"105":"Over Vol Recovery Time"

We can see that there are a total of 13 DpIDs.

Now, jumping to the last method in the tutorial (signaled with [*]) and, after processing the Json as instructed there, we get:
Code: JSON
Log in, to see the code

Where, besides the DpID numbers, we have a more complete description of each of them. With this info in hand we will be able to configure OBK so now we can proceed with flashing.

To flash it with OBK, after unplugging the smaller board from the bigger one, is enough to solder just two wires to the RX and TX pads, as Vcc and Gnd can be connected to the header:
WB3S module on blue PCB with marked TX, RX, GND, and 3.3V pins

I didn't need to cut any traces to flash OBK as the Tuya MCU doesn't seem to interfere with the process (in principle, it should be shut off, as it gets the power from a different pin in the header). To avoid problems, I only connect TX, RX, and GND to the serial to USB adapter, and connect Vcc just after hitting the corresponding key to start flashing in BK7231Flasher.

Once flashed, we can connect our PC or phone to the access point provided by OBK and navigate to 192.168.4.1, where we configure SSID and password for our local WiFi. After rebooting, we have to find in our router the IP assigned to the device and access it with a browser to continue with the configuration. I first configured MQTT and then, by navigating "Launch web application" -> "Filesystem" -> "Create file" I created "autoexec.bat" with the following contents:
Code: Java
Log in, to see the code

Let's explain briefly the contents: The first lines come from similar devices and are there to start the TuyaMCU driver and simulate the connection to the cloud. I commented out the NTP driver, as it doesn't seem to be necessary. The last line also comes from similar devices and, as I understand, is there to force the MCU to send the state periodically.

The lines in between correspond to the previously identified DpIDs, linking them to a channel and setting the channel type accordingly. To make things clearer, I preferred to assign channels with the same number as the DpIDs where possible. I also wrote the following table in Excel to help keep things clear, but it's not really necessary:
Table with DP instructions, IDs, and channel types for a device from Aliexpress.

After saving the autoexec and rebooting the configuration is finished and we can start using the device with OBK:
OpenBK7231T user interface with various settings and energy readings.

In practice, it's not really needed to have so much info, so you can comment out or delete the corresponding lines in the autoexec.bat to eliminate the variables of less interest. Also, some of them don't work as expected (for example, Alarm set 2 doesn't show well, probably because it's too long), but I hope @p.kaczmarek2 will be correcting this in future versions.

Also, after going to "Config" -> "Home Assistant configuration" and hitting "Start Home Assistant Discovery", we can also control the device from Home Assistant:
MQTT interface with BK7231T device information

And that's all for now! It's a long post and I hope I haven't bored you too much, but I think it is better to give as many details as possible for the most novices; the most experienced just can pass over them quickly ;-)

EDIT: corrected label from "Clear Prepayment" to "Clear Energy Counters", as this is what DpID 12 does (thanks, @AngelOf Death)
EDIT: Adding schematic:
Circuit diagram of TOMPD-63 WiFi device

About Author
morgan_flint
morgan_flint wrote 237 posts with rating 52 , helped 4 times. Live in city Sevilla. Been with us since 2018 year.

Comments

Angel0fDeath 28 Dec 2023 10:41

I have exactly the same device. All DpIDs match exactly. About DpID 104 - From the device I'm able to change the values from 0.5s to 30s with step 0.5s. However with tuya-mqtt.js I always receive this... [Read more]

morgan_flint 28 Dec 2023 13:38

Hello and thank you for your answer. Could be it's prepared for some present or future backlight version, as you say. Mine doesn't have any backlight also. From what you say, I understand your manual... [Read more]

Angel0fDeath 28 Dec 2023 13:41

My manual is exactly the same as yours and actually you have this in your manual - 10th bullet on the first page (Light source). Well I just flashed openbeken on my device have some comments on your... [Read more]

morgan_flint 28 Dec 2023 13:46

Ah, OK. I was missing it on the 2nd page, where it should appear between the last two screenshots, so I thought they might have corrected that [Read more]

Angel0fDeath 28 Dec 2023 17:17

So after I spent a few hours with openbeken firmware, I have the following observations: dpID 104: for 1.0s -> 55 AA 03 07 00 08 68 02 00 04 00 00 00 01 80 for 1.5s -> 55 AA 03 07 00 08 68 02 00 04... [Read more]

p.kaczmarek2 28 Dec 2023 19:10

@angel0fdeath , while you are mostly correct, this is not a bug. We just don't have parsing for raw data, well, maybe except for one format. We have a work around for that in place but it requires writing... [Read more]

morgan_flint 28 Dec 2023 20:29

@angel0fdeath, thanks for your analysis; we had already bumped into these issues with the other device, TOMPD-63LW, in its thread , for example in this post and the following ones. Fortunately, we... [Read more]

Angel0fDeath 28 Dec 2023 21:14

I checked it and the idea is not bad, but since this is a setup channel we will not only need correct parsing to mqqt but backwards also. These are setup values and they have ranges. According to me it... [Read more]

p.kaczmarek2 28 Dec 2023 21:17

Hey, your idea 1 is incorrect because we don't know what is the byte size of each variable, it could be 2, or 4, or maybe 1. I'd phrase it differntly, here are my 3 ideas: A. you can (or maybe even... [Read more]

Angel0fDeath 28 Dec 2023 21:33

My idea 1 was just for splitting and nothing more. I know it is not good since everybody should read docs and to know how splitting works. Your suggestion about HEX string is good enough. I know it is... [Read more]

p.kaczmarek2 29 Dec 2023 11:03

I'm working on it, along with a self test, I hope this will suit your basic needs, then we will work on more advanced version: https://obrazki.elektroda.pl/8567259800_1703839632_thumb.jpg Is the... [Read more]

Angel0fDeath 29 Dec 2023 12:26

The path doesn't matter, I hope it is for testing only. About reaction time - yes you are correct, the user will not notice the difference unless there are some fingers in some socket :). However this... [Read more]

p.kaczmarek2 29 Dec 2023 13:04

So what kind of path would you like? This is almost ready for use, so if you have any feedback, let me know. Once we have this feature tested, we will look into other, more specific solutions. [Read more]

Angel0fDeath 29 Dec 2023 16:03

Leave the path as it is Just for information... It looks like the driver has also problems with string parsing: Info:GEN:No change in channel 10 (still set to 0) - ignoring Info:TuyaMCU:TUYAMCU... [Read more]

morgan_flint 29 Dec 2023 19:28

Yes, the same in mine, it clears both counters. I should correct the label (EDIT: done in the first post) , which is like that because there are two different DpIDs in the other device to clear both counters... [Read more]

Angel0fDeath 29 Dec 2023 21:31

About prepayment - yes correct you cannot change anything until prepayment switch is off, and yes you have blackout and alarm 65536 until you enter something where necessary. This is a poor user manual.... [Read more]

Angel0fDeath 30 Dec 2023 13:56

@morganflint Here is the code to process the fault in HA server It is in perl, but I think you can easily write it in any other language. Although I never received 2 faults at same time I left full processing... [Read more]

morgan_flint 30 Dec 2023 14:36

I share your opinion about the device (and this kind of Chinese devices in general): it has some details that can be/should be improved and the manual is very poor. But, on the other hand, the hardware... [Read more]

Angel0fDeath 30 Dec 2023 18:45

Concerning dpID9 - it is not necessary to reserve 17 channels if you want to resolve this in device - 2 channels are enough - 1 channel for num value and 1 channel for text value - 2 changehandlers 1 i... [Read more]