Elektroda.com
Elektroda.com
X

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

p.kaczmarek2 37335 206
This content has been translated flag-pl » flag-en View the original version here.
  • #181
    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.
  • #182
    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.
  • #183
    piratee
    Level 12  
    Hello
    How to change the time of data publication after MQTT to HA?
  • #184
    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
  • #185
    minusync
    Level 6  
    I have a similar socket as described here https://www.elektroda.com/rtvforum/viewtopic.php?p=20585167#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?
  • #186
    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?
  • #187
    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
    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.
  • #189
    minusync
    Level 6  
    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
    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
    miegapele
    Level 3  
    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
    miegapele
    Level 3  
    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:
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    Pcb is mostly the same, it actually has LSPA9 marking, but lacks MOV compared to the modern ones.
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    Show is run by BK7231T this time:
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    It contains the usual BP2525 power supply chip, which runs on 5V for relay
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    So it needs 3.3V regulator for the chip
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    And faintly marked BL0937 for power monitoring
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    Relay is 5V
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942

    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
    minusync
    Level 6  
    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
    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.
  • #195
    minusync
    Level 6  
    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
    p.kaczmarek2
    Moderator Smart Home
    Remove PowerSave 1 from startup.

    If calibration is not helping, maybe you've got swapped CF and CF1 pins?
  • #197
    minusync
    Level 6  
    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
    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?
  • #199
    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
    rishabmehta7
    Level 4  
    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?
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
  • #201
    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.
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
  • #202
    rishabmehta7
    Level 4  
    Hi the problem is the value just being zero.
  • #204
    skupu
    Level 11  
    >>19984436
    What is the value of this large resistor?
  • #205
    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.
  • #206
    rakalexei
    Level 7  
    @p.kaczmarek2 Good day, I faced the issue with switching between wifi ssid.

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

    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
    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.