openshwprojects / OpenBK7231T_App

Open source firmware (Tasmota/Esphome replacement) for BK7231T, BK7231N, BL2028N, T34, XR809, W800/W801, W600/W601, BL602 and LN882H
https://openbekeniot.github.io/webapp/devicesList.html
1.48k stars 276 forks source link

CSE7766 driver? #109

Closed belikh closed 2 years ago

belikh commented 2 years ago

Hi, is there any chance of including the power monitor IC CSE7766 driver?

I have this device: https://templates.blakadder.com/deta_6920HA.html

I've managed to flash the WB2S within and the touch sensors and relays are working, but I'm not sure how to proceed with adding voltage/current sensor.

It seems supported in Tasmota and ESPHome.

(for anyone interested I needed to desolder the WB2S in order to flash.)

openshwprojects commented 2 years ago

CSE7766 looks very simple, it uses UART interface, but I would need to get somehow one device for testing.

belikh commented 2 years ago

Would remote web access to my device be of any help? Otherwise I don't mind testing it. I'm not sure how commonly the CSE7766 is used but we don't have a lot of options in Australia.

openshwprojects commented 2 years ago

It would be very helpful, but I would have to have the remote access to openbk panel, I would need to be able to do a firmware update, and there would need to be some kind of load in the socket, maybe 10W bulb or something.

I would also need some photos from inside or at least know which pins are used by CSE7766

belikh commented 2 years ago

I'm assuming that the chip is on the 1TX and 1RX pins, as I can't flash with those connected.

Device is at http://110.151.54.191/ at least for now. I'm connected via LTE temporarily.

Also I have a bulb marked 60w connected.

belikh commented 2 years ago

20220707_115055.jpg

openshwprojects commented 2 years ago

Ok let me see, but I think w should rather get a Discord or an email conversation

openshwprojects commented 2 years ago

working on it

openshwprojects commented 2 years ago

image receiving raw data, now i need to parse it, wait...

openshwprojects commented 2 years ago

it's almost working, but I don't know why it reports current even if turned off

I looked at Tasmota code and they just do a little "cheat" and set current manually to 0 when relay is off.... maybe we will do the same

I need another 24 hours as I will continue testing it tomorrow

belikh commented 2 years ago

Aha I have awoken to find Santa visited :p

I'll leave the port open until you say you don't need it :)

I've turned off the load though until you need it (energy crisis etc)

Thanks again!

The annoying thing about these and every single other one I could find is they use one power meter for two relays. So not sure how that factors in to the tasmota 'solution' :p

openshwprojects commented 2 years ago

@belikh can you explain what exactly is inside this device, because I am not entirely sure? The power metering chip is measuring power consumption of the two sockets together?

belikh commented 2 years ago

Correct. It has one input, two power outlets and two usb sockets. I'm not sure if it's measuring usb also.

It's a pretty tightly packed pcb and hard to tell what's going on.

I've got another I'll take some photos

openshwprojects commented 2 years ago

@belikh what is the voltage in your country, the exact measurement would be welcome...

Also, have you read that guide? https://www.elektroda.com/rtvforum/topic3887748.html

belikh commented 2 years ago

Screenshot_20220708-185813_Home Assistant.jpg

Does this help? :)

belikh commented 2 years ago

The insides. Please ignore ugly flux :/

20220709_101108.jpg 20220709_101151.jpg 20220709_101312.jpg 20220709_101716.jpg

openshwprojects commented 2 years ago

Thanks I'll see if I get some free time today

openshwprojects commented 2 years ago

Can you double-check some things?

  1. read this guide https://www.elektroda.com/rtvforum/topic3887748.html
  2. here is your calibration: image
  3. do you also see that the Power goes to 0 with a certain delay after turning off the bulb? It's like it needs some time to notice there is no bulb
  4. Do you also see that current consumption is still showing strange results even with both relays off?
  5. do power reading gives correct values? is it correct if you change that single bulb to two bulbs, or to 20W bulb, etc? I am not sure about point 3, but point 4 can be fixed from software side by setting it to 0 when all relays are off...
belikh commented 2 years ago

It seems like current is behaving opposite to expectation?

I have the device connected to a meross plug. then i've got my PC in outlet 1 and OLED TV in outlet 2

(relay state at top, blue is device reading, purple meross)

image
openshwprojects commented 2 years ago

as the device is currently offline, can you try this and recalibrate? https://github.com/openshwprojects/OpenBK7231T_App/commit/ce6f0aa37108b2c401c846ff876065c8acd98ff2

openshwprojects commented 2 years ago

I think that @talltechdude tested this code and made some good adjustments, so now I can close this issue.