logo elektroda
logo elektroda
X
logo elektroda

Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942

p.kaczmarek2 91422 372
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #31 20302394
    p.kaczmarek2
    Moderator Smart Home
    Update:
    You no longer need to type these lines into your startup commands:
    
    VREF 15987.125000
    PREF -683.023987
    IREF 272302.687500
    

    The calibration is remembered automatically .
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #32 20302753
    omelchuk890
    Level 11  
    @p.kaczmarek2
    Do I understand correctly - the "autoexec.bat" file is not needed now, the system somehow automatically saves the coefficients after entering the VoltageSet and the rest commands?
    Otherwise I get this picture.
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    I have sorted out the energystats team.
    Failed to start ntp for "NTP driver is not started, daily stats disbled"
    Found the information here https://github.com/openshwprojects/OpenBK7231T_App/search?p=2&q=CMD_RegisterCommand
    But with an argument in the form of a url does not work for me
    Debug:CMD:loglevel set 6
    Debug:API:POST to api/cmnd
    Debug:CMD:cmd [ntp_setServer belgim.by]
    Error:CMD:cmd ntp_setServer NOT found (args belgim.by)
  • ADVERTISEMENT
  • #33 20308150
    p.kaczmarek2
    Moderator Smart Home
    omelchuk890 wrote:
    @p.kaczmarek2
    Do I understand correctly - the "autoexec.bat" file is not needed now, the system somehow automatically saves the coefficients after entering the VoltageSet and the rest commands?

    Yes. It is autosaved.

    omelchuk890 wrote:

    Otherwise I get this picture.
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942


    How do you have both BL0937 and BL0942 drivers running? Something is very wrong. There is no such device. Please revise your autoexec.bat and determine which chip is really your plug using.


    omelchuk890 wrote:

    Failed to start ntp for "NTP driver is not started, daily stats disbled"
    Found the information here https://github.com/openshwprojects/OpenBK7231T_App/search?p=2&q=CMD_RegisterCommand
    But with an argument in the form of a url does not work for me
    Debug:CMD:loglevel set 6
    Debug:API:POST to api/cmnd
    Debug:CMD:cmd [ntp_setServer belgim.by]
    Error:CMD:cmd ntp_setServer NOT found (args belgim.by)

    I think you first need to do "startDriver NTP". Driver-related commands are only added after driver is started.

    I can see that you have no NTP running.
    Helpful post? Buy me a coffee.
  • #34 20312652
    piratee
    Level 13  
    Hello
    I will also write some of my experiences after switching from LSPA9 Tuya software to BK7231N.
    After the trial period on IoT Tuya expired, the integration with HA disappeared.
    By Local Tuya I was not satisfied with the integration.
    Now to the seat.
    I had already dismantled the socket once, so after soldering the wires to the RS232, the programming went quite quickly.
    Visually, the configuration is similar to the Tasmota.
    First step - switching on the measurement:
    issuing the "StartDriver Bl0942" command in "Change startup command text" - after restarting, the measurements will start automatically.
    I also configured the Control Pins
    I calibrated the socket by issuing commands in "Execute Custom Command":
    - "VoltageSet 228"
    - "PowerSet 100"
    - "CurrentSet 0.42"
    Please note that I calibrated with a 100W bulb (everyone enters their data)

    I will also mention that for BL0937 the initial procedure is different - for BL0937 you need to select the BL0937 pins (CF, CF1 and SEL) and restart the device and then calibrate.

    If someone enters it wrong, you can always clear the configuration in "Execute Custom Command" enter the "clearConfig" command.

    After setting up the MQTT setup in HA, I have the measurements:
    - electricity
    - voltages
    - power
    - total record of kWh consumption.

    Then, after being informed that the software supports NTP, I decided to enable the service.
    Issuing the "StartDriver NTP" command in "Change startup command text" - after restart, time synchronization will start automatically.
    You can enter your server "ntp_setServer 217.147.223.78"
    Information about synchronization as well as other events can be viewed in the logs after going to "Launch Web Application" after issuing the command

    Info:NTP:Server=217.147.223.78, Time offset=0
    Info:NTP:Seconds since Jan 1 1900 = 3878791803
    Info:NTP:Unix time : 1669803003
    Info:NTP:Local Time : 2022/11/30 10:10:03

    (the correct window is shown on Microsoft Edge and Chrome (Firefox has a small window - some scaling bug)

    After adding the NTP server in autostart, the command "StartDriver Bl0942" was overwritten - no measurements.

    Therefore, it is important to enter the command "backlog startDriver NTP; startDriver BL0942" in "Change startup command text"

    After restart we have energy measurement and NTP synchronization running at the same time.

    A big surprise for me was that after starting the time synchronization, new registers appeared in the MQTT logs:
    - energy register of today's consumption.
    - energy register of yesterday's consumption
    - date of resetting energy registers

    Integration with HA went smoothly after entering the appropriate configuration in configruratio.yaml, I only noticed that it refreshes the current value for quite a long time.
    In HA, you only need to scale Wh to kWh.

    Many thanks to the authors of the software, especially to p.kaczmarek2 for providing all the information while learning about the software.

    Regards
  • ADVERTISEMENT
  • #35 20324481
    omelchuk890
    Level 11  
    @p.kaczmarek2
    I updated the firmware on one of the sockets and the data began to display incorrectly.
    I entered a VoltageSet with the necessary argument - ok.
    Current and power parameters at home are more difficult to adjust than voltage.
    Is there any command to get the current VREF, PREF, IREF coefficients from the module before updating?
    It also seemed to me that autosave does not always work. Maybe it's a glitch in my head, but now I write the coefficients to the autoexec file - there are no problems.
    VREF 0.135294
    PREF 1.488095
    IREF 0.011979
    startDriver NTP
    ntp_timeZoneOfs 3
    // Socket_05_1F801360
  • #36 20324648
    p.kaczmarek2
    Moderator Smart Home
    @omelchuk890 can you specify from which version did you update?
    I am currently not aware about any data loss between updates. We didn't change our config struct. This is a serious issue. Can you provide details?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #37 20324772
    omelchuk890
    Level 11  
    @p.kaczmarek2
    Build on Nov 29 2022 23:12:23 version 1.15.116
    I commented out some of the commands in autoexec.
    //VREF 0.135294
    //PREF 1.488095
    //IREF 0.011979
    Restart
    Voltage =210.027969
    We give the command Voltage Set 228.3
    Voltage =228.300018
    Restart
    Voltage =210.027969
  • #38 20324845
    p.kaczmarek2
    Moderator Smart Home
    There was a rare case where settings were not saved, but it was fixed about 11 days ago. Maybe you have build without this fix. You should check latest build.
    Helpful post? Buy me a coffee.
  • #39 20325101
    omelchuk890
    Level 11  
    @p.kaczmarek2
    on versions 147 and 153, I have the same thing.

    P.S.
    Sorry, the jamb was found - the coefficients were registered in Startup command:
  • #40 20325144
    p.kaczmarek2
    Moderator Smart Home
    Oh, so you had them in two places at once? No wonder they were overwritten!

    No problem, it's good it's solved.

    I am also testing a power metering socket, but a virtual one - in soon-to-be-released OpenBK simulator:
    Spoiler:

    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    Helpful post? Buy me a coffee.
  • #41 20325147
    sq3evp
    Level 37  
    Interesting thread - can other similar sockets also be converted?
    Is an identical processor required or can it only be from the same family?
  • #42 20325161
    p.kaczmarek2
    Moderator Smart Home
    Hello @sq3evp . My soft currently supports BK7231T, BK7231N, W600/W601, W800/W801, BL602 and XR809, and I have almost ready support for the RTL platform.
    In turn, sockets for ESP are known - they are supported by Tasmota, so I do not deal with the ESP platform.
    Here's my repository:
    https://github.com/openshwprojects/OpenBK7231T_App
    And I also have Windows support - an IoT device simulator, used to streamline project development, where you can also create scripts and test automations - for learning:
    Spoiler:

    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942


    My software is still being developed, but if there is a socket with a processor for which SDK and toolset are available, I can support them sooner or later. The goal of the project is to support more platforms and give users freedom from the cloud and freedom in their configuration.
    Helpful post? Buy me a coffee.
  • #43 20325423
    omelchuk890
    Level 11  
    Quote:
    I am also testing a power metering socket, but a virtual one - in soon-to-be-released OpenBK simulator:

    It looks great, almost like a Proteus.
    I'm looking forward to it!!!
  • #44 20350404
    madart
    Level 26  
    I have this problem with strange negative peaks on the charts. This is happening to me on 2 different reworked outlets. Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    It appears irregularly and more or less at a similar rate once or twice a day. I don't know where to look for the error, can someone point me?
  • #45 20350445
    p.kaczmarek2
    Moderator Smart Home
    Hello @madart, I haven't seen it, maybe @valeklubomir knows something more about it, he has quite a lot of OBK sockets active all the time, but from what I remember it was only a top-down power limit - PowerMax command.

    But generally I can fix it for you in 5 minutes, just clamp negative results to zero. Would such a solution suit you?

    Just write, does it occur with BL0942 or BL0937?
    Helpful post? Buy me a coffee.
  • #46 20350592
    madart
    Level 26  
    Both are BL0942. Is there any command to reset such negative results? Because in general, I was surprised by the fact that these sockets can count the current in both directions, normally it does not occur because it is impossible to replace the plug with the socket, but when it is disarmed, soldering on the contrary is already possible
  • #47 20350604
    p.kaczmarek2
    Moderator Smart Home
    At the moment there is no, but I can add, for example, a flag.

    Can you still write to me, do you only have a negative power measurement or current too? Basically, I'm not sure now if these are "measurements" at all, or it's not like there's some sort of glitch. Well, but in BL0942 we check the packet checksum and reject packets with interference, so strange.
    Helpful post? Buy me a coffee.
  • #48 20350610
    piratee
    Level 13  
    Hello,
    I did not look at the measurements earlier and I see that I have peaks at five current and power. (as a consequence, renergy will also be miscalculated) BL0942.
    Regards
  • #49 20350634
    madart
    Level 26  
    For me, only the power has such a negative peak, the current and voltage do not show it
  • #50 20350640
    p.kaczmarek2
    Moderator Smart Home
    @madart @piratee do the peaks occur only when there is zero current/power consumption, or quite randomly?

    I'm asking because I want to know if I should:
    a) convert its value to 0
    b) skip this measurement (and wait for the next measurement in 1-2 seconds)

    EDIT: I tend to skip it
    Helpful post? Buy me a coffee.
  • #51 20350648
    madart
    Level 26  
    On one it happens at zero consumption, but the other is still loaded with 20W
    Imo, it's probably better to ignore such an erroneous measurement and give the next one
  • #52 20350650
    piratee
    Level 13  
    This is how it looks in HA, I would probably skip it


    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
  • #53 20350667
    p.kaczmarek2
    Moderator Smart Home
    The build is already uploaded, from now on it skips such measurements, but you can turn off the appropriate flag.

    All you have to do is make an OTA and you can test if it's better (nothing else needs to be configured)
    Helpful post? Buy me a coffee.
  • #54 20350670
    madart
    Level 26  
    Thanks, I'll check it out, happy holidays :)
  • #55 20350677
    piratee
    Level 13  
    Merry Christmas for everyone.
    I'll check later.
  • #56 20364254
    spin55
    Level 17  
    Hello. The text is translated so I apologize if it is not clear enough.
    Kaczmarek2, the work you do is impressive, as well as the attention and patience you show every day.
    I would like to help more, but my means and knowledge are very limited, so here goes my modest contribution to the growth of this community.

    Aubess 16A smart socket with CB2S wifi board with BK7231N chip and BL0937.
    It looks like a clone of LSPA9 but the configuration changes something:

    P6 ---> BL0937CF1
    P7 ---> BL0937CF
    P8 ---> LED_n
    P23 --> Btn
    P24 --> BL0937SEL
    P26 --> Rel


    regards
  • #57 20364553
    p.kaczmarek2
    Moderator Smart Home
    Thank you, I'm here to help.

    If you have any other IoT devices, BK7231 or ESP8266 or anything, you can always submit a teardown - information where device was bought, photos from outside and inside, pins configuration, etc., flashing photos (programming by UART), etc.
    Helpful post? Buy me a coffee.
  • #58 20377368
    Znida2017
    Level 2  
    spin55 wrote:
    Hello. The text is translated so I apologize if it is not clear enough.
    Kaczmarek2, the work you do is impressive, as well as the attention and patience you show every day.
    I would like to help more, but my means and knowledge are very limited, so here goes my modest contribution to the growth of this community.

    Aubess 16A smart socket with CB2S wifi board with BK7231N chip and BL0937.
    It looks like a clone of LSPA9 but the configuration changes something:

    P6 ---> BL0937CF1
    P7 ---> BL0937CF
    P8 ---> LED_n
    P23 --> Btn
    P24 --> BL0937SEL
    P26 --> Rel

    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942

    regards



    For my Aubess plug, it is a little different:

    P6 ---> BL0937CF1
    P7 ---> BL0937CF
    P8 ---> LED_n
    P11 --> Btn - I guess there are different versions inside, outside looks the same as yours.
    P24 --> BL0937SEL
    P26 --> Rel
  • #59 20377390
    p.kaczmarek2
    Moderator Smart Home
    Hmm are all the packaging marking etc the same? I can submit your alternate pinout to templates database but users will have to guess which one is which.
    Helpful post? Buy me a coffee.

Topic summary

The discussion centers on the Tuya LSPA9 smart socket teardown and the process of flashing OpenBeken firmware on devices based on the CB2S (BK7231N) module with BL0942 or BL0937 energy metering chips. Detailed guides cover hardware disassembly, UART programming, pin configurations, and calibration commands for accurate voltage, current, and power measurements. Users report variations in internal components, such as different pinouts and energy metering chips (BL0942 vs. BL0937), requiring tailored firmware settings. The OpenBeken firmware supports features like automatic calibration data saving, MQTT integration with Home Assistant discovery, and configurable precision for telemetry data. Issues discussed include OTA update behavior, negative power measurement spikes, device stability problems with CB2S, and DNS resolution in MQTT. Solutions involve firmware updates, command-line calibration, and community-shared device templates. The project supports multiple chip platforms (BK7231T/N, W600/W601, W800/W801, BL602, XR809) and aims to provide cloud-free, customizable IoT device firmware. Users also share experiences with alternative devices like Aubess and Arlec smart plugs, including pin mappings and flashing tips. The community actively contributes to device template databases and firmware improvements.
Summary generated by the language model.
ADVERTISEMENT