January 11, 20197 yr 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.
January 11, 20197 yr 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 January 11, 20197 yr by Javi Martínez
January 11, 20197 yr 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 #InterrupcionesGPIO.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 January 11, 20197 yr by Javi Martínez
January 11, 20197 yr 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 January 11, 20197 yr by plonkster
January 22, 20197 yr Author @plonkster, So here is the GPIO of the Pi3B+ And here are the pre-configured pins: Are you saying if I configure this is Venus: 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 January 22, 20197 yr by phil.g00
January 22, 20197 yr 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).
January 22, 20197 yr Author @plonksterThanks, I didn't know it was floating. That's going to be very useful. l assume Pin 40 corresponds to "Relay" in the Venus remote console? How do you hook up to that?
January 22, 20197 yr Author Not for the particular venus setup, but as a generic example of an output and an input?
January 22, 20197 yr 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 January 22, 20197 yr by plonkster
January 22, 20197 yr 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.
January 22, 20197 yr 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...).
January 22, 20197 yr 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).
January 22, 20197 yr 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.
January 22, 20197 yr 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 January 22, 20197 yr by phil.g00
January 22, 20197 yr 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 January 22, 20197 yr by plonkster
January 22, 20197 yr 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 January 22, 20197 yr by phil.g00
January 28, 20197 yr 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.