Skip to content
View in the app

A better way to browse. Learn more.

Power Forum - Renewable Energy Discussion

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PI Hat for pulse meter

Featured Replies

I have my Venus PI up and running, wireless connected all that, so I am having a play.

It seems to me that the Venus software has the ability to count pulses ( granted it seems to geared towards flow rate meters).

But I can read m^3 units, and think kWh, so that's just a cosmetic annoyance.

I think that's great, I can have a record of some other nice-to-know loads around the place.

However if I understand correctly, there is no method of a nude Pi to directly read pulses?

It needs a hat right? ( And the right hat and pin out of where things are?)

Or is there a way of getting these pulses in/ or as a different medium or protocol.

Or do I need the Venus GX.

Be gentle, I only first touched a Pi in the last week.

I have never read pulses on a Pi. It has an OS, so I suppose It Will be hard to attack an interrupt. It would be easy read pulses with and Arduino and comunícate, PySerial, with Rpi.

Has the meter some protocol? RS485? In that case It would be possible to read with Pi.

Edited by Javi Martínez

I was mistaken. It seems it is easy, using python and Rpi:

import RPi.GPIO as GPIO
import os

contaA = 0
contaB = 0

#Setup
GPIO.setmode(GPIO.BCM)
GPIO.setup(23,GPIO.IN)
GPIO.setup(24,GPIO.IN)

#Callbacks
def CuentaA(channel):
    global contaA
    contaA += 1
    os.system("clear")
    print "Contador A: ", contaA
    print "Contador B: ", contaB

def CuentaB(channel):
    global contaB
    contaB += 1
    os.system("clear")
    print "Contador A: ", contaA
    print "Contador B: ", contaB

#Interrupciones
GPIO.add_event_detect(23, GPIO.RISING, callback = CuentaA)
GPIO.add_event_detect(24, GPIO.RISING, callback = CuentaB)


print "Contador A: ", contaA
print "Contador B: ", contaB

#Bucle principal
while(contaA < 5):
    pass

GPIO.cleanup()

 

 

 

In any case, "Mr Python -  Blue Wise Man" will explain better. @plonkster

Edited by Javi Martínez

1 hour ago, phil.g00 said:

It seems to me that the Venus software has the ability to count pulses ( granted it seems to geared towards flow rate meters).

I wrote that software. It's called dbus-digitalinputs and it is on github. You're welcome to steal some of the gpio handling code from there. It has some neat handler objects that implements a callable class that in turn acts as a generator (ie it looks like a list to the calling code, so you can iterate through the pulse events with a for loop). In the end it is just standard posixy code.

Venus has a init script that configures the gpios from a config file (because the different supported boards, there's like 5 already, has different GPIOs), but that is essentially these commands (assuming pin 5, consult a pinout to find where that is):

echo 5 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio5/direction

And then you can get the value of the pin by reading /sys/class/gpio/gpio5/value, and if you want to do it event-based you can monitor it with epoll.

Finally, venus already configures a number of pins on the Pi. I picked mostly pins that are not also used by other things (eg SPI).

There is no reason why this cannot work on any other Linux distro on the Pi.

Edit: Also remember that the Pi is 3.3V on the GPIOs.

Edited by plonkster

  • 2 weeks later...
  • Author

@plonkster,

So here is the GPIO of the Pi3B+

GPIO-From-Raspberry-Pi-3-B-model.png.7d25b90a2526357655877a572e7f0291.png

And here are the pre-configured pins:

823461685_GPIOPIvenus.JPG.191f7c7af597c27fe808ffe9bcc1092a.JPG

Are you saying if I configure this is Venus:

1425713729_pulsemeter.JPG.169d983632d43a4946d424ae58781cce.JPG

If I connect my pulse meter output between pin 1 and pin 29 (digital input 1), I will start to count pulses, as is?

Edited by phil.g00

2 hours ago, phil.g00 said:

If I connect my pulse meter output between pin 1 and pin 29 (digital input 1), I will start to count pulses, as is?

The pin is floating, so that alone is not going to do it. What I would do is connect the pulse meter between 29 and ground, and then put pull-up to 3.3V (a 10k resistor or similar). Of course you can also do a pull-down if you really want to, but this is closer to how the Venus-GX does it (it has pull-ups installed on the digital pins).

46 minutes ago, phil.g00 said:

Not for the particular venus setup, but as a generic example of an output and an input?

It looks good.

Re relay output, it goes high when the relay is on. Normally you use that signal to drive an NPN transistor which then switches a relay. Something like a 2N2222 with a suitable voltage divider on the base so as to not overbias the thing... normal analog stuff.

Edit: Well technically a transistor is a current amplifier, so "voltage divider" is nonsense... I mean some kind of resistor to limit current into the base. I'm sure you know this stuff, but it's been two decades for me... 🙂

Edited by plonkster

  • Author

Then it would seem this is the right hat, (at least for pulse counting).

https://www.modmypi.com/blog/how-to-use-modmypis-pud-hat

Now I should be able to monitor at least 5 loads separately using  something like these:

PS. Not to detract from the great feature you've introduced, but If you ever have re-visit/influence the code a "kWh" unit would be nice.

It seems an obvious omission.

600601460_pulsemetera.JPG.0bdfed283e0c41cd73a5f9d82c867715.JPG

16 minutes ago, phil.g00 said:

It seems an obvious omission.

It was deliberate. XP practice (not that we follow all of it, but some of it helps). When stuff becomes complex, it helps to ask what the simplest problem is that you're trying to solve: In this case the simplest problem that had to be solved was water pumps in African villages. That is literally what it is for (but of course then people started using it for pumps on boats and things like that...).

  • Author

If its purely personal records, I would've thought the unit could be a free field rather than a prescribed choice. 

I have set my lawnmower's speedometer to furlongs/fortnight. (Only joking, it doesn't go that fast or that often).

