question

dunnp avatar image
dunnp asked

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
2 |3000

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

4 Answers
Michael Schmidt avatar image
Michael Schmidt answered ·

Same qestion to me.

is it even possible?

2 |3000

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

dunnp avatar image
dunnp answered ·

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
2 |3000

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

dunnp avatar image dunnp commented ·

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).

0 Likes 0 ·
Rob Duthie avatar image
Rob Duthie answered ·

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

11 comments
2 |3000

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

dunnp avatar image dunnp commented ·

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

0 Likes 0 ·
Rob Duthie avatar image Rob Duthie dunnp commented ·

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

0 Likes 0 ·
dunnp avatar image dunnp commented ·

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

0 Likes 0 ·
Rob Duthie avatar image Rob Duthie dunnp commented ·

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

0 Likes 0 ·
dunnp avatar image dunnp Rob Duthie commented ·

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)


0 Likes 0 ·
Rob Duthie avatar image Rob Duthie dunnp commented ·

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

0 Likes 0 ·
dunnp avatar image dunnp Rob Duthie commented ·

Rob

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


Phil

0 Likes 0 ·
Rob Duthie avatar image Rob Duthie dunnp commented ·

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

Regards

Rob D

NZ

0 Likes 0 ·
dunnp avatar image dunnp Rob Duthie commented ·
0 Likes 0 ·
Marcel avatar image Marcel Rob Duthie commented ·

Hi Rob, I'm sruggeling with a expander Pi hat, and am looking for that dbus-adc file.

Would you please be so kind as to share it via email? briebelbus@gmail.com.

I noticed that the website of mbcshop is down. Do you have any idea if they will be back

thank you in advance.

regards,

Marcel

0 Likes 0 ·
Rob Duthie avatar image Rob Duthie Marcel commented ·

Hi

Sent via email a zip folder.

Regards

Rob D

NZ

0 Likes 0 ·
dunnp avatar image
dunnp answered ·

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

4 comments
2 |3000

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

Rob Mitchell avatar image Rob Mitchell commented ·

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

0 Likes 0 ·
dunnp avatar image dunnp Rob Mitchell commented ·

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

0 Likes 0 ·
Rob Duthie avatar image Rob Duthie dunnp commented ·

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

0 Likes 0 ·
yuwire avatar image yuwire Rob Duthie commented ·

@Rob Duthie are you making this HAT?

0 Likes 0 ·