Directly connecting to Optical Pulse Counter with RPi?

I used surface mount Ethernet sockets and a few “jumper wires” with one end in the “punch down” connectors of the Ethernet socket box and the other loose ends I used a spot of super glue to make a 5pin header from the 5 single pole connectors to make the connection(s) more manageable when plugging onto the gpio.

Another “quick and dirty” method is to use rc.local, but this is less reliable and being phased out in Raspbian Stretch.

I think the basic settings would be

[[Pulse]]
        Type = EmonHubSocketInterfacer
        [[[init_settings]]]
                port_nb = 50012
        [[[runtimesettings]]]
                pubchannels = ToEmonCMS,
                timestamped = True

added to the interfacers section of emonhub and possibly an entry in the nodes section too, But I don’t use the same version of emonhub so I can’t easily define that off-the top of my head. Once you have the optical counter mounter and physically connected, with just the above settings in emonhub.conf and pulses.py running, you should get data appearing in emonhub.log and from there it should be easy to add a nodes definition and see the data arrive in emoncms.

An example would be something like

[[18]]
    nodename = pulsecounter
    [[[rx]]]
        names = pulsecnt1, pulsecnt2
        scales = 1, 1
        units = Wh, Wh

but I’m guessing a bit here and it will partially depend on any mods you make to pulses.py, the spec of your meter pulses and your choice of labels.

With regard to using multiple Pi’s you have options, although unless you have reason to do otherwise, I would recommend just changing the node id in one of the pulses.py scripts and use the same target host for both scripts to deposit their data into the same emonhub socket on the one device, just edit the host = "localhost" line to point the slave Pi’s pulses.py at the master Pi’s emonhub socket, using a fixed ip if needed.

As long as they are on the same LAN you need no other setting than possibly opening the “50012” port in the UFW firewall if it’s enabled on the master Pi.

??? I thought I was loosing my marbles, I couldn’t remember writing anything along these lines recently. That post was written a year ago! But thanks for linking, I had forgotten about that post and there are some useful links about gpio etc in there.

1 Like