logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 91416 372
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #181 20654255
    krzakx
    Level 11  
    p.kaczmarek2 wrote:
    We have a "Button" pin role and a "TglChannelOnTgl" role, which is a "button"/"switch" which toggles target channel when pressed.


    Hey! This is great news for me too, as I prefer to use momentary switches. Also what I found out is that after setting to "button" pin role, I have additional field to set up.
    My question would be:
    * Is it possible with your OpenBK software to distinguish single click action and double click action and then send different action to MQTT broker?
    This would greatly improve my wall switches! Looking forward to your feedback.
  • ADVERTISEMENT
  • #182 20654364
    p.kaczmarek2
    Moderator Smart Home
    Hello @krzakx , please consult our docs, the autoexec examples section:
    https://github.com/openshwprojects/OpenBK7231T_App/tree/main/docs/autoexecExamples.md
    Specifically, the Configuration for 4x socket + 1x USB power strip with a single button (double click, triple, etc) section shows how to create button events.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #183 20657152
    piratee
    Level 13  
    Hello
    How to change the time of data publication after MQTT to HA?
  • #184 20657342
    p.kaczmarek2
    Moderator Smart Home
    Hello, I seem to be looking for the mqtt_broadcastInterval command to be placed in autoexec.bat or in the short startup command.

    Documentation:
    https://github.com/openshwprojects/OpenBK7231T_App/tree/main/docs
    Helpful post? Buy me a coffee.
  • #185 20668848
    minusync
    Level 9  
    I have a similar socket as described here https://www.elektroda.com/rtvforum/topic3887748-150.html#20585167
    and I flashed it successfully but my current and power values are jumping around all over the place. Watts goes from 15 to 3255 and back. also sometimes it switches off itself even when HA shows it on.
    I did not set it up exactly as described in the first post here but instead used the flasher option to write OBK config, aso webapp now has calibration utility so everything should be OK .
    What do I miss here?
  • ADVERTISEMENT
  • #186 20669825
    p.kaczmarek2
    Moderator Smart Home
    Hello @minusync , can you post here your Tuya config?
    https://www.youtube.com/watch?v=WunlqIMAdgw
    Also, please post your OBK JSON template from the Web App.

    Futhermore, did you calibrate your device correctly with some load like 60W bulb?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #187 20671569
    mminkov
    Level 5  
    can I add temperature/humidity sensor (dht11 or other) to miniSwitch, and add something to tuya config and make workable system? When flash with openBeken, I made this, but interesting for Tuya...
  • #188 20671575
    p.kaczmarek2
    Moderator Smart Home
    DHT11 sensor can be easily added to OpenBeken device, but keep in mind that some Tuya devices are not isolated from mains so you need to take extra caution when working with them.

    See the DHT11 in OpenBeken video (it's using W600 platform, but it's the same on BK7231):




    I don't think the same is possible for vanilla Tuya device. You need flash OpenBeken first.
    Helpful post? Buy me a coffee.
  • #189 20674136
    minusync
    Level 9  
    p.kaczmarek2 wrote:
    Hello @minusync , can you post here your Tuya config?
    https://www.youtube.com/watch?v=WunlqIMAdgwAlso, please post your OBK JSON template from the Web App.


    I have already converted it to OB so the only thing I can give is a backup bin file.
    I think the only difference in my pin setup is a button in pin10, if I remember correctly in your setup button was 11
    Also, I did try to calibrate with 15w bulb but even with completely wrong calibration, it should simply give me consistently wrong readings not jumping all around.
    Code: JSON
    Log in, to see the code
  • #190 20674611
    mminkov
    Level 5  
    p.kaczmarek2 wrote:
    DHT11 sensor can be easily added to OpenBeken device, but keep in mind that some Tuya devices are not isolated from mains so you need to take extra caution when working with them.

    I made it under OB, but interesting how to change config under Tuya for Power Monitordevice and adding temperature sensor on factory maded device without PREflashing
  • #191 20693491
    miegapele
    Level 15  
    Bought some cheap sockets from AliExpress Elivco store (in March 2023), with the intention to cut from the cloud.
    These 2 are 16A/20A LSPA9.
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    They have firmware V1.1.8, and so BK7231N chip. Flashed with cloudcutter. Config is same for both:
    
    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Elivco EU Smart Socket 16A/20A",
      "model": "LSPA9",
      "chip": "BK7231N",
      "board": "TODO",
      "flags": "1024",
      "keywords": [
        "TODO",
        "TODO",
        "TODO"
      ],
      "pins": {
        "6": "BL0937CF1;1",
        "7": "BL0937CF;1",
        "8": "LED_n;1",
        "10": "Btn;1",
        "23": "WifiLED_n;1",
        "24": "BL0937SEL;1",
        "26": "Rel;1"
      },
      "command": "backlog PowerSave 1;startDriver BL0937;",
      "image": "https://obrazki.elektroda.pl/8741558300_1692035118.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/viewtopic.php?p=20693491#20693491"
    }
    

    Just noticed, not all the above sockets as two leds, these have two, red for wifi, blue for ON, when both are on looks nice magenta color.
  • #192 20697482
    miegapele
    Level 15  
    Here is teardown of historical LSPA9 socket, which I bought in 2021 with hope to flash with tuya-convert. But was not able too.
    It has no markings on the case:
    Front panel view of a smart electrical plug with a power button.
    Pcb is mostly the same, it actually has LSPA9 marking, but lacks MOV compared to the modern ones.
    Close-up of the PCB of an electrical device with the marking LSPA9BPV1.1DL.
    Show is run by BK7231T this time:
    Close-up of a PCB module with WB2S marking and Beken BK7231T chip.
    It contains the usual BP2525 power supply chip, which runs on 5V for relay
    Close-up of electronic components on a PCB, including a chip labeled BP2525.
    So it needs 3.3V regulator for the chip
    Close-up of a component labeled AMS1117 3.3 H230NK on a circuit board.
    And faintly marked BL0937 for power monitoring
    Close-up of a circuit board with a BL0937 chip on a green background.
    Relay is 5V
    Close-up of a PCB with a relay marked QLRELAY JZC-11FH.

    I wonder why they did not use 3 volt relay and 3.3V BP2525, would save one component.

    It has tuya V1.0.3 firmware, I did not try to flash it.
  • #193 20715208
    minusync
    Level 9  
    I have a combination of CB2S with BL0937
    With BL0937 so far all the measurements are really unstable. U mention in first post that u r working with BL0937. Have u had any luck?
    Thanks
  • #194 20715289
    p.kaczmarek2
    Moderator Smart Home
    Someone has recently reported that the solution is to turn off PowerSave for devices with BL0937.

    Other devices are not affected by this issue.
    Helpful post? Buy me a coffee.
  • #195 20716591
    minusync
    Level 9  
    p.kaczmarek2 wrote:
    Someone has recently reported that the solution is to turn off PowerSave for devices with BL0937.


    I am not sure how to do that. Anyway, I did try the startup commands PowerSave 1 and PowerSave 0. No change in power reading results. They are still fluctuating around thousands of watts and hundreds of volts
  • #196 20716659
    p.kaczmarek2
    Moderator Smart Home
    Remove PowerSave 1 from startup.

    If calibration is not helping, maybe you've got swapped CF and CF1 pins?
    Helpful post? Buy me a coffee.
  • #197 20716762
    minusync
    Level 9  
    p.kaczmarek2 wrote:
    If calibration is not helping, maybe you've got swapped CF and CF1 pins?


    I used the flasher option to read/write OBK config but now I swapped it anyway and it looks stable. I need to monitor it longer but looks promising. No idea why flasher got it wrong.
    The only problem now is that it turns itself off every few minutes, maybe something else is wrong , needs more testing
  • #198 20716830
    p.kaczmarek2
    Moderator Smart Home
    What is the restart reason?

    Well, we may be running in circles, but... I've had a "device turning off" issue several times and it was caused by a low quality power supply, which then required PowerSave 1.... so it's up to you to choose the best config.

    Also please check if it restarts with itself with blank config.

    So, you are saying that our config decoder has swapped CF and CF1? I would like to look at that. Can you provide your config partition in binary form and the correct config in one post so I can compare?
    Helpful post? Buy me a coffee.
  • #199 20727132
    omelchuk890
    Level 11  
    @p.kaczmarek2
    Thank you so much for the project!
    There are several devices with an energy meter, BL0942.
    On some of them, embedded, an external shunt is used. The voltage drop on the shunt is calculated, checked, approx.
    But there is a small problem - the parameters are displayed a little incorrectly, there is an error.
    At the moment, there is a possibility of correction using the commands PowerSet, Voltage Set, Current Set. However, for correct data entry, it is necessary to have stable parameters, which in my case cannot be done.
    Is it possible to read correction coefficients from the system, evaluate, recalculate and record others?
    Example: the readings of the reference device and the module differ by 6%. We read the coefficient, change it by 6%, write it down, check it. If necessary, we repeat.

    P.S. I will try to explain the need to change the coefficient.
    There is a point of commercial electricity metering. Visual data acquisition only.
    The power displayed on the module and the actual one for the same period of time, one week, are different, and using PowerSet it will not be possible to adjust exactly, but by changing a known constant, having previously read it!, and knowing the percentage of error, everything becomes much easier.
    There is a house in the village, alternately, by agreement, fishermen stop there and use electric heaters - everyone owes only for what he used while there. Data transmission is organized, the question is their correctness.
  • #200 20737833
    rishabmehta7
    Level 6  
    Hi @p.kaczmarek2

    I have the device listed in Post #20
    I have also added "startDriver BL0942" startup script

    The Voltage and Current values seem to work, but the Power always seems to be 0. Can you help?
    User interface monitoring voltage and current values, showing power error of 0.
  • #201 20738534
    omelchuk890
    Level 11  
    @rishabmehta7
    As indicated in the first post, you need to calibrate according to a stable load and a meter that you trust.
    The author of the topic used a 60 watt lamp.
    The image shows calibration instructions for the OpenBeken device with voltage charts and a photo of a power meter.
  • #202 20738536
    rishabmehta7
    Level 6  
    Hi the problem is the value just being zero.
  • #203 20738569
    p.kaczmarek2
    Moderator Smart Home
    Is it 0 even after calibration?
    Helpful post? Buy me a coffee.
  • #204 20745222
    skupu
    Level 12  
    >>19984436
    What is the value of this large resistor?
  • #205 20745571
    p.kaczmarek2
    Moderator Smart Home
    I will have two LSPA9 clones on Tuesday, I will program them for the reader, I will try to check them. Remind me if anything happens.
    Helpful post? Buy me a coffee.
  • #206 20753548
    rakalexei
    Level 8  
    @p.kaczmarek2 Good day, I faced the issue with switching between wifi ssid.

    User interface for managing Wi-Fi connections with two SSID fields and buttons.

    I did some tests. It can successfully connect to each wifi ssid, but only when it's a first ssid. So basically it never switched to a second ssid if the first one failed.

    P.S. I'm on version 1.17.262
  • #207 20754561
    p.kaczmarek2
    Moderator Smart Home
    To the best of my knowledge this feature is currently a stub, we have a GUI but it's missing the implementation. I may find time soon to finish it.
    Helpful post? Buy me a coffee.
  • #208 20757886
    erikvanboxtel
    Level 2  
    I have flashed my LSPA9 device and I have a question. I have used the HA auto discovery feature and that works well. In MQTT explorer I see that the energy consumption of yesterday is also being published (obk1Fxxxxxx/energycounter_yesterday/get). How can I display this value in HA? I tried adding this to configuration.yaml, but that doesn't work.
  • #209 20758154
    p.kaczmarek2
    Moderator Smart Home
    If it's not in discovery yet, then the configuration.yaml method is the way to go. I will look into it when I get some more free time.
    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