RPi pulse import

I am putting together an energy monitoring system for a site with 20+ meters and some PV.

One point has 6 meters in a cupboard together. To reduce the amount of hardware, I am attempting to use one Raspberry Pi  to record the pulses and upload to emoncms via wifi. Has anyone done this? I have read the post about 12 pulse imports with Arduino but this seems like an overly complicated solution. I am hoping the RPI with its extra processing power (and cheap wifi) will be able to handle everything.

Any thoughts or comments?

dBC's picture

Re: RPi pulse import

Linux allows user-level access to the GPIOs via sysfs, including configuring them as interrupt sources.  Your user level process can then put itself to sleep until there's a change.  It's not quite as real-time as attaching your own ISR to the hardware, but depending on the expected event frequency could well be real-time enough.  There's a good tutorial here:  https://www.ridgerun.com/developer/wiki/index.php/How_to_use_GPIO_signals

William's picture

Re: RPi pulse import

I have started a python code to run on the RPi that uses interrupts (http://raspi.tv/2013/how-to-use-interrupts-with-python-on-the-raspberry-...). My concern is that upload side will be disturbed by the interrupts.

dgoadby's picture

Re: RPi pulse import

If you are using Raspian on the RPI then it is easy to handle I/O interrupts from Python.

As you have a lot of inputs to manage you might be better creating some extra logic to take the 20+ inputs and then create a single interrupt routine which reads the state of the inputs to see which ones are active.

One idea is to reduce the inputs using a 8 input encoders. These will reduce each set of  8 lines to 4 (binary to hex). With chip enables, all of the encoders can be read using the same 4-bit port. The interrupts share one RPI input port using a wired-or.

The ISR would select the encoders in turn to get the input states. From one interrupt the ISR would use just three reads to check 24 inputs. If you keep a copy of the last read state then, at each interrupt, you can see which input has changed.

There are other schemes that would work here too but this ome is simple and involves easy to debug hardware.

Well that's my threepeneth.


David Goadby, North Wales.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.