# Pulse count with conditions

**URL:** <https://community.openenergymonitor.org/t/pulse-count-with-conditions/22969>\
**Category:** Emoncms\
**Created:** [26 February 2023 16:15 UTC](https://community.openenergymonitor.org/t/pulse-count-with-conditions/22969 "2023-02-26T16:15:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barry\_Osborne](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/barry_osborne/32/17817_2.png) [@Barry\_Osborne](https://community.openenergymonitor.org/u/Barry_Osborne)\
**Post date:** [26 February 2023 16:15 UTC](https://community.openenergymonitor.org/t/pulse-count-with-conditions/22969/1 "2023-02-26T16:15:56Z")

</div>

Hi all,

I have pv and battery storage so when the house load is supported by the solar or battery very little power is exported / imported so the error of the CT sensors can get quite large.

I thought I could use the pulse count but sadly my main electricity meter flashes on both import and export so here is my question.

I have the grid CT clamp spilt into two feeds with allow positive and allow negative (this get converted to a positive number with x-1)

Is there a way for me to use both the feeds and the count the pulses.

If CT grid import feed is \>0 then count pulses and add to a new feed grid import pulse.  
&  
If CT grid export feed is \>0 then count pulses and add to a new feed grid export pulse.

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [26 February 2023 16:36 UTC](https://community.openenergymonitor.org/t/pulse-count-with-conditions/22969/2 "2023-02-26T16:36:07Z")

</div>

> [@Barry\_Osborne](#):
>
> the error of the CT sensors can get quite large.

Do you mean the accumulated energy error can get quite large?

I think I’ve seen something like this - I can’t remember how long ago though. Worse still, I can’t think of a set of key words to search for.

I suspect it involved the “conditional” processes in emonCMS, which are only available in your local version, not in [emoncms.org](http://emoncms.org).

[Edit]  
It might have been this that I remembered:

> [@Large discrepancy between pulse counter and CT](https://community.openenergymonitor.org/t/large-discrepancy-between-pulse-counter-and-ct/10561/9):
>
> Now that you’ve got import-only readings from the pulse count readings, you should be able to compare these against the actual meter readings from the meter’s display. In a perfect world, they should match exactly slight_smile I have a meter that works the same way as yours, so I may try to replicate your setup.

---

<div class="post-metadata">

**Author:** ![Barry\_Osborne](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/barry_osborne/32/17817_2.png) [@Barry\_Osborne](https://community.openenergymonitor.org/u/Barry_Osborne)\
**Post date:** [26 February 2023 17:18 UTC](https://community.openenergymonitor.org/t/pulse-count-with-conditions/22969/3 "2023-02-26T17:18:06Z")

</div>

This is all being done locally on the pi, will have a look at the conditional unsure how to get a condition based upon another feed if that makes sense but will have a play around.

Sorry for posting in the wrong section.

---

<div class="post-metadata">

**Author:** ![Barry\_Osborne](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/barry_osborne/32/17817_2.png) [@Barry\_Osborne](https://community.openenergymonitor.org/u/Barry_Osborne)\
**Post date:** [26 February 2023 22:34 UTC](https://community.openenergymonitor.org/t/pulse-count-with-conditions/22969/4 "2023-02-26T22:34:20Z")

</div>

Been thinking about this I’m not sure this will work, I have a emonTH with the optical sensor attached as i dont have useable power by my meter. The emonTH stores the pulses and then send them every 60 seconds to save battery life so my condition will be potentially incorrect as when the pulses get sent the current grid import or export could have changed.

Will have to tune my CT sensors the old way…

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [26 February 2023 22:48 UTC](https://community.openenergymonitor.org/t/pulse-count-with-conditions/22969/5 "2023-02-26T22:48:35Z")

</div>

Ah, you didn’t mention the data wasn’t anywhere close to synchronous.

As you say, it’s the old way - a calendar, a pen and the individual registers on the meter.

You could tweak the emonTH sketch to send the pulse count much more frequently, but at the cost of battery life. If you say just under every 10 s, you should still get a few months from a set, which is probably enough to get a fairly close calibration on one set of batteries. (Then change it back to just under a minute.)
