Egyras / HeishaMon

Panasonic Aquarea air-water H, J, K and L series protocol decrypt
217 stars 113 forks source link

S0-metering noisy when Opentherm is used #437

Open jacco-hass opened 6 months ago

jacco-hass commented 6 months ago

My (Emat) S0-meters work fine, but once I turn on Opentherm processing, the readings become very noisy (spikes up to 50000 W). I have a Plugwise Anna + Smile thermostat, which is right next to the Heishamon and connected via a thick, short wire. I tried several hardware solutions (STP grounded wire, ferrite beads, different PSU's, condensators to stabilize 5V), but the only solution so far has been to either turn off Opentherm in the settings or to disconnect it altogether.

In the terminal, I noticed that the Heishamon is receiving Opentherm data every second: image

My theory is that the Heishamon gets overloaded with Opentherm data from my thermostat, somehow messing up the timing. Any suggestions? Is there a way to limit the rate at which Opentherm data is processed?

jacco-hass commented 6 months ago

Just tested with a different thermostat (Remeha Celcia 20) and the S0 meters still show very high (erratic) power values.

IgorYbema commented 6 months ago

Limiting opentherm isn't possible. It is in the specs for opentherm to send at least one message each second (or something like that). Which version are you using?

Please try this firmware which is compiled with 160mhz cpu instead of 80mhz cpu speed.

HeishaMon.ino.d1_mini.zip

jacco-hass commented 6 months ago

My Heishamon was on the latest version (3.2.3), testing with the 3.2.4-beta that you sent delivers the same results. This is the history from last night, showing the noise on the S0-meter. I physically disconnected the thermostat at 10AM, after which the correct value (~500W) was shown. image

Let me know if there's anything I can test/measure to help diagnose the issue!

IgorYbema commented 6 months ago

Can you try this one? It disables all log messages about opentherm. So you won't see them in console also. Just to see if skipping the log_messages helps. HeishaMon.ino.d1_mini.zip

IgorYbema commented 6 months ago

Also please check the other value, Watthour, and get the difference over a few minutes. Then calculate it back to Watt (or just post it here so I can calculate it back to Watt for your) to see if the amount of pulses still is correct (if yes, then it is a timing issue, if there are too many pulses, there is a noise issue)

jacco-hass commented 6 months ago

Disabling the log messages didn't work, the high peaks are still there.

The average power seems allright, as you can see in this plot. Here, I disconnected the thermostat at ~10AM. image

IgorYbema commented 6 months ago

Yes looks like it. 500W is 0,5kWh each our and that is what the graph is showing also (maybe a bit more).

The watt is calculated by heishamon by counting the time between two pulses. A pulse is detected by an interrupt from the S0 input. But also the opentherm is interrupt driven. It looks like this messes up the timing for the S0. I'll try to find a solution but I don't think it is easy.

IgorYbema commented 6 months ago

Can you please also share your s0 settings in heishamon? pulses per second and the min and max pulse time?

jacco-hass commented 6 months ago

The pulse width is approximately 80ms. Average pulse width in Heishamon is 79ms, and I verified this with an oscilloscope: image

So I left the S0 settings at default, with 60/100 min/max and 1000 imp/kWh. When Opentherm is off, this works fine and the console reports very little bad pulses.

IgorYbema commented 6 months ago

Can you try to make the pulse gap larger? Set min. to for example 20 and max to 200. I'm guessing that it can't keep up with the 80ms pulse window and for example sometimes sees a pulse of 120ms wide. It will then ignore that pulse (because it is out of the window). It will however grab the last edge of the pulse for the start of the new pulse and therefore can count a pulse as a time between pulses and not the pulse itself (and a 80ms pulse 'gap' calculate to about 45kW, the high peaks you are seeing). Making the window longer might helpt.

In older versions heishamon only measured on a rising edge and didn't care about the falling edge (of a pulse). But that wasn't stable enough also, mainly in noisy situations.

IgorYbema commented 6 months ago

Also please test this test firmware. It changes to count on falling edges only. Maybe this is better in your situation. Please provide the result of this and the previous question (previous one about s0 pulse width chaging with running previous firmware without opentherm logging) HeishaMon.ino.d1_mini.zip

jacco-hass commented 6 months ago

3.2.4-beta (without OT logging), min 20 max 200: not working 3.2.4-s0-test, min 20 max 200: works 3.2.4-s0-test, min 60 max 100: works

So the last firmware you sent solved the issue for me! For your information, I'm using a 2 meter (properly shielded) S/FTP cable between the kWh-meters and the Heishamon, so there should be very little noise in my S0 lines.

IgorYbema commented 6 months ago

Great! Can you post a graph just for the comparison?

I'll think about how to add this change to the final code. Maybe a user switch to choose which S0 measuring algorithm is used. Ofcourse you can keep running this test firmware for now.

jacco-hass commented 6 months ago

This was the heat pump's power use last night, no noise at all and the power nicely corresponds to the total energy used!

Screenshot_20231218_084111_Home Assistant

One more thing: I was having some stability issues (random reboots every couple of hours), which seem to have been solved as well. It's a bit early to say, but it's been running for 16 hours continuously now. Thanks for your efforts!