Sonoff powct / pow ring power not accurate

Good day,

I flashed my Sonoff POWCT with ESPHome. The relay works perfectly, but the power accuracy is most definitely NOT correct. I tested it with an electrician. I have 2 units, one has ESPHome and the other is stock with the Ewelink app.

The mains measure 235w and when the 3kw geyser kicks in, the house measures 1183w. The device with the stock firmware measured over 4kw. Oh and when exceeding the 4kw, the ESPHome flashed POWCT actually drops it’s reading to 537w

Can anybody kindly please point me in the right direction? I tried flashing to Tasmota, but apparently that’s not possible.

Kind regards,

1 Like

Hi, I found the same problem and made a fix.
You can try the PR here: [cse7761] Add Sonoff POW-CT support and frequency sensor by mick96 · Pull Request #7836 · esphome/esphome · GitHub
Have a look at the related documentation PR for usage details: [cse7761] add POWCT and frequency support by mick96 · Pull Request #4469 · esphome/esphome-docs · GitHub

3 Likes

Nice work there @mick96.
Looking forward for the Merge if is approved.
Is there anything we can do to help with that ?

1 Like

Thnak you @VasilisA.
Honesty I’m pretty new on git pull request and in esp home development scene. If you guys can test it and confirm it is working also on your side you can post a comment in the pull request.

1 Like

Hi @mick96 and everyone else,

First of all I’d like to thank you for helping with the pull request. I forgot to reply back, but I have found a fix which in my opinion is much quicker to do.

Referring to the official config file which can be found on the ESPHome website by clicking here, there is a section that says “Measurement divided by the PI number”. I had to pull the logs on the device in “VERY_VERBOSE” mode to verify that it’s in fact referring to the PI number as in 3.14… in mathematics, which it did.

Below is the “wrong” piece of configuration:

sensor:
  - platform: cse7761
    update_interval: 2s
    current_1:
      name: Current
      id: a_sensor
      unit_of_measurement: 'A'
      accuracy_decimals: 3
      icon: mdi:current-ac
      filters:
        # Measurement divided by the PI number
        - lambda: return x / PI;
    voltage:
      name: Voltage
      id: v_sensor
      unit_of_measurement: 'V'
      icon: mdi:sine-wave
    active_power_1:
      name: Power
      id: w_sensor
      filters:
        # Measurement divided by the PI number
        - lambda: return x / PI;
      icon: mdi:flash
      on_value_range:
        - above: 4.0
          then:
            - light.turn_on: switch_led
        - below: 3.0
          then:
            - light.turn_off: switch_led

All I did to fix it was to remove the filters, please see my code below:

sensor:
  - platform: cse7761
    update_interval: 2s
    current_1:
      name: Current
      id: a_sensor
      unit_of_measurement: 'A'
      accuracy_decimals: 3
      icon: mdi:current-ac
 
    voltage:
      name: Voltage
      id: v_sensor
      unit_of_measurement: 'V'
      icon: mdi:sine-wave
    active_power_1:
      name: Power
      id: w_sensor
      icon: mdi:flash
      on_value_range:
        - above: 4.0
          then:
            - light.turn_on: switch_led
        - below: 3.0
          then:
            - light.turn_off: switch_led

I have no idea why the developers thought is was necessary to do this, but removing this actually fixed the issue and the reading matched with my Sonoff POWCT that still had the stock Ewelink software installed.

Oh and please see this section in the log where the “raw” data was being divided by the PI number:

[18:58:21][D][cse7761:224]: Channel 1 power 3681.787109 W, current 26.911350 A
[18:58:21][V][sensor:043]: 'Power': Received new state 3681.787109
[18:58:21][VV][sensor.filter:014]: Filter(0x3ffb3104)::input(3681.787109)
[18:58:21][VV][sensor.filter:286]: LambdaFilter(0x3ffb3104)::new_value(3681.787109) -> 1171.949219
[18:58:21][VV][sensor.filter:021]: Filter(0x3ffb3104)::output(1171.949219) -> SENSOR
[18:58:21][D][sensor:094]: 'Power': Sending state 1171.94922 W with 1 decimals of accuracy

I hope this helps. Please do not hesitate to ask, should someone have any questions.

Thanks for this!
After your patches, would this config stay or get removed?
For both a_sensor and w_sensor there is:

        # Measurement divided by the PI number
        - lambda: return x / PI;

at the config link:

Would that filter get removed with your patches, or the filters remain?

1 Like

I see the PR has a comment from user “tinusb” who tested the PR, saying it fixes the issue and works:

1 Like

I did indeed remove the filters. Please refer to this post. The second piece of code is with the filters removed. That’s pretty much the fix, just remove the filters and the power readings would be correct.

1 Like

Thanks for this! I’m going to test it and reply to this post ASAP

Have you tested this yourself yet?

Not as yet, I only saw it today. I saw that it mentions that without the patch, up to 2kw is accurate, then over 2kw is inaccurate. The patch fixes that. You marked solution to remove the filters, I wonder if it doesn’t solve the over 2kw issue? Possibly only the patch is the right fix for this issue in all cases?

I did a lot of testing before eventually removing the filters. It definitely fixes the accuracy above 2kw. The post I marked as the solution, is still the solution for me, but I’d like to test the more “official” fix as well. I’m probably only going to be able to test it the weekend. I will definitely report back. Can you also please post your findings once you were able to test the PR?

1 Like

Thanks. I will do so, but likely only get around to it weekend or next week even. What I’m not clear about then, is should the PI filters remain or be removed, after the cpp file patches. I’m hoping that @mick96 can advise so when we do get around to testing it, we can do so with correct config.
Thanks again to everyone for the efforts.

1 Like

So I applied the PR patches, removed the PI filters from my config, added the config:

sensor:
  - platform: cse7761
    sonoff_model: POWCT

And it is looking good!
Not only is it now accurate above and below 2kw, but over 24 hours it matches my mains utility usage reading very closely.

1 Like

I’ll try my best to test it out tonight. Very excited :grin:

1 Like

Somehow, ESPHome doesn’t want to accept the config. Maybe I’m doing something wrong?

sensor:
  - platform: cse7761
    sonoff_model: POWCT
    update_interval: 2s
    current_1:
      name: Current
      id: a_sensor
      unit_of_measurement: 'A'
      accuracy_decimals: 3
      icon: mdi:current-ac