There was another reason for it, which has to do with internationalisation, and the idea that you split storage and presentation. The SI unit for volume is the cubic meter, so ideally you want to store values in cubic meters, and then multiply them by the required factor when you need to display them in heathen gallons (as opposed to imperial gallons.... just kidding).

So the correct solution to the problem is to add another pulse-counter device that actually measures electricity instead of water. And that simply wasn't done yet.

Also... the very early revisions actually had KWh as a unit... it was removed.

  • Author

I don't really understand the argument, but code is your area, not mine, so I'll take your word for it that sky will fall in.

(Don't worry, deep down, I'll know that I haven't turned a fire-hose on my DB).

Thanks for the feature.

 

Edited by phil.g00

10 minutes ago, phil.g00 said:

I don't really understand the argument, but code is your area, not mine, so I'll take your word for it that sky will fall in.

It's more like my brain will implode if another complexity is added 🙂

The software emulates a device (it shows up in the device list on the other side, etc), so presently you can configure a digital pin to be a pulse meter or some kind of alarm. All that is needed is another option in that list. That kind of device will then have Kwh as an option. It will likely be an exact copy of the PulseCounter class... with suitable parts overridden :-)

Edit: Also, there is the risk that some genius might want this kind of meter to show up as an energy meter so it can be used for that kind of function (eg as a grid limiter) and that would not only be an exceedingly bad idea (because the flashes get kinda slow around zero... which would make it inaccurate), it will likely blow cause weird support issues... and we hate those 🙂 That is to say, quite often, something is left out simply because we don't want to deal with it (yet).

Edited by plonkster

  • Author
12 minutes ago, plonkster said:

Edit: Also, there is the risk that some genius might want this kind of meter to show up as an energy meter so it can be used for that kind of function (eg as a grid limiter) and that would not only be an exceedingly bad idea (because the flashes get kinda slow around zero... which would make it inaccurate), it will likely blow cause weird support issues... and we hate those 🙂 That is to say, quite often, something is left out simply because we don't want to deal with it (yet).

This is a reason that makes sense. And that's what I thought.

How about a unit called"units"?

 

Edited by phil.g00

  • Author

@plonkster, I also think there is a legitimate place for integrated or an aggregate kWh amount to be incorporated into the Venus software and not just for record keeping.

Here is a future feature that I reckon there is already a swelling demand for, and that is a nett zero power sale over time.

For example, the attempt of the system to balance power in (or cost) with power out (or sales),  in between meter readings. 

Might not apply to ZA, but elsewhere it will.

So Victron shouldn't miss a trick and not anticipate this coming. 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.