ls -al /sys/bus/iio/devices/iio\:device0/ (to see loaded values) cat /sys/bus/iio/devices/iio\:device0/in_voltage4_raw ( to see only one channel loaded e.g voltage4) cat /sys/bus/iio/devices/iio\:device0/in_voltage[0-7]_raw (display all channels) Script to read ADC channels every second, ctrl C to stop reading. while true; do for i in 0 1 2 3 4 5 6 7; do echo -n "adc[${i}]: " cat /sys/bus/iio/devices/iio:device0/in_voltage${i}_raw done echo "" sleep 1 done root@RaspPi2:~# ls /sys/bus/iio/devices/iio\:device0 dev in_voltage3-voltage2_raw in_voltage7-voltage6_raw in_voltage-voltage_scale in_voltage3_raw in_voltage7_raw in_voltage0-voltage1_raw in_voltage4-voltage5_raw in_voltage_scale in_voltage0_raw in_voltage4_raw name in_voltage1-voltage0_raw in_voltage5-voltage4_raw of_node in_voltage1_raw in_voltage5_raw power in_voltage2-voltage3_raw in_voltage6-voltage7_raw subsystem in_voltage2_raw in_voltage6_raw uevent root@RaspPi2:~# ./read_adc.sh (without ADC connected) This command might not work for our application use the one at the top. ADC[0]: 0 ADC[1]: 0 ADC[2]: 0 ADC[3]: 0 ADC[4]: 0 ADC[5]: 0 ADC[6]: 0 root@RaspPi2:~# ./read_adc.sh (with ADC board connected) ADC[0]: 6 ADC[1]: 5 ADC[2]: 1999 (tank3) ADC[3]: 1999 (temp2) ADC[4]: 1997 (tank1) ADC[5]: 1998 (temp1) ADC[6]: 1996 (tank2) ADC[7]: 4 (does not exist on beaglebone) Pi Expander ADC ADC[1]: # N/A Tank4 ADC[2]: # N/A Temp3 ADC[3]: # Tank3 ADC[4]: # Temp2 ADC[5]: # Tank1 ADC[6]: # Temp1 ADC[7]: # Tank2 ADC[8]: # N/A Temp4 Pin outs wiring on the Expander Pi Tested OK 16/06/2019 Rob D ADC 3 = on Tank3 Victron ADC 5 = on Tank1 Victron ADC 7 = on Tank2 Victron ADC 4 = on Temp2 Victron ADC 6 = on Temp1 Victron The line in config.txt should read "dtoverlay=mcp3208:spi0-0-present" or spi1 for the stetson project. I received my ADC board today, and connected it to the RaspberryPi. I'm using this board, https://www.abelectronics.co.uk/p/50/Expander-Pi mainly because it was the one I could get delivered the quickest :-) Any board with an MCP3208 shoud do. I had some problems to get the ADC to give me 12bits resolution, as it would only give me 10-bits, with a max value of 1023 I had to convert the mcp3008-overlay.dtb to a dts file, change all references to 3008 to 3208, and convert it back to a dtb file, to get it to give me 12-bits (4095). (I've enclosed the dtb file if anyone needs it). The line in config.txt should read "dtoverlay=mcp3208:spi0-0-present" I haven't changed the voltage reference to an 1.8V version yet, or wired up the required resistors from the Beaglebone cape, but just fed the ADC's about half the vref input voltage as a proof of concept. I downloaded the compiled image for the Venus GX, ripped out the /opt/victronenergy/dbus-adc directory from the image with 7-zip, copied the directory to the Raspberry Pi. I then created a symlink from /service/dbus-adc to /opt/victronenergy/dbus-adc/service to get the service running… I then grabbed the device overlay file for the MCP3208 from the latest Raspian image, (mcp3008.dtbo I think), renamed it to mcp3008-overlay.dtb and dumped it into /u-boot/overlays added the line “dtoverlay=mcp3008:spi0-0-present” to config.txt and rebooted. Tada! All the analog sensor options are present in the Rasperry Pi’s Venus interface. Since there is no actual hardware is present, all the values are reading “0” on the sysfs iio interface, and you’ll get “Short Circuit” and “Unknown” as statuses in the GUI. (2.0V/4.096V, should be equivalent to around 0.9V on the Beaglebone) ###### Expander Pi ADAC Board ###### #https://www.abelectronics.co.uk/p/50/Expander-Pi https://www.abelectronics.co.uk/p/50/Expander-Pi #copy dtb to /u-boot/overlays # add the dbus-adc file to the opt/victronenergy folder #excerpt from post: #I had to convert the mcp3008-overlay.dtb to a dts file, change all references to 3008 to 3208, and convert it back to a dtb file, to get it to give me 12-bits (4095). #(I've enclosed the dtb file if anyone needs it). The line in config.txt should read "dtoverlay=mcp3208:spi0-0-present" #https://groups.google.com/d/msg/victron-dev-venus/mejgJbMjU34/WglmnUPQAwAJ install dbus-adc file into /opt/victronenergy/ (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 (need to add a folder called log and a file called run inside it) if missing? not required to run? 26/5/2020 touch /var/log/dbus-adc (sets time stamp of the file or created one) ln -s /opt/victronenergy/dbus-adc/service /service/dbus-adc (symlink command to link the files together) #add to /u-boot/config.txt #you did this way at the top. #####################Relay gpio ######################### 1. First off, pick a suitable GPIO. It seems to me the obvious choices would be something that is not multiplexed onto another function (some pins do double duty and can be configured to be something else), so the obvious choice to me seems to be GPIO21, which is on pin 40 on the header (right at the end). What's nice about this one, is it has a ground right next to it on pin 39. 2. Next you have configure this pin as a gpio. There is some functionality built into venus to do this, but not yet enabled on the Pi, so you will have to manually install this. First create /etc/venus/gpio_list by using the following command: echo "21 out relay_1" > /etc/venus/gpio_list echo "17 out relay_2" > /etc/venus/gpio_list echo "27 out relay_3" > /etc/venus/gpio_list echo "22 out relay_4" > /etc/venus/gpio_list 3. Install the setup script and make it executable, like so: wget -O /etc/init.d/gpio_pins.sh \ https://raw.githubusercontent.com/victronenergy/meta-victronenergy/master/meta-venus/recipes-bsp/gpio-export/files/gpio_pins.sh chmod +x /etc/init.d/gpio_pins.sh 4. Create a symlink to make gpio setup run at boot: cd /etc/rcS.d ln -s ../init.d/gpio_pins.sh /etc/rcS.d/S90gpio_pins.sh 5. Either reboot, or just run the script manually to set up the gpios at this time (you will reboot again later): /etc/init.d/gpio_pins.sh 6. You should now have a file /dev/gpio/relay_1 configured as an output. 7. Create /etc/venus/relays and add the relevant gpio ports only one is required to be in the folder? May not have to do as realys run with out this command in place. echo /sys/class/gpio/gpio21 > /etc/venus/relays echo /sys/class/gpio/gpio17 > /etc/venus/relays echo /sys/class/gpio/gpio27 > /etc/venus/relays echo /sys/class/gpio/gpio22 > /etc/venus/relays 8. Reboot. The relay should now show up in the list. Files to check for contents dev/gpio sys/class/gpio/export (can't open) etc/venus/gpio_list 9. Relay test from command screen, just select relay number to suit to test output is OK. echo 1 > /dev/gpio/relay_3/value (on) echo 0 > /dev/gpio/relay_3/value (off) For the 4 relays to work in the latest versions after 2.40.33 Need to use the old files from the version 2.4.33. ------------------------------------------------------------------------------------------------------------ Create a file /etc/venus/relays with the gpio controlling the relay, Confirmed and working OK Rob Duthie 18/06/2019 reboot and it should work (at least if I understand your question correctly). e.g. root@ccgx:~# cat /etc/venus/relays /sys/class/gpio/gpio182 Thanks to Izak I manage to make the relay work. Connect a 5v relay board to the GPIO, 5v and ground from the board and the signal from the 21 GPIO Now I find a problem. The relay is inverted by default. Izak told me that I could try to change from 0 to 1 into /dev/gpio/relay_1/active_low, and it works, but until i reboot the board. Then, something forces this to change from 1 to 0 when the board boots up. I don't know for sure (haven't tested it) but I think this should work for you: 1. Create a file called /data/rcS.local with the contents: echo 1 >/dev/gpio/relay_1/active_low 2. Make the file executable: chmod 755 /data/rcS.local 3. Test (ie. reboot) Relay out put and Digital input and output. Running in version 2.40.19 tested OK 24/8/2019 Rob D # This is a list of gpio pins, set by the script /etc/rcS.d/S90gpio_pins.sh # They are documented at: https://github.com/victronenergy/venus/wiki/bbb-gpio # Format: # # The part is used to create an symlink in /dev/gpio. # Relay 1 Pin 40 / GPIO 21 21 out relay_1 # Digital input 1 Pin 29 / GPIO 05 5 in digital_input_1 # Digital input 2 Pin 31 / GPIO 06 6 in digital_input_2 # Digital input 3 Pin 33 / GPIO 13 13 in digital_input_3 # Digital input 4 Pin 35 / GPIO 19 19 in digital_input_4 # Digital input 5 Pin 37 / GPIO 26 26 in digital_input_5 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). ######################## Relay Outputs - Digital IO Combined Files ##################### Extra relays command is under etc/venus Digital IO is built in using the Raspi GPIO ports. # This is a list of gpio pins, set by the script /etc/rcS.d/S90gpio_pins.sh # They are documented at: https://github.com/victronenergy/venus/wiki/bbb-gpio # Format: # # The part is used to create an symlink in /dev/gpio. # Relay 1 Pin 40 / GPIO 21 # Relay 2 Pin 11 / GPIO 17 # Relay 3 Pin 13 / GPIO 27 # Relay 4 Pin 15 / GPIO 22 21 out relay_1 17 out relay_2 27 out relay_3 22 out relay_4 # Digital input 1 Pin 29 / GPIO 05 5 in digital_input_1 # Digital input 2 Pin 31 / GPIO 06 6 in digital_input_2 # Digital input 3 Pin 33 / GPIO 13 13 in digital_input_3 # Digital input 4 Pin 35 / GPIO 19 19 in digital_input_4 # Digital input 5 Pin 37 / GPIO 26 26 in digital_input_5 Backup copy of test scripe for opt victronenergy/gui/pagesettingsrelay.qml import QtQuick 1.1 import com.victron.velib 1.0 import "utils.js" as Utils MbPage { id: pageRelaySettings title: qsTr("Relay") property string bindPrefix: "com.victronenergy.settings" property VBusItem relay1Item: VBusItem { bind: "com.victronenergy.system/Relay/1/State" } property bool hasRelay1: relay1Item.valid model: VisualItemModel { MbItemOptions { id: relayFunction description: hasRelay1 ? qsTr("Function (Relay 1)") : qsTr("Function") bind: Utils.path(bindPrefix, "/Settings/Relay/Function") possibleValues:[ MbOption { description: qsTr("Alarm relay"); value: 0 }, MbOption { description: qsTr("Generator start/stop"); value: 1 }, MbOption { description: qsTr("Tank pump"); value: 3 }, MbOption { description: qsTr("Manual"); value: 2 } ] } MbItemOptions { description: qsTr("Alarm relay polarity") bind: Utils.path(bindPrefix, "/Settings/Relay/Polarity") show: relayFunction.value === 0 possibleValues: [ MbOption { description: qsTr("Normally open"); value: 0 }, MbOption { description: qsTr("Normally closed"); value: 1 } ] } MbSwitch { id: relaySwitch // Use a one-way binding, because the usual binding: // checked: Relay.relayOn // will be broken when the switched toggled, and changes in the relayOn property made // elsewhere will not change the state of the switch any more. Binding { target: relaySwitch property: "checked" value: Relay.relayOn when: true } enabled: userHasWriteAccess name: qsTr("Alarm relay On") onCheckedChanged: Relay.relayOn = checked; show: relayFunction.value === 0 } MbSwitch { id: manualSwitch name: hasRelay1 ? qsTr("Relay 1 On") : qsTr("Relay On") bind: "com.victronenergy.system/Relay/0/State" show: relayFunction.value === 2 // manual mode } MbSwitch { id: manualSwitch1 name: qsTr("Relay 2 On") bind: "com.victronenergy.system/Relay/1/State" show: hasRelay1 } } } ######################## Relay updates notes ########################### root@raspberrypi2:~# cd /opt/victronenergy/gui/qml root@raspberrypi2:/opt/victronenergy/gui/qml# ls yes, the community issue already mentioned you need: MbSwitch { id: manualSwitch1 name: qsTr("Relay 2 On") bind: "com.victronenergy.system/Relay/1/State" show: hasRelay1 } Now remove the show property to always show it and copy/paste it some other menu where you want to have it. That should be it. The main page is a bit more special since it is build dynamically, so try a normal submenu first. ############################################################# etc/ venus/relays gpio list file /sys/class/gpio/gpio21 /sys/class/gpio/gpio17 /sys/class/gpio/gpio27 /sys/class/gpio/gpio22 etc/venus/gpio_list # This is a list of gpio pins, set by the script /etc/rcS.d/S90gpio_pins.sh # They are documented at: https://github.com/victronenergy/venus/wiki/bbb-gpio # Format: # # The part is used to create an symlink in /dev/gpio. # Relay 1 Pin 40 / GPIO 21 # Relay 2 Pin 11 / GPIO 17 # Relay 3 Pin 13 / GPIO 27 # Relay 4 Pin 15 / GPIO 22 21 out relay_1 17 out relay_2 27 out relay_3 22 out relay_4 # Digital input 1 Pin 29 / GPIO 05 5 in digital_input_1 # Digital input 2 Pin 31 / GPIO 06 6 in digital_input_2 # Digital input 3 Pin 33 / GPIO 13 13 in digital_input_3 # Digital input 4 Pin 35 / GPIO 19 19 in digital_input_4 # Digital input 5 Pin 37 / GPIO 26 26 in digital_input_5 optvictronenrgy/gui/qml/Page SettingRelay.qml import QtQuick 1.1 import com.victron.velib 1.0 import "utils.js" as Utils MbPage { id: pageRelaySettings title: qsTr("Relay") property string bindPrefix: "com.victronenergy.settings" property VBusItem relay1Item: VBusItem { bind: "com.victronenergy.system/Relay/1/State" } property bool hasRelay1: relay1Item.valid property VBusItem relay2Item: VBusItem { bind: "com.victronenergy.system/Relay/2/State" } property bool hasRelay2: relay1Item.valid property VBusItem relay3Item: VBusItem { bind: "com.victronenergy.system/Relay/3/State" } property bool hasRelay3: relay1Item.valid model: VisualItemModel { MbItemOptions { id: relayFunction description: hasRelay1 ? qsTr("Function (Relay 1)") : qsTr("Function") bind: Utils.path(bindPrefix, "/Settings/Relay/Function") possibleValues:[ MbOption { description: qsTr("Alarm relay"); value: 0 }, MbOption { description: qsTr("Generator start/stop"); value: 1 }, MbOption { description: qsTr("Tank pump"); value: 3 }, MbOption { description: qsTr("Manual"); value: 2 } ] } MbItemOptions { description: qsTr("Alarm relay polarity") bind: Utils.path(bindPrefix, "/Settings/Relay/Polarity") show: relayFunction.value === 0 possibleValues: [ MbOption { description: qsTr("Normally open"); value: 0 }, MbOption { description: qsTr("Normally closed"); value: 1 } ] } MbSwitch { id: relaySwitch // Use a one-way binding, because the usual binding: // checked: Relay.relayOn // will be broken when the switched toggled, and changes in the relayOn property made // elsewhere will not change the state of the switch any more. Binding { target: relaySwitch property: "checked" value: Relay.relayOn when: true } enabled: userHasWriteAccess name: qsTr("Alarm relay On") onCheckedChanged: Relay.relayOn = checked; show: relayFunction.value === 0 } MbSwitch { id: manualSwitch name: hasRelay1 ? qsTr("Relay 1 On") : qsTr("Relay On") bind: "com.victronenergy.system/Relay/0/State" show: relayFunction.value === 2 // manual mode } MbSwitch { id: manualSwitch1 name: qsTr("Relay 2 On") bind: "com.victronenergy.system/Relay/1/State" show: hasRelay1 } MbSwitch { id: manualSwitch2 name: qsTr("Relay 3 On") bind: "com.victronenergy.system/Relay/2/State" show: hasRelay2 } MbSwitch { id: manualSwitch3 name: qsTr("Relay 4 On") bind: "com.victronenergy.system/Relay/3/State" show: hasRelay3 } } }