logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 90534 372
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #61 20377846
    spin55
    Level 17  
    p.kaczmarek2 wrote:
    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.


    OpenBK7231N_QIO_1.15.263

    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
  • ADVERTISEMENT
  • #62 20397347
    erikvanboxtel
    Level 2  
    Hi,

    I have this device and connected the correct wires and did everything right. But I can't program the CB2S! Why? There is no BK7231Flasher.exe file on github. Please provide a pre-compiled version of the flasher! I'm currently working on an old system and I am not able to install visual studio. I have downloaded "OpenBK7231N_QIO_1.15.347.bin" and want to flash that file. Is that the correct bin file or do I have to burn another (bootloader) file first? Please help me with a precompiled BK7231Flasher.exe.
    To make it easier for everyone to be able to do this:
    1) Download flasher tool from http://..../BK7231Flasher.exe or http://.../BK7231Flasher.zip.
    2) Download bin file from http://..../firmware.bin or http://..../firmware.zip. Found the link on this forum.
    3) Flash the file
    That would be great. Thanks in advance.
    Most people won't edit the flasher code and just want the exe file. Providing this file will also prevent malware being made and published somewhere else with the same name. Yes, I googled "BK7231Flasher.exe". I even wanted to use the outdated python flasher, but posted this instead.
    Thank you so much for the great work and your help.

    Best reagrds,
    Erik

    Ps. the flash board is a self made board with FTDI chip. Power is provided by 5V jumper position that's not used (3V3 is connected). The button is to reset the controller and start the programming. I will probably replace the relay with a solid state relay (Sharp S216S02).
  • #63 20397486
    p.kaczmarek2
    Moderator Smart Home
    Hello @erikvanboxtel . Precompiled version is available always, from the very beginning of the flasher. Have you checked "Releases" tab on the right?
    https://github.com/openshwprojects/BK7231GUIFlashTool
    It's here:
    https://github.com/openshwprojects/BK7231GUIFlashTool/releases
    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
    Where do you have a topic with missing Flasher link?


    PS: You can also use bkWriter 1.60 or hid_download_py. Read more here:
    https://www.elektroda.com/rtvforum/topic3951016.html
    Helpful post? Buy me a coffee.
  • #64 20399803
    erikvanboxtel
    Level 2  
    Thank you very much for your reply. You're flash programming tool is briljant.

    Everything works, but I have only a problem with the DNS lookup. This is the response from the ping request (laptop on same network):
    ping homeassistant.local

    Pinging homeassistant.local [192.168.1.150] with 32 bytes of data:
    Reply from 192.168.1.150: bytes=32 time=3ms TTL=64
    etc.

    This is the response from your firmware:.
    MQTT State: disconnected RES: 0(ERR_OK)
    MQTT ErrMsg: mqtt_host homeassistant.local not found by gethostbyname
    MQTT Stats:CONN: 47 PUB: 0 RECV: 0 ERR: 0

    Now I use the IP number and that works, but I prefer to use the hostname. My Tasmota (same network) works with this hostname (homeassistant.local). The ping request to pool.ntp.org was also a problem. Please fix this DNS problem. That would be great.

    I also did the calibration.... I visited the "Launch Web Application" and selected the right device. I did the "StartDriver BL0937" command and after that I did these "Execute custom commands" with the correct parameters to calibrate the device:
    - "VoltageSet 228"
    - "PowerSet 100"
    - "CurrentSet 0.42"

    I have a question. Why do you have to set voltage, power AND current for this calibration (P=U*I?)? Is voltage (AC voltage measurement Fluke) and setting power or current not enough?

    Information for people that want to use the NTP function. Enable the NTP server with this at the "Change startup command text". "backlog startDriver NTP; startDriver BL0937" (my device) or "backlog startDriver NTP; startDriver BL0942". To correct for a time offset use this custom command (looked it up in the code): "ntp_timeZoneOfs 01:00" ntp_timeZoneOfs hh:mm. You can use a minus before hh:mm. Don't do this: "ntp_timeZoneOfs 1:00". Hours must be 2 digits.

    Best regards,
    Erik

    Ps. I am impressed with the work you have done. This socket with power measurement is connected to the TV. When the TV is powered on (TV>50W), it will also power on the HDMI receiver. This HDMI receiver/amplifier draws always 90W. So also when it's not working (standby). When I turn off the TV (TV<50W), home assistant will power off this HDMI receiver unit. The HDMI receiver uses a tasmota power socket (ESP8266 device).
  • #65 20441517
    kokskrustnagla
    Level 2  
    Hello,
    I am new in this project. I need some information. I flash 2 devices BK7231N CB2S Model: 4B2-39G1-01 ZN366877_01 with openbk7231N_1.15.452. But one of this device did not shows total consumption. In the front page I se Total consumption=inf Wh.
    I try to reset, calibrate the voltage but nothing change. Below I added photo. Maybe You have some solution for that.
    Best regards Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
  • #66 20441576
    p.kaczmarek2
    Moderator Smart Home
    Hello, please try EnergyCntReset command.
    Helpful post? Buy me a coffee.
  • #68 20441895
    p.kaczmarek2
    Moderator Smart Home
    Remember to try out other features, like "startDriver SSDP" (in short startup command - use backlog for multiple commands) so Windows can detect obk devices in network places.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #69 20489793
    mminkov
    Level 5  
    Hi there, after version 1.15.584, my socket with BL094 can't measure voltage and power consumation. Recalibrate needed?
  • #70 20489818
    p.kaczmarek2
    Moderator Smart Home
    Thank you for reporting Are you saying that this pull request broke things?
    https://github.com/openshwprojects/OpenBK7231...mmit/6f6086e5805b34058e1a980993808ef8a766b110
    @Digga you've accidentally broken BL0942 UART:
    
    #define UART_CMD_READ (0x58 & UART_ADDR)
    

    That gives 0x00 value for UART_ADDR 0... I've pushed a fix.

    I need to add a self-test for that...

    Please update software and it will work now
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #71 20489841
    mminkov
    Level 5  
    583 is last working version (I mistake in previous post)
  • #72 20489861
    p.kaczmarek2
    Moderator Smart Home
    I know. SPI driver for BL0942 had introduced a typo for BL0942 UART that I didn't notice in the PR review process.

    Please update to 1.15.596, it should be okay. No recalibration needed. Can you check?
    Helpful post? Buy me a coffee.
  • #73 20489865
    mminkov
    Level 5  
    10x, working well... I see in log file "freq", is this frequency, and how can show human readable value
  • #74 20489879
    p.kaczmarek2
    Moderator Smart Home
    That's good. I apologize for the inconvenience. Thanks for reporting. It seems I must really review the further Pull Request in more detail.
    Helpful post? Buy me a coffee.
  • #75 20499425
    mminkov
    Level 5  
    Good work for v1.15.614, enegy look perfectly
  • #76 20499469
    p.kaczmarek2
    Moderator Smart Home
    It was @Digga pull request, all thanks to him.

    In a meantime, I added calibration interface to Web App (so you don't have to use VoltageSet commands etc):
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    Helpful post? Buy me a coffee.
  • #77 20501987
    Digga
    Level 9  
    Just saw this thread. Thanks. And yes, I accidentally broke the UART bl0942, as I have no hardware to test changes yet. Thanks for fixing it so quickly.

    I want to get one bl0942 plug and not bl0937, because in the future I want to integrate and be able to measure positive and negative power separately. For solar panel power. And it seems not to be possible with bl0937.

    So, do you know which one I can get from aliexpress with bl0942 or is it more random and just luck to get the bl0942? I have two plugs in mind:
    LSPA9
    Cheapest :) But maybe not even tuya/bk7231?
  • #78 20502001
    p.kaczmarek2
    Moderator Smart Home
    I had ordered LSPA9 twice, once about two years ago, and second time about a year ago, and my first LSPA9 was with BL0937 + WB2S and second one (newer) was with BL0942+CB2S. They both look the same from outside. So I am not sure what to advice...
    Helpful post? Buy me a coffee.
  • #79 20502013
    Digga
    Level 9  
    Thanks for the info. So I probably have to order and hope for bl0942. Hopefully newer devices are always with bl0942...
  • #80 20504117
    piratee
    Level 13  
    Hello
    A friend has a 1-phase photovoltaic. how to check the flow direction is it "+" or "-" on BL0942?
    Regards
  • ADVERTISEMENT
  • #81 20504129
    p.kaczmarek2
    Moderator Smart Home
    @piratee I haven't tested it but there seems to be a flag that allows negative values:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/flags.md
    Flag number 25.
    Helpful post? Buy me a coffee.
  • #82 20506612
    Digga
    Level 9  
    Yes, with this flag you can measure negative power (Watt). But the energy is always counted absolute (positive).
    If the power is negative for power consumption and positive for the photovoltaic power, then you can recalibrate to fix this.

    Edit: I have to correct myself. If the power is negative, it is not counted to the energy. If it is "+" for consumption and "-" for generation pr vise versa depends on your calibration.
  • #83 20506698
    pawel3110
    Level 15  
    p.kaczmarek2

    Great project.
    Is it possible to change the operation of command VCPPublishThreshold from a value to a percentage change?
    At higher current and power it will be more useful, because then the delta is larger than at low power and causes excessive publication of new values?
  • #84 20513886
    sirlouen
    Level 4  
    @p.kaczmarek2 I've been trying to launch a very similar product
    https://www.elektroda.com/rtvforum/topic3968081.html

    But I'm not receiving any signals from power metering.

    Also I've copied your YAML for the PM sensors but it throws a ton of errors:

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

    (I've modified the obk0696FB33 with my device mqtt name, but the errors are still there
  • #85 20513999
    p.kaczmarek2
    Moderator Smart Home
    Hello @sirlouen . It looks like you are trying to write YAML code for OpenBeken device by hand, which is not a recommended method. Do you know that OpenBeken currently supports Home Assistant Discovery, so the power metering device can be added to your HA with just a few clicks?


    Helpful post? Buy me a coffee.
  • #86 20514017
    sirlouen
    Level 4  
    p.kaczmarek2 wrote:
    Hello @sirlouen . It looks like you are trying to write YAML code for OpenBeken device by hand, which is not a recommended method. Do you know that OpenBeken currently supports Home Assistant Discovery, so the power metering device can be added to your HA with just a few clicks?


    Great it works now in HA.
    Now I have to discover how to configure the pins for these BL0937 device because I'm not receiving a single power reading. Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
  • #87 20518019
    p.kaczmarek2
    Moderator Smart Home
    It is worth adding that the rest of @sirlouen discussion about BL0937 problem is in this topic:
    https://www.elektroda.com/rtvforum/topic3968081.html
    It has turned out that he was sold a device that has no power metering. Probably a shipping issue or a scam offer.

    So, next time when you're not sure about not working BL0937, consider opening your device and checking if there really is one. Or at least first try the Tuya firmware to be sure that the device can measure power, etc.
    Helpful post? Buy me a coffee.
  • #88 20520492
    Digga
    Level 9  
    Sorry for bothering again, but I tried to find out, which module has BL0942 and not BL0937, but it is like impossible. Also the sellers from Ali Express cant help. Only on replied, that they use BL0937.

    So, does anybody ordered a power metering plug with BL0942 and still has the ordering link? (Preferable Ali Express).
    Would be great help.

    @p.kaczmarek2 Didn't you order from Ali Express? Could you have a look in your profile orders, if the link is still available?
  • #89 20520585
    p.kaczmarek2
    Moderator Smart Home
    I have checked but it seems that I don't have that purchase in the history. Futhermore, I don't think it's a reliable method of determining what is inside the device. It was two years ago.

    I already had a situation where I bought 2 gang switch from the seller and got WB3S based one and then I order the 3 gang + RF version from the very same offer, just different product subtype and got TYWE3S-based one...

    Maybe just check forums for people who bought their devices in last weeks.

    Maybe that one has BL0942, and also an aliexpress link?
    https://www.elektroda.com/rtvforum/topic3965530.html

    Added after 10 [hours] 19 [minutes]:

    @Digga I really think that the offer linked there:
    https://www.elektroda.pl/rtvforum/topic3965530.html#20521865
    have aubess switch with BL0942 for relatively low price
    Helpful post? Buy me a coffee.
  • #90 20523668
    Digga
    Level 9  
    @p.kaczmarek2 Thanks a lot. I prefer a plug, but would have ordered if my other plan didn't work out:

    I wrote to 12 sellers on aliexpress and asked if their plug is using BL0942. Most couldn't answer the question. Some said they are not using BL0942. One wrote only "yes" and one other asked the tech support and replied, it is using the BL0942. I ordered two of them. Here is the link (but I don't guarantee anything):
    https://de.aliexpress.com/item/1005004856918423.html
    I will arrive 7.5.. So is anyone is interested I could give feedback, when it arrived and I opened it for flushing. Or mabe trying cloud cutter. Would be nice if it wouldn't be necessary to open the plug.
    The one just answered with yes:
    https://de.aliexpress.com/item/1005005324161607.html (also available in black)

    Edit: The plugs arrives today. I made a misstake and ordered Zigbee instead of Wifi plugs. Furthermore they have the BL0937 and not BL0942 as the seller told me. I made a complain... Seems like the best bet, as @p.kaczmarek2 suggested, is to order an item, which was presented here recently with the correct chip.

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