libretiny-eu / libretiny

PlatformIO development platform for IoT modules
http://docs.libretiny.eu/
MIT License
382 stars 55 forks source link

BL0937 not working with wb2s #202

Closed brunosalezze closed 8 months ago

brunosalezze commented 8 months ago

I have a smart power plug with a WB2S chipset and a BL0937 power/current/voltage monitor. Libretiny works well to sense button and control LED and Relay, but the BL0937 readings only return zeros. The pinout is correct since I opened the device and tested with OpenBeken. With OpenBeken the readings are perfect. My YAML is the following:

bk72xx: board: wb2s

logger: level: DEBUG

sensor:

Power sensor

binary_sensor:

Binary sensor for the button press

switch:

Switch to toggle the relay

and the OpenBeken config is the following:

"vendor": "Tuya", "bDetailed": "0", "name": "Full Device Name Here", "model": "enter short model name here", "chip": "BK7231T", "board": "TODO", "flags": "33554432", "keywords": [ "TODO", "TODO", "TODO" ], "pins": { "6": "LED;57", "7": "BL0937CF;56", "8": "BL0937CF1;55", "10": "Btn_n;53", "23": "ADC;0", "24": "BL0937SEL;9", "26": "Rel;37" },

Any help for further debuging?

Cossid commented 8 months ago

It has been the general experience that you need to invert the pins for sel, cf, and cf1 on the Beken platform. No idea why, but that is how Tuya generally has the configs as well.

brunosalezze commented 8 months ago

Thank you, with this config the device works as expected:

sensor:

Power sensor