question

dunnp avatar image

RPi GPIO digital inputs and relay outputs?

Hi

Does anyone know what GPIO ports are used for the digital inputs and for the relay outputs on a RPi to replicate the functionality of a real Venus?

I've trolled through all the sites I can think of and come up blank. Anyone cracked it?


Any guidance greatly appreciated.

Cheers

Phil

Venus OSRaspberry Pi
10 |3000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

4 Answers
dunnp avatar image

Analog and digital I/O working!

Big thanks to Rob Duthie for helping me get the analog inputs showing on the Venus console.

I have a bit more work to do to get the correct sensors and proper values displayed - and most likely a few more questions for the experts out there.

But for now I'm happy to say that it is possible to utilise the five digital inputs, the relay output (only one) and have 5 analog inputs connected to the Venus-RPi system.


Cheers

Phil

3 comments Share
10 |3000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi, is there any documentation on how you got this working? I want to connect digital tank senders to the RPi.

dunnp avatar image dunnp Rob Mitchell ·

Hi Rob

I don't have much useful info; I just muddled through various posts and asked lots of questions to get mine working. But much of it is irrelevant now.

At the time it was a long convoluted process to get the analog inputs working - had to add a lot of dbus-adc stuff. But the latest Venus firmware (v2.53) has it all included and everything can be configured on the remote console without having to delve into command line stuff.

To be clear, the tank sender functions in Venus are analog and assume a resistive tank unit. Originally they had to be either US spec (240-33 ohm) or Euro spec (0-180 ohm) but now the resistance settings can be tweaked in the console to suit non-standard senders. Big improvement and big thanks to Victron for adding this.

The digital inputs are purely logic levels - on, off or pulse. I'm not sure what 'digital tank senders' you have but the digital inputs aren't the place to connect them if they are RS485, Canbus or similar.

Back to the analog inputs (for completeness), now that all the software side is included, the only remaining challenge is to add the MCP3208 ADC chip and the resistor networks on each input. Just a matter of following the wiring diagrams available on GitHub - can't recall where.

Cheers

Phil

Hi

As per my schematic, all works as per the Venus software and pin outs etc.

Just need to add a few files to Uboot in the root directory etc and you are done

Note: we have full update path that required no SSH commands to add files etc

There is script file written which takes care of this now, i have all the information required to do this automatically, email me for details.

Victron Raspi Hat.pdfVictron Raspi Stetson.pdf


Regards

Rob D

NZ

Rob Duthie avatar image

Yes all confirmed being running for some time now all the analog and digital ports.

9 comments Share
10 |3000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi Rob

Have you cracked the analog inputs? I tried bread-boarding an MCP3008 ADC as per some stuff I found on the web but the 'Analog Inputs' on the console remained vacant,

Do you know if there any tricks to getting the ADC talking to VenusOS? I have a list of the analog input channels and think I have the SPI wiring to the Pi sorted but obviously I'm missing something.

Cheers

Phil

Have you loaded in the ADC file into the Venus directly ?ADC _GPIO_ Relay ports config notes for Raspi Venus.txt

File instruction attached.

And ADC file to install.


Regards

Rob D

NZ

Hi again Rob

I did look at that file and tried the suggestion but on my system there is no /sys/bus/iio directory. I looked in most of the other directories but couldn't find anything that looked like analog voltage stuff.


I'm running v2.40-34 in my 'play' system but I looked in my v2.33 'live' system and couldn't find that /iio directory either.

How does that directory get created? Do I need to install something to create it?


Cheers

Phil

Hi Phil

When you type in this command in the root directory you get nothing?
ls -al /sys/bus/iio/devices/iio\:device0/

What is in your boot config file

The line in config.txt should read "dtoverlay=mcp3208:spi0-0-present"

Then the ADC file is not installed etc

Add the dbus-adc file to the opt/victronenergy folder which was attached to the last post.

You can use Bit vise to do this easily

Regards

Rob D

NZ

HI Rob

No, noting works because there's no /iio directory in /sys/bus - I just get a 'no such file or directory'.


I've done a lot of web searching and the recipe you attached comes up a lot - but it seems to refer to the Beaglebone version. So I'm wondering if it's not compatible with RPi's?. Obviously something is missing in the RPi version - that /iio directory.


I also hunted everywhere I could think of for the dbus-adc file and came up blank. Any tips on how and where to get it?

I looked everywhere in the RPi and found nothing remotely like a reference to any adc or analog devices. I got a bit lost in GitHub so perhaps it's lurking somewhere there? (I looked at the AB Electronics github site but there's no 'git' command in my system so couldn't try any installs).


I really appreciate your help - I'm still on the learning curve so sorry for the dumb questions.

Phil

(PS - My system is a RPi 3B-plus running v2.40-34)


Hi Phil

It works OK with the Raspi OK as that is what i use only.

I attached the ADC file to the last post which you insert in to the

Adding ADC files and commands.
#chmod 755 both scripts. these are permission to set for the files.

Install dbus-adc file into /opt/victronenergy/ (not required installed with the packages Rocko) install via Bitvise the file ( dbus-adc )

chmod 755 /opt/victronenergy/dbus-adc/start-adc.sh
chmod 755 /opt/victronenergy/dbus-adc/dbus-adc
chmod 755 /opt/victronenergy/dbus-adc/service/run
chmod 755 /opt/victronenergy/dbus-adc/log/run Added to file so don't need to do !!!(need to add a folder called log and a file called run inside it) if missing?
ln -s /opt/victronenergy/dbus-adc/service /service/dbus-adc (symlink command to link the files together)
touch /var/log/dbus-adc (sets time stamp of the file or created one)

Regards

Rob D

NZ

Rob

No Dbus-adc file attached, just the instruction txt file.


Phil

OK it did not like the file upload, do you have a email address i can send it to?

Regards

Rob D

NZ

Show more comments
dunnp avatar image

Michael

Almost by accident I stumbled on a file in the VenusOS called /etc/venus/gpio_list last night. It suggests the ports are as follows:


Relay 1 - GPIO 21 Pin 40 (only one relay apparently)

Digital input 1 - GPIO 5 Pin 29

Digital input 2 - GPIO 6 Pin 31

Digital input 3 - GPIO 13 Pin 33

Digital input 4 - GPIO 19 Pin 35

Digital input 5 - GPIO 26 Pin 37


I haven't had a chance to test yet but looks promising.

Phil




1 comment Share
10 |3000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Success!! The digital inputs work as per the pin-outs.. I used a 10K pull-up resistor from the 3V3 supply then pull the pin to ground with a switch.

The relay output also works. I drove a LED from pin 40 to ground via a 1K resistor (ie active high).

Michael Schmidt avatar image

Same qestion to me.

is it even possible?

Share
10 |3000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.