# Directly connecting to Optical Pulse Counter with RPi?

**URL:** <https://community.openenergymonitor.org/t/directly-connecting-to-optical-pulse-counter-with-rpi/1294>\
**Category:** Getting Started\
**Created:** [17 August 2016 20:38 UTC](https://community.openenergymonitor.org/t/directly-connecting-to-optical-pulse-counter-with-rpi/1294 "2016-08-17T20:38:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pb66](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/pb66/32/27_2.png) [@pb66](https://community.openenergymonitor.org/u/pb66)\
**Post date:** [17 August 2016 21:39 UTC](https://community.openenergymonitor.org/t/directly-connecting-to-optical-pulse-counter-with-rpi/1294/2 "2016-08-17T21:39:16Z")

</div>

You can indeed use the optical pulse counter directly with a Pi.

I use a python script with 2 pulse counters, their data pins are connected to gpio pins 13 and 15, and are powered by pins 9 and 17 so that a simple 1x5 header socket could be plugged directly on the gpio pins (9-17 odds).

Rather than chop the rj45’s off the pulse counters I use a surface mount double rj45 socket with just 4 wires between the sockets and the Pi gpio.

The pulse counters are just a logic level switch, it just translates the light pulses to a distinct on or off signal. there is no baud as such although there is probably a maximum switching speed, but there is very little in the way of info on the shop sold device, We don’t even know what components are used. (hint hint @glyn.hudson can you share some tech info/schematic?)

[Edit: That information is now available here: [First try with EmonPi - Pulsecount stuck at 1 - #16 by Robert.Wall](https://community.openenergymonitor.org/t/first-try-with-emonpi-pulsecount-stuck-at-1/7375/16) - RW]

The python code I use sends an accumulating count for each pulse counter to emonhub via a web socket. It may not suit your needs exactly but should get you started at least, there are notes but do ask if anything is unclear.

[pulses.py.txt](https://community.openenergymonitor.org/uploads/default/original/2X/b/b7b150dec028e86f25d5a6e4b0a959e4a774448f.txt) (3.5 KB)

And here’s a couple of pic’s of 2 pulse counters in situ, you can see the double rj45 socket in the top left corner of the enclosure.

 ![](https://community.openenergymonitor.org/uploads/default/original/2X/0/067c393f93df2e1c69def7252aeddb24813071f3.jpg) ![](https://community.openenergymonitor.org/uploads/default/original/2X/c/c6666091fcd390d9a0834e14098f3a76207d3f7c.jpg)

---

_[View the full topic](https://community.openenergymonitor.org/t/directly-connecting-to-optical-pulse-counter-with-rpi/1294)._
