Sorting by

×

Tasmota Energy Meter Pulse Output Counting

Summary

This monitoring was built as part of my whole house 3 phase monitoring project.

I had a couple of kWh counters (often called Check Meters) on my main and a sub board. Not as accurate, and can’t monitor V or power factor etc, but useful to look at targeted areas of power use as well as having their own LCD display on the unit itself. The ones I use give a pulse/contact output for every 2Wh of energy that passes though them.

The meters I used were Tanzini CM1D units bought locally (for SDoc compliance), but there are many imported versions. The ones I got were rated at 100A and 1 pulse per 2Wh.

My main use case is for monitoring my EV Charging but also a self contained unit on our house.

Tip: Unless you actual need a local display, I highly recommend using PZEM-004T devices instead as they are cheaper, much more accurate, can also monitor voltage and power factor and use no mains connections (current transformers instead).

Check Meter Pulse Measuring

Wiring

This same principal will apply for most pulse count meters (eg water/gas), but I just wired a GPIO on a Wemos D1 Mini (one I already had in a small switchboard) to the pulse count output on the meter, the other to 0v. I used a 10k Resistor to pull the GPIO high (to 3.3V, but 5V would likely be fine too according to Wemos literature).

So on every pulse, the meter pulls the GPIO low. The Wemos was flashed with Tasmota.

Check Meter Pulse Count GPIO Wiring
Simple wiring of the pulse meter to the Wemos

Tasmota Setup

Set the Tasmota GPIO to be a Counter eg Counter 1 (42) 

Now, the counter input will start counting up every time there is 2Wh of energy used (the check meter will also flash in unison). This would now be fine if you can use Node Red or Home assistant to further interpret that data, but there is more you can do in Tasmota itself if you’d like to get yourself an actual average “Watts” output, over say one minute.

Firstly, set the teleperiod to 1 minute on the console. This will help us get a Wh per minute number.

TelePeriod 60

Then set up a rule to push the value of the count to MQTT, then reset the counter… once per minute (don’t forget to turn on the Rule also)

rule1 on tele-counter#c1>=0 do 
	backlog publish stat/%topic%/EnergyMeterCount {"EVChargerWhCount":%value%} ; 
	counter1 0 
	endon 
 
rule1 on   

If you wanted to compile Tasmota and use a non standard build, there are some mathematical functions you could use to get an actual Watts value into MQTT. I prefer to stick to the standard build so I can update without issue, and I now have at least a value in MQTT that is a count of half the number of Watt hours used in the last minute (remember it gives a pulse for every 2Wh in this case)

This is fine for me as I use Grafana to display the results and Grafana allows some maths to happen before display so I can convert the Wh to Watts.

(W) = (Wh)/(h) or in this case W = 2x (Pulse count) / (1/60)

This is the grafana query I used, allowing for data every minute and 1 pulse every 2Wh:

Grafana Pulse Count Energy Wh

My basic grafana graph looks like this. More accuracy than a minute might be nice, and low power (ie less than 2Wh in a minute) will give some bumps in the graph, but this is perfectly acceptable to me.

EV Power Use