Power monitoring with an XTM18S and MQTT

Hi, I have no problems connecting directly to the Wemos and it never gave me any trouble for this last few months. If you look at the first post on this thread, the original project is connected the exact same way. The pulse is very short (90ms i think) and <= then 27mA.

1 Like

ok very short but very high! 36V!
Other proiect use a resistance.
Have you measured the VOUT?


No, i didn’t measure. If you’re worried about that just put a resistence.

1 Like


I don’t know what happens… but without any change IT’S WORKING FINE including web server… in a SONOFF BASIC, of course :slight_smile:

THANK YOU! :hugs:

Your welcome @Pharizna! I’ll include the Sonoff Basic in the list of compatible boards.

P.S: Can you please send a photo of the connections you’ve made on the Sonoff?

1 Like

Of course :slight_smile:
Here it is a “sketch” from our friend @Lantzi

Last question

In your code your are using

define PULSE_FACTOR 1000

But for the XTM18S the ratio is 2000 pulses / kWh


You should change the value of PULSE_FACTOR to 2000 or it will count the double…

1 Like

I did it. It was only to confirm it

Thank you


Yes, directly. I used it for a whole week without issues but I understand your concern. I am aware of my limitations and that’s why I included a disclaimer in my post.

No. Since the pulse is so short, I guess we should measure with an oscilloscope, which I don’t own. I suposse my standard voltimeter is not appropriate for such dynamic signal.

@j.assuncao , thanks for sharing your code in github. It has plenty of features! Nice work!

@Pharizna , thanks for the feedback with the SonOff. Just out of curiosity, are you using it for overall home electricity consumption?

1 Like

Of course :slight_smile:

It’s my main goal … but previously I’m testing the system measuring only single “external” devices and then I’ll connect in my home fuse box :sweat_smile:

1 Like

@Pharizna, be carefull when you connect the XTM to the fuse box. You have to use a model suited to your total consumption in terms of Amps.


Thank you Jorge

My home main disjuntor is 25A and my XTM18S current range is 0.25 - 32A

1 Like

hi, this is the project i was looking for. i’ve ordered today 1 xtm18sa (with lcd display and 50A), my goal is to monitor entire apartment consumption. i live in italy with 3 KWh of max consumption and 25A of fuse box.

I’ve wemos d1 and nodemcu availables.

it’s possible to connect this to emoncms? it’s an opensource project with apis avaibles and their own equipment also use esp8266 to connect to emoncms. thanks and sorry form my bad english :slight_smile:

hi, @hangy! I don’t know if it’ll work with EmonCMS because i don’t use it but HA can connect to it. Probably if you send the readings to EmonCMS from HA it is possible.

1 Like


I’ve just installed the “device” to monitor my home consumption … and it’s working

1 Like

Wow, that’s awesome. Definitely, I have to take a look at Grafana. Congratulations!
Did you put the device in the electric box at the entry of your house? (¿en el cuadro eléctrico a la entrada de casa? :slight_smile: ). Did you ask for help to a professional?

@Pharizna Great work! With some math (and sensor templates) you can get other values like Apparent Power (kVA) and Current (A). I’m also using a couple of automations to get daily and monthly consumption.

@timseebeck If you know a little about electricity you can do it yourself. It’s really not a big deal…

I’m now working on a new version of the meter that uses the ACS712 AC current meter to be use on extension sockets for example.

1 Like

@timseebeck It’s very easy. The only problem was the small holes for the ‘big ‘ power cables (…y ahí es donde se nota que el XTM es un producto chino)

@j.assuncao When are you thinking about to have the templates, etc? Do you know how to ‘write’ a new valor in energy accumulated? I would like to have the same value in my HA as in the official meter of the electric company :slight_smile:

I’ve bought an equivalent for the XTM18S. It’s a ORNO OR-WE-501 (Polish concept, but also made in China), with digital display, that can handle power cables with a max. of 6mm2. Are your cables bigger than that??

Do you mean the sensor templates for Current and Apparent Power? I can post then here if you want.

1 Like