# Adjusting sensitivity of Optical Pulse Sensor

**URL:** <https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399>\
**Category:** emonTx\
**Created:** [30 August 2018 04:47 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399 "2018-08-30T04:47:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kempson](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/k/fbc32d/32.png) [@Kempson](https://community.openenergymonitor.org/u/Kempson)\
**Post date:** [30 August 2018 04:47 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/1 "2018-08-30T04:47:16Z")

</div>

I’m a relatively new user of OpenEnergyMonitor gear, and so far it’s absolutely brilliant apart from 1 problem. I have an emonTx with Optical Pulse Sensor and it works fine, however I’ve just purchased an emonTH with a similar Optical Pulse Sensor and the sensor is extremely sensitive. It records multiple random counts for only one light pulse - the led is permanently on when in semi-shade (compared to the emonTx sensor which is only ever on when the electricity meter flashes). The emonTx/TH hardware is identical as far as the sensor is concerned (ie direct connection to PD3/INT1 on the ATMEGA328). Does this sound like a dodgy sensor, or is there a config variable that needs to be changed? An external pull-up or pull-down resistor maybe?

---

<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:** [30 August 2018 08:31 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/2 "2018-08-30T08:31:33Z")

</div>

There is certainly no configuration variable available. The optical “pulse” sensor is actually a linear device, that’s just overdriven (despite mention of “TTL” etc in the description), and sadly all the information we have is published, I think on the shop page, if not there’s a blog post somewhere.

The only suggestion I can make is you put a hood over the meter. When investigating (very briefly), I found that light was leaking in via the hook-and-loop tape of the fixing. But this (depending on your meter) might not be the only path for ambient light to get in.

(A multimeter reading voltage and hung on the output could be useful while you experiment.)

---

<div class="post-metadata">

**Author:** ![Kempson](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/k/fbc32d/32.png) [@Kempson](https://community.openenergymonitor.org/u/Kempson)\
**Post date:** [30 August 2018 09:30 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/3 "2018-08-30T09:30:04Z")

</div>

Thanks - I took some extra precautions to shield out ambient light and it looks ok now. I’ll also experiment with an extra external pull-up resistor - ie the sensor will need to be driven harder (more light) to reach the same threshold voltage, albeit at the expense of increased current drain

---

<div class="post-metadata">

**Author:** ![danbates](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@danbates](https://community.openenergymonitor.org/u/danbates)\
**Post date:** [30 August 2018 11:40 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/4 "2018-08-30T11:40:18Z")

</div>

I found a pull-down on the signal line worked rather than pull-up. Also, a 0.1uF capacitor can help with debouncing.

---

<div class="post-metadata">

**Author:** ![Bill.Thomson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/bill.thomson/32/1834_2.png) [@Bill.Thomson](https://community.openenergymonitor.org/u/Bill.Thomson)\
**Post date:** [30 August 2018 12:46 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/5 "2018-08-30T12:46:55Z")

</div>

> [@danbates](#):
>
> Also, a 0.1uF capacitor can help with debouncing.

Debouncing is associated with mechanical switch contacts.  
The capacitor is acting as a spike suppressor. 😉  
Same _results,_ different name.

---

<div class="post-metadata">

**Author:** ![danbates](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@danbates](https://community.openenergymonitor.org/u/danbates)\
**Post date:** [30 August 2018 13:06 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/6 "2018-08-30T13:06:48Z")

</div>

Aha, you are right. I related the term to the digital input, which is not a correct use 🙂  
Filtering the input is more accurate.

---

<div class="post-metadata">

**Author:** ![Kempson](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/k/fbc32d/32.png) [@Kempson](https://community.openenergymonitor.org/u/Kempson)\
**Post date:** [30 August 2018 22:48 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/7 "2018-08-30T22:48:26Z")

</div>

Sweet - hadn’t thought of a filter. Will try that and let it run few a few days then compare pulse counts to the meter readings. Thanks for the help

---

<div class="post-metadata">

**Author:** ![danbates](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@danbates](https://community.openenergymonitor.org/u/danbates)\
**Post date:** [31 August 2018 06:06 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/8 "2018-08-31T06:06:56Z")

</div>

It probably won’t be what makes the most difference, but it I know it would have helped for the setup I had on an Elster.  
I had to enable 130ms worth of ‘software debouncing’ to get reliable pulse counts. Equivalent to a small cap, thus, I’d recommend a cap.  
It could’ve been the power cables near my optical sense lead were giving off a lot of noise, I’m not sure of why my setup needed so much ‘software debouncing’.  
Seems like light leakage could have been your problem, out of interest, is there anything near your cables that could be giving off lots of noise?

---

<div class="post-metadata">

**Author:** ![Kempson](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/k/fbc32d/32.png) [@Kempson](https://community.openenergymonitor.org/u/Kempson)\
**Post date:** [31 August 2018 06:28 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/9 "2018-08-31T06:28:11Z")

</div>

Thanks - looks like there were a few problems which are all now resolved:

1. Light leakage - being more careful with installation is the answer.
2. Noisy connection - just moving the emonTH from the workshop to the meterbox caused thousands of pulses. Wiped the (new) RJ45 plug in it’s socket a dozen times and now perfect.
3. Multiple pulse counts - only evident when ‘testing’ with a torch, but left me feeling a bit nervous. A 0.1 uF cap from IRQ to ground improved it, but fully resolved when a 33 k external pull-up resistor was added as well.  
Nothing obviously noisy too close, however a meter box will never be the best environment for what is effectively an unshielded lead running directly to an unisolated interrupt.

---

<div class="post-metadata">

**Author:** ![danbates](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@danbates](https://community.openenergymonitor.org/u/danbates)\
**Post date:** [31 August 2018 06:48 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/10 "2018-08-31T06:48:24Z")

</div>

Great stuff.

I’m interested in this pull-up/down situation now, as I used a pull-down on my signal line. My reasoning was that it’s normally meant to have no output, and then _driven high_ by a light event. A pull-up would increase the sensitivity. Now I’m confused again about my setup 🙂

I notice in the emonTH v1.5 hardware there’s no pull-up/down on the board. In the firmware the internal pull-up is enabled, so the signal line is being pulled up. @glyn.hudson design the board? Anyone else got any info on this?

---

<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:** [31 August 2018 09:48 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/11 "2018-08-31T09:48:22Z")

</div>

Glyn has tried to get more information - as I mentioned. If you search carefully, you’ll probably find his post about it, with a photo of the inside of the sensor. Short of taking one apart completely to find out what components are inside and drawing out the circuit diagram (even if that’s possible), it seems that no more definitive information will be forthcoming.

The only alternative that I can think of is to do a ‘black box’ series of tests on it and from that develop an equivalent circuit that behaves more or less the same way.

---

<div class="post-metadata">

**Author:** ![danbates](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@danbates](https://community.openenergymonitor.org/u/danbates)\
**Post date:** [31 August 2018 11:24 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/12 "2018-08-31T11:24:39Z")

</div>

That makes sense. Thank you.

Found one page, but it doesn’t reference the sensor we’re currently using.

[https://openenergymonitor.org/forum-archive/node/79.html](https://openenergymonitor.org/forum-archive/node/79.html)

---

<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:** [31 August 2018 13:23 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/13 "2018-08-31T13:23:49Z")

</div>

The picture is now on the shop page, but I’m reasonably certain there were words with it saying that Glyn had tried to find more information, but the supplier/manufacturer was not cooperative.

---

<div class="post-metadata">

**Author:** ![danbates](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@danbates](https://community.openenergymonitor.org/u/danbates)\
**Post date:** [31 August 2018 16:45 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/14 "2018-08-31T16:45:18Z")

</div>

Can’t find it. I tried various search methods.

---

<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:** [31 August 2018 16:48 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/15 "2018-08-31T16:48:02Z")

</div>

I know I’ve seen it - it was when it was introduced into the shop. It probably became a casualty of the move to Discourse.

Incidentally, enabling the internal pull-up of the interrupt input prevents spurious triggering in the absence of a connection, and bear in mind any mechanical switch can also be used, which will require a pull-up or pull-down, depending on how the switch is wired.

---

<div class="post-metadata">

**Author:** ![danbates](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@danbates](https://community.openenergymonitor.org/u/danbates)\
**Post date:** [31 August 2018 17:15 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/16 "2018-08-31T17:15:15Z")

</div>

I don’t doubt you. Must be around somewhere.

I think enabling the pull-down would do the same?

---

<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:** [31 August 2018 18:33 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/17 "2018-08-31T18:33:04Z")

</div>

According to the device data sheet, there is only an internal pull-up.

---

<div class="post-metadata">

**Author:** ![danbates](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@danbates](https://community.openenergymonitor.org/u/danbates)\
**Post date:** [1 September 2018 06:09 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/18 "2018-09-01T06:09:42Z")

</div>

You have a data sheet? What Chinese vault did you break into for that? 🙂

So a pull-up inside the device might mean it works off the back of a conventional LDR.

I’ll revisit this in the future… Keen to test the effect of a pull-up vs pull-down.

---

<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:** [1 September 2018 11:38 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/19 "2018-09-01T11:38:12Z")

</div>

The Atmel one - and **_I_** didn’t think it was Chinese. I’m talking about

> [@danbates](#):
>
> I notice in the emonTH v1.5 hardware there’s no pull-up/down on the board. In the firmware the internal pull-up is enabled, so the signal line is being pulled up. @glyn.hudson design the board? Anyone else got any info on this?

---

<div class="post-metadata">

**Author:** ![danbates](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@danbates](https://community.openenergymonitor.org/u/danbates)\
**Post date:** [1 September 2018 11:54 UTC](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399/20 "2018-09-01T11:54:52Z")

</div>

Oh! I thought you meant the sensor internals 🙂

OK good to know…

[Next page](https://community.openenergymonitor.org/t/adjusting-sensitivity-of-optical-pulse-sensor/8399.md?page=2)
