Power monitoring with an XTM18S and MQTT


#82

Hi @Pharizna , i ’ ve connected xtm18sa with Sonoff to my fuse box and finally it seems is working on HA.

However , i only see pulses on graphics at grafana and i don’t be sure it’s showing right data.

Is it necessary to create a template sensor to modify it with any mathematical function to achieve “real” values?


#83

Try using this configs on your graphs:

Capture


#84

Hi

You have to change Graphana graph line configuration in order to look “continuous” and not pulse… as @j.assuncao has just explained :slight_smile:

Your data seems good because with this configuration one count is equivalent to 120 w and for this reason you can see in your graph a lot of “0” values… and “120” because you are working at minimun of the scale.

You have to create (using templates) some function to “accumulate” data for days, month, etc… and also to reset this data hourly… monthly


#85

thanks @j.assuncao

I already had selected format you mentioned (actually i have cheched all possibilities):

I have no idea what else i can test


#86

thanks @Pharizna

That’s what i thought , but i’m affraid that’s my handicap (templates with math functions).

Is there any possibility to send my a little example in order to start working with?

Thanks in advance!!


#87

Here’s mine, I have fill(linear) in the GROUP BY

screenshot123


#88

Hello, then the cables that go to the wemos or the sonoff can be connected directly without the need of any resistance or logic converter?

Someone came to measure with the oscilloscope the volge of these pulses?


#89

Yes, i have mine running for almost one year without problems.


#90

Hello again,

This sensor measures the apparent power or only the active power (which is the one that matters)?


#91

It measures active power.


#92

Thanks @RoadkillUK

I have change it to fill(linear) and graphics looks more like i expected:

However, i’m still struggling with templates in order to get “real” consumption and cumulative values.

I can’t find any example code about this in HA forums .

I’m starting to think this is a secret (like “Coca-cola formula”…)


#93

Hi @Pharizna

I have ready access to a sonoff basic, do you have updated code for arduino idea, or does it only work with plat form io, I want to try this project with Sonoff, must just get a meter with a pulse output.

Regards
CN


#94

Hi,
Is there a need to alter the code when doing this with Sonoff, I have arduino ide, should I change to platformio.

Regards
CN


#95

No, you don’t need to change the code.


#96

I’ve connected with a standard jumper wire the 20 port to the D6 pin in the Wemos D1 mini while the 21 port to the ground pin.

@timseebeck How did you do this task without any soldering?


#97

[…] and this operation does not involve any soldering tasks.

Sorry, my bad :frowning: I’m assuming here that the wemos comes with pin headers already soldered which I don’t think it’s the usual case.


#98

On Aliexpress it’s not the case. But on Bangood, it is. But the price is not the same.


#99

Hello, thank you for your script.
I have only not the good current usage. Can it be that it is calculated by how many pulses there are in 1 minute? That is not realy accurate maybe you can change it so it can be caluted by the times between the pulses?


#100

Hi, thanks! Even if we count the time between two consecutive pulses we are not going ot have the good current usage: only in the precise moment when you get the pulse and do the calculation. Let’s remember this:

So, in summary, with this device we are not going to have an accurate current (or instantaneous) value of the consumed power. I prefer to do the calculations on a fixed time basis rather than on time-difference method because with the latter approach your measurement is not updated if there is no consumption (which will lead you to think that your appliance is ON while maybe it isn’t).


#101

Hi I tested it with a XTM18SA and a 60W bulb … but “Inst power 01” show me 240.00W
…it is 4 times the real consumption