logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 90588 372
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • ADVERTISEMENT
  • #212 20782379
    maczekg
    Level 13  
    Dears,
    Long time ago I bought 3 pieces of Tuya plugs (NEO NAS-WR01W) which I supposed to be easy to tasmotize - I already had same one tasmotized. What was a surprise, when I got Beken7231T ones :) They were working via LocalTuya integration, and one day one of them stopped to work (no wifi connection, no reaction on button). I supposed it to be dead, but I found your thread about OpenBeken, so decided to give it a try. Soldered wires, updated firmware and voila, it is alive again :)
    As I was able to recover it to same functionality as LocalTuya had (no power readings), I played with settings, succesfully configured BL0942, configured it to work with Home Assistant, but now there is an issue with voltage sensor.
    Here is what I see in Home Assistant:
    Screenshot of Home Assistant data showing incorrect voltage readings.

    In MQTT info I see following:
    Screenshot of MQTT configuration for NAS-WR01W OpenBeken plug

    Looks like something is mixed in MQTT data, voltage readings with signal strength, but I wonder where I did somthing wrong. I reloaded MQTT integration, removed and rediscovered device again, and no clue what's the point.
    Any ideas?
    By the way, thanks for everything what you're doing here, great job!
  • ADVERTISEMENT
  • #213 20784808
    maczekg
    Level 13  
    Update to the above - what I wrote about occurred on version 1.17.286. I changed it to 1.17.289, but with no result, the signal strength is still converted into voltage:

    . Screenshot from software showing an error where the signal strength is displayed as voltage.

    Sometimes the "voltage" value is displayed as the actual signal strength, e.g. "-47 dBm". I have no idea what it depends on.
  • #214 20784863
    p.kaczmarek2
    Moderator Smart Home
    I'll find a moment and check it out. If necessary, you can temporarily revert to the version before RSSI was added, which was relatively recently. I can find which one it is.

    Added after 2 [hours] 32 [minutes]:

    @maczekg I found the problem, it already works for me:
    User interface of a control panel with weather and sensor information.
    Electrical circuit simulation in OpenBeken using WJ3S and BL0942.
    I'm uploading the fix to Github.
    Helpful post? Buy me a coffee.
  • #216 20785282
    p.kaczmarek2
    Moderator Smart Home
    Please, if you have any other suggestions or ideas on what to do, let me know.
    Helpful post? Buy me a coffee.
  • #217 20787313
    skupu
    Level 12  
    p.kaczmarek2 wrote:
    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.


    Do we know?
  • #218 20787417
    p.kaczmarek2
    Moderator Smart Home
    @skupu I didn't check it, but then it turned out that it was impossible to remove the PCB and I chose the route of "cutting the corner of the housing" to get to the pads:
    Close-up of a damaged white adapter showing wires and PCB. Interior of a plastic enclosure with visible PCB and electronic components. Two damaged BLOW smart sockets with exposed interiors.
    You have to wait for another opportunity. And why do you need this resistor value?

    And the BL0937 or BL0942 application diagrams will not help?
    Helpful post? Buy me a coffee.
  • #219 20795959
    maczekg
    Level 13  
    >>20785282

    Hi,
    There will always be suggestions :) Today's topic - I noticed that after restarting HA (or reloading the MQTT integration), the "buttons" connected to the dashboard via OpenBeken sockets do not work. You can click as much as you want, it does not turn on the relay. After entering MQTT integration and displaying the properties, switching on the relay looks like this:

    Screenshot of a control panel with icons representing devices and an option to add to the dashboard.

    Only clicking on the uncrossed/crossed out lightning bolt (if the socket is off/on) turns on and "unblocks" the whole thing and changes to a regular switch:

    Control panel with a toggle switch to add to the dashboard.

    The buttons on the dashboard then start working. The situation is similar when you press the button on the socket itself - the lightning disappears and the switch appears. I have never noticed similar behavior on sockets or relays with Tasmota, ESPHome or Zigbee, so it is probably not a matter of HA itself.
    I wonder if the flags might have an impact on this - I have them set to 10, 27 and 40. Flag 10 probably not, I tried unchecking it and it doesn't change anything. Any suggestions?
  • #220 20795964
    p.kaczmarek2
    Moderator Smart Home
    I saw two solutions for this, you can:
    - turn on flag 2 so that the socket refreshes its status from time to time
    - in HA in yaml, force refresh with a simple script after restart, see topic: https://www.elektroda.com/rtvforum/topic4001877.html#20761607
    Helpful post? Buy me a coffee.
  • #221 20796618
    maczekg
    Level 13  
    Well, thanks again :) I chose script and automation.
    Three sockets have already been removed from LocalTuya and are running on OpenBeken.
  • #222 20796721
    skupu
    Level 12  
    @p.kaczmarek2

    >>20787417
    I think this resistor went bad and it has some strange strip markings on it, so I'm not sure what to replace it with.

    I don't know if the value is given in the diagrams because I didn't find them.

    As for disassembly, the board can be removed by unscrewing the screws inside the L/N pins or by unscrewing the screw in the board - at least that was the case in the products I had.
  • #223 20811797
    sebacornea
    Level 2  
    Hi,
    I have a LSPA9 clone called Chigoods with CBS2 wifi module and BL0937, successfully installed the latest OpenBK firmware and everything works fine except the voltage, current and power report. Did the calibration as instructed and with that particular lightbulb plugged in the values are ok. As soon as I change and plug in another device the values are off see attached image. I get 89,3 V instead of 218V. What could be the problem?
    Screenshot of OpenBK interface showing incorrect measurements of voltage, current, and power.
  • #224 20811935
    p.kaczmarek2
    Moderator Smart Home
    Hello, can you do Tuya config extraction and post here JSON?
    Helpful post? Buy me a coffee.
  • #225 20812188
    sebacornea
    Level 2  
    {
    	"sel_pin_pin":"24",
    	"rl1_lv":"1",
    	"bt1_pin":"10",
    	"net_trig":"4",
    	"jv":"1.0.5",
    	"netled1_lv":"0",
    	"netled_reuse":"0",
    	"bt1_type":"0",
    	"ffc_select":"0",
    	"nety_led":"1",
    	"vi_pin":"6",
    	"resistor":"1",
    	"over_cur":"30000",
    	"bt1_lv":"0",
    	"reset_t":"5",
    	"netled1_pin":"8",
    	"chip_type":"0",
    	"lose_vol":"90",
    	"over_vol":"265",
    	"module":"CB2S",
    	"ele_pin":"7",
    	"ch_cddpid1":"9",
    	"ch1_stat":"2",
    	"rl1_type":"0",
    	"ch_num":"1",
    	"ele_fun_en":"1",
    	"rl1_pin":"26",
    	"netn_led":"0",
    	"vol_def":"0",
    	"ch_dpid1":"1",
    	"sel_pin_lv":"1",
    	"crc":"101",
    	"}SyNAgw_di{abi":"0",
    	"id":"null",
    	"swv":"1.1.15",
    	"bv":"40.00",
    	"pv":"2.2",
    	"lpv":"3.4",
    	"pk":"keyjup78v54myhan",
    	"firmk":"keyjup78v54myhan",
    	"cadv":"1.0.5",
    	"cdv":"1.0.0",
    	"dev_swv":"1.1.15",
    	"s_id":"null",
    	"dtp":"0",
    	"sync":"0",
    	"attr_num":"1",
    	"mst_tp_0":"9",
    	"mst_ver_0":"1.1.15",
    	"mst_md5_0":"null",
    	"mst_tp_1":"0",
    	"mst_ver_1":"null",
    	"mst_md5_1":"null",
    	"mst_tp_2":"0",
    	"mst_ver_2":"null",
    	"mst_md5_2":"null",
    	"mst_tp_3":"0",
    	"mst_ver_3":"null",
    	"mst_md5_3":"null } )MAgw_wsm{nc_tp",
    	"ssid":"null",
    	"passwd":"null",
    	"md":"0",
    	"random":"0",
    	"wfb64":"1",
    	"stat":"0",
    	"token":"null",
    	"region":"null",
    	"reg_key":"null",
    	"dns_prio":"0 }{uuid",
    	"psk_key":"Rw2qljrrRdPptlRhoqAwKsiN9cLTPsspSfuaI",
    	"auth_key":"ysA8AJ4BOFfyYn6quSGuGBhYIWRdiw3s",
    	"ap_ssid":"SmartLife",
    	"ap_passwd":"null",
    	"country_code":"null",
    	"bt_mac":"null",
    	"bt_hid":"null",
    	"prod_test":"false",
    	"fac_pin":"ddms3xyc8sfctabe }3VAwf_start_mdll"
    }
    
  • ADVERTISEMENT
  • #226 20812638
    p.kaczmarek2
    Moderator Smart Home
    Ok, so is your GPIO correctly configured?
    Here is template importer:
    https://openbekeniot.github.io/webapp/templateImporter.html
    You can also import it directly in the OBK...
    Helpful post? Buy me a coffee.
  • #227 20813725
    sebacornea
    Level 2  
    It seems the GPIO was not configured correctly. PIN 6 and 7 assignment was switched. I used the BK7231 Easy flasher built in autoconfig from tuya backup but it seems that has a bug and assigned wrongly PIN 6 and 7. The online tool you provided showed the correct assignment and after I changed it, everything is working fine.
    Thanks for the help. Screenshot of the GPIO pin configuration program for BK7231.
  • #228 20813735
    p.kaczmarek2
    Moderator Smart Home
    Wow, this is a nice find! I will fix flasher now.
    Helpful post? Buy me a coffee.
  • #229 20832613
    minusync
    Level 9  
    maczekg wrote:
    They were working via LocalTuya integration, and one day one of them stopped to work (no wifi connection, no reaction on button). I supposed it to be dead, but I found your thread about OpenBeken, so decided to give it a try. Soldered wires, updated firmware and voila, it is alive again


    Exactly the same thing happened to me a couple of days ago with BL0937 version. This was really strange because when I did try to read it with BK7231Flasher I got CRC mismatch error and also was unable to read OBK configuration. But flashing with OB was without any problems and after some setup troubles, it is now fully functional again.

    I have also some questions to p.kaczmarek2 if he happens to read this.
    Is it still needed to "to save your BL0942 init and calibration constant setting commands in LittleFS or startup command " as described in the first post?
    Can I save the button state after a power outage? I have not found any settings for that. Maybe I missed something.
  • ADVERTISEMENT
  • #230 20833531
    p.kaczmarek2
    Moderator Smart Home
    minusync wrote:
    maczekg wrote:
    They were working via LocalTuya integration, and one day one of them stopped to work (no wifi connection, no reaction on button). I supposed it to be dead, but I found your thread about OpenBeken, so decided to give it a try. Soldered wires, updated firmware and voila, it is alive again


    Exactly the same thing happened to me a couple of days ago with BL0937 version. This was really strange because when I did try to read it with BK7231Flasher I got CRC mismatch error and also was unable to read OBK configuration. But flashing with OB was without any problems and after some setup troubles, it is now fully functional again.

    That\s good to hear, however, I have never heard yet about CRC error in BK7231 GUI flasher. It happens in HID_download_py because of the wrong algorithm implementation, but not in my flasher. Did it happen every time you read?
    Can you read device configuration with the Web App method? The one from our YT video?
    https://www.youtube.com/watch?v=WunlqIMAdgw


    minusync wrote:

    I have also some questions to p.kaczmarek2 if he happens to read this.
    Is it still needed to "to save your BL0942 init and calibration constant setting commands in LittleFS or startup command " as described in the first post?

    You can use our docs to check the latest state of c ommands:
    Screenshot of a table in documentation with the VoltageSet command.
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md


    minusync wrote:

    Can I save the button state after a power outage? I have not found any settings for that. Maybe I missed something.

    Do you mean relay state?
    Documentation snippet showing the SetStartValue command and its description.
    It can be also done via WWW GUI with "Configure Startup" menu
    Helpful post? Buy me a coffee.
  • #231 20842003
    minusync
    Level 9  
    p.kaczmarek2 wrote:
    I have never heard yet about CRC error in BK7231 GUI flasher. It happens in HID_download_py because of the wrong algorithm implementation, but not in my flasher. Did it happen every time you read?


    I didn't try that hard because the Tuya software didn't seem to work anyway. I first tried to just read for backup and then also the OBK settings just in case. The weirder thing is that the OB software worked. I think the memory was somehow corrupted?? because initially OB also had almost similar constant reboot problem. At one point, however, all the settings disappeared by themselves - even wifi and MQTT. After setting everything up again, suddenly everything started working.

    p.kaczmarek2 wrote:
    You can use our docs to check the latest state of c ommands:


    Since it is obviously now possible to perform calibration in the webapp, c commands are not directly necessary for this. The point of the question was rather whether the calibration made in the web app is preserved after the device restart?
  • #232 20842520
    p.kaczmarek2
    Moderator Smart Home
    minusync wrote:

    Since it is obviously now possible to perform calibration in the webapp, c commands are not directly necessary for this. The point of the question was rather whether the calibration made in the web app is preserved after the device restart?

    Yes, I answered you in the previous post. Please open this screenshot from the documentation:
    Screenshot of documentation for the VoltageSet command related to voltage calibration.
    The text on screenshot reads:
    Quote:

    Measure the real voltage with an external, reliable power meter and enter this voltage via this command to calibrate. The calibration is automatically saved in the flash memory.

    The calibration is saved in flash memory, which means, it's kept forever stored in the device. In general, it's worth to check the docs often, both our commands list and FAQ:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/faq.md
    Helpful post? Buy me a coffee.
  • #233 20843208
    minusync
    Level 9  
    p.kaczmarek2 wrote:
    Yes, I answered you in the previous post. Please open this screenshot from the documentation:


    Nice to know, but there was a little bit of contradiction between the first post of the thread and the current situation. That is why I always promote whenever it is possible to keep the first post with actual instructions up to date. This is the place where most of the users will look for actual setups. Especially since the device database literally points to the forum thread of each device. So users should by design get most if not all of the necessary information for setup from there.
    The best example of a great (in my opinion) , clear structure and instructions for users is XDA forums like for example this one: https://xdaforums.com/t/guide-magisk-unlock-root-keep-root-oos-13-1-0-591.4252373/
    thanks
  • #234 20843935
    denisrobel
    Level 3  
    Hallo,

    I flashed a LSPA9 plug successfully with tuya-cloudcutter.
    Everything is working well except when I'm switching the plug on or off manually with the button the state will not transferred via MQTT.

    When I switch this plug remotely via MQTT everything is working well.

    Is there any workaround or a fix for this problem?
  • #235 20843936
    p.kaczmarek2
    Moderator Smart Home
    Have you followed our HASS discovery guide? What is your device config?
    Easy Home Assistant Discovery Pairing for BK7231T, BK7231N, BL602, XR3, W800, W600, etc. - OpenBeken
    Helpful post? Buy me a coffee.
  • #236 20843993
    denisrobel
    Level 3  
    Thank you for your feedback.

    I don't use HA. I'm happy with FHEM...

    I followed this guide an this fixed my problem.

    I made some typos in my mqtt config.
  • #237 20889664
    sliver85
    Level 4  
    Hello,

    I purchased a smart plug on AliExpress: https://fr.aliexpress.com/item/1005005725291219.html It had CB2S and BL0937 as chipsets with Tuya version 1.1.15, making it flashable with Tuyacutter. Through the exchanges in this conversation, I managed to flash the smart plug with OpenBK 1.17.389 (had to desolder the CB2S chip to do so, as the flash wouldn't start on bk7231flasher_1.1.6 otherwise).

    Screenshot of an energy consumption monitoring app interface with a set of data.

    The smart plug is discovered by Home Assistant, but some elements are missing, which are available on MQTT Explorer. I can retrieve "energycounter" and "energycount_last_hour," but not "energycounter_last_hour," "energycounter_today," and "energycounter_clear_date."

    Screenshot from MQTT Explorer showing various energy values for a smart plug.

    This issue occurs on both smart plugs I flashed with OpenBK. I thought of bypassing the problem through the configuration.yaml and creating the sensor manually, but that doesn't work either. Any ideas?

    sensor:
      - platform: mqtt
        name: "BL0937 Energy_yesterday"
        state_topic: "obk68191C68/energycounter_yesterday/get"
        unit_of_measurement: "Wh"
      - platform: mqtt
        name: "BL0937 Energy_today"
        state_topic: "obk68191C68/energycounter_today/get"
        unit_of_measurement: "Wh"


    Thank you very much.
  • #238 20889683
    p.kaczmarek2
    Moderator Smart Home
    Do you have set a SetupEnergyStats command in either startup line or autoexec.bat?
    Helpful post? Buy me a coffee.
  • #239 20889701
    sliver85
    Level 4  
    Yes,

    Startup command:
    backlog startDriver BL0937; StartDriver NTP; PowerSave 1; ntp_setServer 192.168.1.1; ntp_timeZoneOfs +1; SetupEnergyStats 1 60 5;


    Screenshot showing the user interface for OpenBK7231N_68191C68 with status ON.
  • #240 20905357
    greg_li
    Level 2  
    >>20889664 I probably have exactly the same plug as you do (I bought 2 of them, by mistake as I wanted the Zigbee version): Same CB2S+BL0937, same tuya firmware 1.1.15. That gave me the occasion to experiment, so I flashed both with OpenBK7231N_1.17.391 and put them on my home network. Good practice for my soldering and de-soldering skills (the second one was nasty, CB2S was very tight).
    I stopped before the full configuration (only did the wifi config so it's more convenient to access them) cause I am on linux and was not able to launch the configuration extractor (a windows exe). Could you share your configuration? I think the chance of your plugs being exactly like mines is high, so appart from extracting the info from the tuya.bin it's my best shot at getting things right first try....

    BTW I also plan to use MQTT to communicate with my HomeAssistant (so that it is close to my other zigbee plugs connected to my zigbee2mqtt bridge) so I will report if I manage to do it (or not).

Topic summary

The discussion revolves around the Tuya LSPA9 smart socket, focusing on its teardown, flashing OpenBeken firmware, and configuring the BL0942 energy metering chip. Users share their experiences with various versions of the LSPA9, including issues with calibration, communication protocols (UART vs. SPI), and the stability of energy readings. Solutions include using specific commands for calibration, adjusting baud rates, and troubleshooting connectivity issues. The conversation also touches on the integration of these devices with Home Assistant and the challenges faced in ensuring accurate power measurements and MQTT communication.
Summary generated by the language model.
ADVERTISEMENT