logo elektroda
logo elektroda
X
logo elektroda

OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown

kraavok 5835 22
ADVERTISEMENT
  • #1 20251805
    kraavok
    Level 3  
    I just received this smart meter and it seems it no longer uses the ESP8266.

    I found the OpenBK7231T (WB3S) project, and successfully flashed the device, but I'm not really sure how to configure the device from here.

    I was originally planning on using this guide for Tasmota: https://github.com/krikk/Hiking-DDS238-2-WIFI-Din-Rail-Energy-Meter-flashing-Tasmota

    I've attached the original BIN dump.

    ---

    Here's some photos from the teardown and flash.
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
  • ADVERTISEMENT
  • Helpful post
    #2 20253504
    p.kaczmarek2
    Moderator Smart Home
    Hello, it looks like a TuyaMCU device and the guide from Github confirms it. Have you tried to configure the TuyaMCU? There are some examples for that, for example:
    https://www.elektroda.com/rtvforum/topic3895301.html
    https://www.elektroda.com/rtvforum/topic3898502.html#20253434
    They are for different kinds of devices, but in general the TuyaMCU protocol is the same in all cases.

    Do you know the dpIDs of, for example, relay function?

    We can try to configure it together, for a start, let's get relay working.
    Helpful post? Buy me a coffee.
  • #3 20255966
    kraavok
    Level 3  
    Thanks, I will have a read through those and learn a bit more about TuyaMCU.

    I think there are some of the dpIds in the Tasmota guide, as it mentions:

    Quote:
    Tasmota Config for TuyaMCU to paste into Console:

    Backlog TuyaMCU 33,20; TuyaMCU 32,18; TuyaMCU 31,19; TuyaMCU 37,101;

    dpId=9 seems to be a timer to toggle the device relay, set it to any value and it starts counting down, by the time it reaches 0 the relay toggles state. As far as I know, this can't be used in Tasmota


    Where the command `TuyaMCU {fnId},{dpId}` is as outlined here.

    So based on what you mentioned, the relay seems to be dpId 9.

    The others (above) seem to relate to:
    dpId 20 = voltage power monitor (V)
    dpId 18 = current power monitor (A)
    dpId 19 = active power monitor (W)

    dpId 101 = not sure as the fnId of 37 is not listed here
  • ADVERTISEMENT
  • #4 20256284
    p.kaczmarek2
    Moderator Smart Home
    So let's try to get this running together. I don't have much time and I don't know this device, so we will do it step by step, carefully.
    kraavok wrote:

    So based on what you mentioned, the relay seems to be dpId 9.

    Not really, it seems that it's a timer to turn off relay. Timer turns off relay after some time. It's not like a direct access to relay. But let's try that.

    Quote:

    Backlog TuyaMCU 33,20; TuyaMCU 32,18; TuyaMCU 31,19; TuyaMCU 37,101;
    dpId=9 seem to be a timer to toggle the device relay, set it to any value and it starts counting down, by the time it reaches 0 the relay toggles state. As far as I know, this can't be used in Tasmota

    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
    Ok 31, 32 and 33 are POWER, but what is 37 in Tasmota?
    Docs does not specify that.
    https://tasmota.github.io/docs/TuyaMCU/#tuyasend-command

    Is 37 for direct access to relay (NOT a timer?)

    This is an autoexec.bat that you shall drag on file system on LFS.
    NOTE: you can just also type those 3 commands in console, but then they will NOT be remembered corrrectly.
    
    // start MCU driver
    startDriver TuyaMCU
    // let's say that channel 1 is dpid101  - relay on/off
    setChannelType 1 toggle
    // map dpid101  to channel1, var type 1 (boolean)
    linkTuyaMCUOutputToChannel 101 1 1
    
    
    // channel 2, dpId 9, dataType 4-DP_TYPE_ENUM = set timer
    setChannelType 2 TextField
    linkTuyaMCUOutputToChannel 9 4 2
    
    

    linkTuyaMCUOutputToChannel syntax:
    linkTuyaMCUOutputToChannel	[dpId][varType][channelID]	Used to map between TuyaMCU dpIDs and our internal channels. Mapping works both ways. DpIDs are per-device, you can get them by sniffing UART communication. Vartypes can also be sniffed from Tuya. VarTypes can be following: 0-raw, 1-bool, 2-value, 3-string, 4-enum, 5-bitmap


    Unless I'm much mistaken, the above code might allow you to toggle the relay through OpenBeken. Can you check it and tell me if the relay toggles? If it does not, we will try to diagnose. If it does, we will try to go further.

    Things to check:
    1. Do you get a button (toggle) on GUI with the code above?
    2. Do you get a textfield with a "Send" button on GUI with the code above?
    3. If you press a button, does the relay toggle instantly?
    4. If you send a "1" in textfield (enter 1 and press button to send), does relay turn off after 1 second?
    5. if you send a "5" in textfield (enter 5 and press button to send), does relay turn off after 5 seconds?

    Please try the code above and report results here. Also provide screenshots to show any potential issues.
    Helpful post? Buy me a coffee.
  • #5 20256809
    kraavok
    Level 3  
    Unfortunately no luck. I even tried dpId 1 and 4 (some others mentioned in the Tasmota official docs for switches and relays).
    (see below for update)

    1 & 2: Both fields displayed and were clickable
    3: No response on the device on click
    4 & 5: No response on the device after changing the values

    Also, I had to use `setChannel ...` instead of `setChannelType ...` as it seems to have changed in your docs and `setChannelType` gave a "command not found" error.

    EDIT: OK, I see that `setChannelType` works in the webapp console but not in the standard config console (outside the webapp). However, it does not change the outcome.

    I checked the logs and found the following dpId outputs:

    1:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 01 02 00 04 00 00 00 04 1C 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 1, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 4
    
    6:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 00 0C 00 00 00 10 01 C3 00 00 77 09 1C AD 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes
    
    9:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 05 09 05 00 01 00 1D 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 12 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 9, dataType 5-DP_TYPE_BITMAP and 1 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 1 byte: 
    
    16:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 05 10 01 00 01 01 21 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 12 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 16, dataType 1-DP_TYPE_BOOL and 1 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 1 byte: 
    
    17:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 22 11 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 64 00 01 0E 00 00 AA 00 00 00 00 00 0A 00 00 00 00 00 00 81 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 41 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 17, dataType 0-DP_TYPE_RAW and 30 data bytes
    
    18:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 15 12 00 00 11 00 05 00 64 00 05 00 1E 00 3C 00 00 00 00 00 00 00 09 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 28 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 18, dataType 0-DP_TYPE_RAW and 17 data bytes
    
    101:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 65 02 00 04 00 00 00 04 80 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 101, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 4
    
    102:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 66 02 00 04 00 00 00 00 7D 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 102, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 0
    
    103:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 67 02 00 04 00 00 00 0C 8A 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 103, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 12
    
    105:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 69 02 00 04 00 00 13 88 1B 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 105, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 5000
    
    109:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 6D 02 00 04 00 00 00 03 87 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 109, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 3
    
    110:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 6E 02 00 04 00 00 00 10 95 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 110, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 16
    
    111:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 6F 02 00 04 00 00 01 BE 45 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 111, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 446


    Added after 10 [minutes]:

    The display still works (separate chip??) but the values seem to match to my current load as:

    103 = Active Power (W)
    105 = Frequency (mHz)
    110 = Reactive Power (VAr)
    111 = Power Factor (PF)

    (will update as I go)

    Added after 35 [minutes]:

    OK dpId 16 is the toggle.

    I'm finding out more as we go:

    Here's the config I'm using so far to discover values:
    startDriver TuyaMCU
    
    setChannelType 1 ReadOnly
    linkTuyaMCUOutputToChannel 1 2 1
    
    setChannelType 2 ReadOnly
    linkTuyaMCUOutputToChannel 6 0 2
    
    setChannelType 3 ReadOnly
    linkTuyaMCUOutputToChannel 9 5 3
    
    setChannelType 4 Toggle
    linkTuyaMCUOutputToChannel 16 1 4
    setChannelType 5 ReadOnly
    linkTuyaMCUOutputToChannel 17 0 5
    setChannelType 6 ReadOnly
    linkTuyaMCUOutputToChannel 18 0 6
    
    setChannelType 10 ReadOnly
    linkTuyaMCUOutputToChannel 101 2 10
    setChannelType 11 ReadOnly
    linkTuyaMCUOutputToChannel 102 2 11
    setChannelType 12 ReadOnly
    linkTuyaMCUOutputToChannel 103 2 12
    setChannelType 13 ReadOnly
    linkTuyaMCUOutputToChannel 105 2 13
    setChannelType 14 ReadOnly
    linkTuyaMCUOutputToChannel 109 2 14
    setChannelType 15 ReadOnly
    linkTuyaMCUOutputToChannel 110 2 15
    setChannelType 16 ReadOnly
    linkTuyaMCUOutputToChannel 111 2 16


    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown

    Not sure yet how to display RAW values properly, as I think they hold the current and voltage.
  • #6 20256907
    p.kaczmarek2
    Moderator Smart Home
    Very good job, I see you figured most of the things well.

    RAW values... how would YOU like to display them?

    I can add any channel type for you, I can add a "voltage" channel that will format value as volts, I can add a "current" channel, etc, it's up to you.

    It seems that I will also have to find a way to enable bl_shared.c power metering statistics and features for TuyaMCU power metering devices.

    Also.... dpID 111, power factor, values like that need to have a multiplier, right?
    Helpful post? Buy me a coffee.
  • #7 20256920
    kraavok
    Level 3  
    p.kaczmarek2 wrote:
    RAW values... how would YOU like to display them?

    I can add any channel type for you, I can add a "voltage" channel that will format value as volts, I can add a "current" channel, etc, it's up to you.


    Ah, ok, didn't realize they needed a new channel format. Makes sense now!

    I guess the following channels would be useful, to match my Tasmota plugs:

    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown

    p.kaczmarek2 wrote:
    Also.... dpID 111, power factor, values like that need to have a multiplier, right?


    It shows on the LCD display of the device as a decimal of the value listed. For example 542 shows as 0.542 so I suspect the value is simply clamped between 0 and 1000 and acts as the multiplier.

    The Apparent Power could then be calculated by multiplying the Active Power (W) by 1/ Power Factor (PF as decimal).

    Also, is there a way to ask TuyaMCU to update more frequently or is it fixed in their IC?
  • #8 20257021
    p.kaczmarek2
    Moderator Smart Home
    How often are you getting TuyaMCU updates? I will look into it.

    Can you specify again all found dpIDs with their raw values and meaning? I know to know the multipliers.
    Something like:
    - dpID 111 - power factor - raw value 542 means 0.542 (multiplier 0.001)
    - dpID 103 -voltage - raw value 221 means 221 (multiplier 1)
    - etc

    I want to add channel types for you, but I need to know multipliers.
    Helpful post? Buy me a coffee.
  • #9 20257052
    kraavok
    Level 3  
    p.kaczmarek2 wrote:
    How often are you getting TuyaMCU updates? I will look into it.


    Right now, on the LCD display it's every second. In OpenBeken it arrives every minute I think.

    p.kaczmarek2 wrote:
    Can you specify again all found dpIDs with their raw values and meaning? I know to know the multipliers.
    Something like:
    - dpID 111 - power factor - raw value 542 means 0.542 (multiplier 0.001)
    - dpID 103 - voltage - raw value 221 means 221 (multiplier 1)
    - etc

    I want to add channel types for you, but I need to know multipliers.


    Here's the current status of what I've figured out:

    1 - Energy Total (kWh) [UNCONFIRMED] - 0.001 multiplier
    6 - Voltage - 0.1 multiplier
    9 - [UNKNOWN]
    16 - Relay switch
    17 - [UNKNOWN - possibly current (more likely)] - if current, probably 0.01 multiplier
    18 - [UNKNOWN - possibly current] - if current, probably 0.01 multiplier
    101 - Energy Today (kWh) [UNCONFIRMED] - 0.001 multiplier
    102 - Energy Yesterday (kWh) [UNCONFIRMED] - 0.001 multiplier
    103 - Active Power (W) - NO multiplier
    105 - Frequency (Hz) - 0.01 multiplier
    109 - Energy Export [back to grid] (kWh) - 0.001 multiplier
    110 - Reactive Power (VAr) - NO multiplier
    111 - Power Factor (PF) - 0.001 multiplier
  • #10 20281655
    bizquik
    Level 6  
    Hi,

    Do you have an update here?
    I have a DDS238-1, but it seems to work the same.

    For example, how can I read the voltage?

    Thanks.
  • ADVERTISEMENT
  • #11 20281707
    p.kaczmarek2
    Moderator Smart Home
    I will try to look into it today. I have ported OpenBeken to Windows and I will just add an UART simulator to 'fake' the TuyaMCU packets and write the support for their interpretations.

    If anyone wants to help, please provide me more TuyaMCU packets dump, preferably from the RX pins of WiFi (the packets that WiFi module receives) in a hex form.

    I have tools for analyzing them:
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown

    How to make TuyaMCU packets dump
    1. solder RX of UART to USB connector to the given UART lane of your choice (for example, to RX of the Beken to see what Beken receives)
    2. Open RealTerm
    3. Go to Capture, set "Capture as Hex", disable other options (no commas, timestamps), enter file name, press "Start capture" and wait - it will capture to file (and will stop displaying output on RealTerm screen, just will be forwarding it to file"
    4. Get a file like:
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown

    but this is just a general guide, I will try to use the data already provided here by @kraavok

    Dodano po 22 [minuty]:

    UPDATE Ok ok I am looking into it right now, I running OBK on Windows and created a packet simulator to run data that @kraavok provided:
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
    https://github.com/openshwprojects/OpenBK7231...mmit/984575f19fc1541641b59674072b84449cab2a0f
    I hope that the provided data will be enough

    Dodano po 51 [minuty]:

    UPDATE
    I only added variable types so far. Haven't done ROUNDING yet.
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
    I have a question about id 6. This is not an enum nor an integer. It is 15 bytes of data.
    Can anyone provide me more detailed samples of TuyaMCU packets, for example, with a certain known loads or voltages, so I can investigate more?
    I mean this data point:
    Quote:

    6:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 00 0C 00 00 00 10 01 C3 00 00 77 09 1C AD
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes

    The DP_TYPE_RAW with 15 bytes of data is not even handled in my code yet. What kind of data is that?
    Helpful post? Buy me a coffee.
  • #12 20281883
    bizquik
    Level 6  
    I can't get raw packets right now, because it's already mounted in the fuse box.
    I will try to do that when I take it out.

    This is what I got from the logs:
    Quote:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 00 BF 00 00 01 3C 01 F8 00 06 4F 09 30 B4
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 00 BD 00 00 01 3C 01 F4 00 06 45 09 36 AA
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 00 C1 00 00 01 3C 01 FD 00 06 53 09 2E BD
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 00 BD 00 00 01 3B 01 F6 00 06 46 09 2E A4
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 00 BD 00 00 01 3B 01 F5 00 06 46 09 2D A2
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes


    Assuming it's voltage, the value should be around 235.
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
  • #13 20282000
    p.kaczmarek2
    Moderator Smart Home
    If your TuyaMCU is sending something, this is still very helpful. No need to solder wires. Let me plug this into my analysis tool.
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
    
    55 AA	03	07		00 13	06 00 00 0F 000000BF0000013C01F800064F0930 		180	
    HEADER	VER=03	State		LEN	fnId=6 RAW V=00 00 00 BF 00 00 01 3C 01 F8 00 06 4F 09 30	CHK	
    
    55 AA	03	07		00 13	06 00 00 0F 000000BD0000013C01F40006450936 		170	
    HEADER	VER=03	State		LEN	fnId=6 RAW V=00 00 00 BD 00 00 01 3C 01 F4 00 06 45 09 36	CHK	
    
    55 AA	03	07		00 13	06 00 00 0F 000000C10000013C01FD000653092E 		189	
    HEADER	VER=03	State		LEN	fnId=6 RAW V=00 00 00 C1 00 00 01 3C 01 FD 00 06 53 09 2E	CHK	
    
    55 AA	03	07		00 13	06 00 00 0F 000000BD0000013B01F6000646092E 		164	
    HEADER	VER=03	State		LEN	fnId=6 RAW V=00 00 00 BD 00 00 01 3B 01 F6 00 06 46 09 2E	CHK	
    
    55 AA	03	07		00 13	06 00 00 0F 000000BD0000013B01F5000646092D 		162	
    HEADER	VER=03	State		LEN	fnId=6 RAW V=00 00 00 BD 00 00 01 3B 01 F5 00 06 46 09 2D	CHK	
    

    but from a quick glance, I have not yet determined where the voltage is stored. I analyzed the data above in the hex editor and I can't see your voltage value yet, neither as a 32-bit float, nor an integer (most likely multiplied by 100 or so)

    I would need more samples. It would be extremely helpful to get, for example, a sample from voltage like 234V and then from 225V or even 180V if you have an autotransformer, but I assume that most people don't own one. Hmmm. I will think about it more later today.

    Also, maybe voltage is in different ID and not 6?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #14 20282086
    bizquik
    Level 6  
    Just as kraavok, I get 13 dpIds.
    8 VALUE (1, 101, 102, 103, 105, 109, 110, 111), 1 BOOL (16), 3 RAW (6, 17, 18) and 1 BITMAP (9).
    All the VALUE type dpIds are accounted for (almost, I can't confirm 102 is energy yesterday, as I only installed it today and it says 0, and 109 I think it's "reactive energy kvarh", not export)
    16 is the relay.
    6, 9, 17, 18 I don't know.

    I have an inverter with slightly adjustable output voltage. (maybe 210-240V, not sure)
    I will try to use that and compare the voltages with the data from all these 4 dpIds.
  • #15 20282231
    p.kaczmarek2
    Moderator Smart Home
    Please do. And make a longer log file for me for analysis, maybe I will come up with something.
    First let's decode those dpIDs, then we will handle the MQTT publishes.

    Good thing also would be a test with 60W bulb and then a test with 10W bulb and two separate log files for comparison.

    Dodano po 2 [godziny] 19 [minuty]:

    Huh, now @btsimonh made me realize I haven't checked the big-endian values.... thanks @btsimonh !
    000000BD0000013B01F5000646 092D
    This stands for 2349 which is most likely the voltage...
    So that's it! I will now consider how to handle it in code.


    Voltage parsing done, now I need two packet dumps:
    - one with 60W bulb load
    - one with 10W bulb load
    Helpful post? Buy me a coffee.
  • #16 20283360
    bizquik
    Level 6  
    I didn't managed to take package dumps with controlled loads, but I think I found where the current is stored.

    I did this with more samples, but take this example:
    Quote:

    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 00 D3 00 00 01 26 02 3A 00 06 13 09 4C D5
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes

    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 67 02 00 04 00 00 00 D3 51
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 103, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 211

    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 6F 02 00 04 00 00 02 38 C0
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 111, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 568

    103 is power (so 211W) and 111 is power factor (0.568)
    Voltage is 094C so 238V.
    If my math is right, the current should be ~1.56A.
    The display confirmed this value.

    From dpId 6 if we take 2 or 3 bytes, before the voltage, we get 000613 (so 1555)
    Seems right to me.
    Quote:
    55 AA 03 07 00 13 06 00 00 0F 00 00 00 D3 00 00 01 26 02 3A 00 06 13 09 4C D5


    dpIds 117 and 118 didn't change in all my samples.

    Other samples:
    Quote:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 08 D1 00 00 01 8B 03 D7 00 25 F1 09 3C CB
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes

    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 67 02 00 04 00 00 08 D2 58
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 103, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 2258

    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 6F 02 00 04 00 00 03 D7 60
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 111, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 983


    Quote:

    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 01 C7 00 00 01 75 02 98 00 0B 40 09 4C A9
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes


    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 67 02 00 04 00 00 01 C4 43
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 103, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 452


    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 6F 02 00 04 00 00 02 99 21
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 111, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 665


    Quote:
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 13 06 00 00 0F 00 00 01 60 00 00 01 21 02 C6 00 08 2A 09 43 FA
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 26 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 6, dataType 0-DP_TYPE_RAW and 15 data bytes

    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 67 02 00 04 00 00 01 5B DA
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 103, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 347

    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 6F 02 00 04 00 00 02 C4 4C
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=3]: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 111, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 708
  • #17 20283616
    p.kaczmarek2
    Moderator Smart Home
    This is the current config I use in the simulator (based on your packets):
    
    startDriver TuyaMCU
    
    setChannelType 10 Current_div1000
    setChannelType 11 Voltage_div10
    setChannelType 12 Power
    setChannelType 13 PowerFactor_div1000
    
    // special syntax for 15 bytes packets containing multiple variables
    // (no channel specified, it will set channels by their type automatically)
    // This sets Current_div1000 and Voltage_div10
    linkTuyaMCUOutputToChannel 6 RAW_DDS238
    
    // this links tuyamcu var 103 to channel 12 which is Power
    linkTuyaMCUOutputToChannel 103 Enum 12
    
    // this links tuyamcu var 111 to channel 13 which is PowerFactor_div1000
    linkTuyaMCUOutputToChannel 111 Enum 13
    

    This is how it looks like on panel:
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
    What next do we need? There is much more variables, but I am not sure about their meanings.

    For example, are we sure about that "today consumption total" and "yesterday"?
    Helpful post? Buy me a coffee.
  • #18 20284266
    bizquik
    Level 6  
    That's great! Thanks!

    Not sure about today and yesterday, I think my meter doesn't have a clock.
    1 seems to be total consumption, but it's 0.01 scale (not 0.001)
    Maybe it's different than DDS238-2.
  • #19 20284360
    p.kaczmarek2
    Moderator Smart Home
    So I am adding channel type: "EnergyTotal_kWh_div100". Now, what else do we need to read from that TuyaMCU?

    And regarding next steps, what kind of publish format would you like? JSON one?

    We already have our own power system that is able to calculate today's total and yesterdays (or should I rather say, last 24h?) and "all time" power consumption, I think I will add an option to connect TuyaMCU to that.
    Helpful post? Buy me a coffee.
  • #20 20285793
    bizquik
    Level 6  
    I don't think I need anything else right now.
    MQTT with plain text is fine for me.
    I already integrated it in Home Assistant and it calculates hourly/daily/monthly/cost/etc.
    Automatic discovery in HA would be nice, but I only have one BK7231T device, so it wasn't a problem for me.

    It works great.
    Thanks a lot!
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown

    PS: The device froze one time with the previous firmware and config. Not sure why. It responded to ping, but the http requests failed (timeout) and it wasn't publishing anything to HA.
    Right now it seems fine. I hope it stays that way. :)
    OpenBK7231T (WB3S) Config for Hiking DDS238-2 Smart Meter: Tasmota Guide & Teardown
  • #21 20286363
    kraavok
    Level 3  
    Hey, sorry I have been away on holiday the past week but great work to you both! And nice find on the current reading @bizquik!

    I'll flash the update ASAP and check on the changes. I have been using stock since my last update so that it was usable in the meantime.

    @bizquik, could you post your HA config for the mqtt energy readings by any chance? Would save me (and hopefully others) some time setting that up. Thanks!
  • #22 20286417
    p.kaczmarek2
    Moderator Smart Home
    If there are any stability issues, please report them on Github. @valeklubomir did a great job updating LWIP for more stable version and most of issues are resolved, but we never know if it's really 100% stable now, maybe there is still something bad at play.

    @kraavok @bizquik one important thing to know would be that we already have a power metering system with statistics in OpenBeken and with HA discovery and with JSON publish, but.... but it's not yet connected to TuyaMCU. It is used only for BL0937, BL0942, CSE, etc...

    So soon I might add an option to connect that system to TuyaMCU.

    Then you will be able to make a choice - whether to receive raw readings directly from channel publishes, or whether to use our OBK built-in system...
    Helpful post? Buy me a coffee.
  • Helpful post
    #23 20286707
    bizquik
    Level 6  
    kraavok wrote:
    @bizquik, could you post your HA config for the mqtt energy readings by any chance? Would save me (and hopefully others) some time setting that up. Thanks!

    Code: YAML
    Log in, to see the code

Topic summary

The discussion revolves around configuring the OpenBK7231T (WB3S) firmware for the Hiking DDS238-2 smart meter after it was flashed successfully. Users explore the TuyaMCU protocol to control various functionalities of the smart meter, including relay operations and power monitoring. They identify specific dpIDs for different measurements such as voltage, current, and power factor, and discuss the necessary commands to set up these parameters in Tasmota. The conversation includes troubleshooting steps, sharing of logs, and the development of a Home Assistant integration for monitoring energy consumption. Users also share their findings on the multipliers for raw values and the frequency of updates from the device.
Summary generated by the language model.
ADVERTISEMENT