logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

[BK7231N] How to add BL0939 SPI support for Tuya 2x CT Smart Power Meter Clamp?

geoagache 636 32
Best answers

How can I add or use BL0939 SPI support for a BK7231N Tuya dual-CT smart power meter clamp, and how do I calibrate it?

Use the custom `bl0939spi` driver and start it with `startdriver bl0939spi`; the thread confirms a bit-banged SPI implementation on P6 (MISO/SDO), P24 (MOSI/SDI), and P26 (SCLK), and it worked on the BK7231N device after flashing the test build [#21924051][#21924136][#21925040] Make sure the BL0939 SEL pin is tied to VDD on this board, which confirmed that the chip is in SPI mode [#21924569][#21924580] The driver is likely to use renamed calibration commands rather than the usual console names, because `VoltageSet`/`help` were missing in the stripped build [#21925040] For calibration, the source notes that `SetVoltage` exists under a different name and current has `SetCurrentA` and `SetCurrentB`, so the driver/source should be checked for the exact command names [#21925086][#21925105]
ADVERTISEMENT
  • #31 21927089
    DeDaMrAz
    Level 22  
    Posts: 611
    Help: 34
    Rate: 130
    Excuse my French for the wrong name/term call there 😁

    I was referring to the same thing. I mention that I am catching up from some absence and you guys did an amazing job of improving everything and adding more and more, every time I try to look at the code base something is changed - compound that to nearly 2-3-4 months and you get a stupid question like mine 😉

    Nice and good to know, I will look into that more but 32k area i way more than than I remember. Thanks.
  • ADVERTISEMENT
  • DRY abstraction can mispublish unsupported BL0937 frequency

    #33 21927194
    DeDaMrAz
    Level 22  
    Posts: 611
    Help: 34
    Rate: 130
    divadiow wrote:
    DRY appears to be the acronym of the moment.


    Oh yes, power metering comes to mind where that principal exposed frequency readout on BL0937 chip even thou it is not supported - because all power metering chips are bunched up into one category then a generic value publish run on them.

    DRY is good but it has to be audited to avoid mistakes such as the one I mentioned above. BTW AI is bad at DRY unless explicitly enforced 😉 don't ask me how I know!

Topic summary

✨ Discussion about adding OpenBeken support for a Tuya-based dual CT smart power meter clamp using a CB3S module with BK7231N and a BL0939 energy-monitoring chip wired over SPI instead of the usual UART. The board pinout was reverse-engineered, including SPI lines on P6/P24/P26 and control signals on P14, P23, P8, and P7. A new experimental BL0939 SPI driver for BK7231N was shared for testing, but hardware compatibility was uncertain because the referenced pins do not match standard UART or hardware SPI. Datasheet inconsistencies were noted, with some sources describing I2C and others SPI/UART, while ESPHome documentation shows UART usage. A fallback suggestion was to replace the module with an ESP-based solution and use ESPHome.
ADVERTISEMENT