Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drastically wrong power reported when there is few pulses #48

Open
nbasse opened this issue Nov 24, 2019 · 13 comments
Open

Drastically wrong power reported when there is few pulses #48

nbasse opened this issue Nov 24, 2019 · 13 comments

Comments

@nbasse
Copy link

nbasse commented Nov 24, 2019

Wrong power is being reported when there is a low load in the system making it take longer time between the light pulses on the meter.
For example, when there is 250-350W being consumed, the EspSparsnasGateway reports 10-20W, (with 100 pulses/Kwh for the meter, therefore approximately 3 minutes between the pulses).
But higher loads, for example, 2000w gets reported correctly.

Attached serial log shows first an apartment at approx 300w, then a kettle is turned on raising the power to above 2000w and then it is turned off again.
(Most of the bad packets received have been filtered away to make the log shorter.)

debug_log.txt

@nbasse
Copy link
Author

nbasse commented Nov 24, 2019

After performing more experiments, I have found the breaking-point to be somewhere between 599W (still working) and 557W (not working)

(All "real" values are from the original Sparsnäs display)

@riksarchen
Copy link
Contributor

I think the problem is not the decoded power but the number of pulses within a timespan.

Your setup was 100 pulses per kWh, Confirm?

@nbasse
Copy link
Author

nbasse commented Nov 24, 2019

Yes, that is correct. 100 pulses /KWh

@bphermansson
Copy link
Owner

I've added a function to print raw power values to the serial port. Not tested.

@nbasse
Copy link
Author

nbasse commented Nov 28, 2019

I've added a function to print raw power values to the serial port. Not tested.

Not sure how I can test this. I am currently using @riksarchen fork as it has some tweaks to make it work with the board he deigned.

Some sort of raw values are already being printed, (see the log in my first post) are these different from the ones you added?

@fredrike
Copy link
Contributor

@nbasse, we need to see your data4 value for the low power mode, but I suspect that we might have a case of data4 = 3 which is not covered in the code..

float watt = power * 24;
int data4 = TEMPDATA[4]^0x0f;
// Note that data_[4] cycles between 0-3 when you first put in the batterys in t$
if (data4 == 1) {
watt = (3600000.0f / float(PULSES_PER_KWH) * 1024.0f) / float(power);
} else if (data4 == 0) { // special mode for low power usage
watt = power * 0.24f / float(PULSES_PER_KWH);
}

@nbasse
Copy link
Author

nbasse commented Mar 30, 2020

@fredrike
Data4 seems to be 1 at higher loads when everything is working and 0 when at lower loads when wrong power is being reported.

Seq 18017: 1585594856, 624.72 W, total: 1190 kWh, battery 100%, rssi -108dBm. Power(raw): 59009 Vcc: 2993.00mV, Data4: 1

Seq 17972: 1585594181, 17.95 W, total: 1190 kWh, battery 100%, rssi -123dBm. Power(raw): 7478 Vcc: 2993.00mV, Data4: 0

@fredrike
Copy link
Contributor

fredrike commented Mar 31, 2020

Data4 seems to be 1 at higher loads when everything is working and 0 when at lower loads when wrong power is being reported.

Great! What is the consumtion with Data4 = 0 and Power(raw) = 7478 ?

I.e., what formula should we use for that case? Perhaps try to extract 10 values and corresponding values from the display.

@nbasse
Copy link
Author

nbasse commented Mar 31, 2020

Yes, started doing this yesterday, but only had the time to get 5 or 6 value pairs. And since the original display only shows whole watts, I think some more values would be good to get a better formula.

I started by fitting a straight line to the values. but I'm not sure where I should add the parameter for pluses/KWh. I will look into this more later today or tomorrow and try to get some more readings.

@fredrike
Copy link
Contributor

I started by fitting a straight line to the values. but I'm not sure where I should add the parameter for pluses/KWh. I will look into this more later today or tomorrow and try to get some more readings.

Just post the readings here and I can try to find the factor for you.

@nbasse
Copy link
Author

nbasse commented Apr 1, 2020

OK, Here are some readings!
watt =[ 508 466 456 460 465 465 468 200 171 150 141 133 120 114 184 268 263 291 353]
raw = [4530 4934 5042 5003 4946 4948 4913 11501 13421 15341 16301 17261 19181 20055 12471 8575 8730 7895 6512]

Apparently it is not a linear relationship between the value pairs as I expected.
See attached plot
data4_0_valuepairs

@nbasse
Copy link
Author

nbasse commented Aug 1, 2020

I have now fitted a exponential model to the values I recorded and extracted some coefficients.
I have successfully added it to the code and get good values even when data4 = 0. See nbasse@9f872e2

I'm not sure if I correctly accounted for the number of pulses. So someone with a value other than 100 should try this to see if it is correct.
(Or maybe someone can just double-check the math? I just multiplied the value I got for C_a with 100 and then divided the calculated power with the number of pulses. Not sure if this is correct for all cases.)

@fredrike
Copy link
Contributor

fredrike commented Aug 2, 2020

Great job!

I suggest that you send this as a pull-request so @bphermansson can merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants