question

sv-soleil avatar image
sv-soleil asked

mcp3208 ADC raspberry pi

Here are step-by-step instructions on how to interface an mcp3208. I spent days following old posts and falling down various rabbit holes. What a nightmare. What I’ve done below works as of 2024.


Step 1: download anyspi.dbto


cd /u-boot/overlays


wget https://github.com/raspberrypi/firmware/raw/master/boot/overlays/anyspi.dtbo


Step 2: create run files


cd /opt/victronenergy/dbus_adc

mkdir service


nano run


#!/bin/sh

exec 2>&1

exec softlimit -d 100000000 -s 1000000 -a 100000000 /opt/victronenergy/dbus-adc


(Add above lines to the file “run”)


cd /opt/victronenergy/dbus_adc/service


mkdir log


nano run


root@raspberrypi2:/opt/victronenergy/dbus-adc/service/log# more run

#!/bin/sh

exec 2>&1

exec multilog t s99999 n8 /var/log/dbus-adc


(Add above lines to the file “run”)


chmod 755 /opt/victronenergy/dbus-adc/service/run

chmod 755 /opt/victronenergy/dbus-adc/service/log/run


ln -s /opt/victronenergy/dbus-adc/service /service/dbus-adc

1710961355106.png

Step 3: Add one line to /u-boot/config.txt


nano /u-boot/config.txt

(Add this to the end of the file)


dtoverlay=anyspi:spi0-0,dev="microchip,mcp3208"


Step 4: create your own dbus-adc.conf file


nano /etc/venus/dbus-adc.conf


Here you need to put your own custom information, for example:


device iio:device0

vref 1.8

scale 4095

label "Tank 1"

tank 4

1710961291592.png

reboot


On your remote console go to

Settings->I/O->Analog Inputs

1710961622494.png

tank monitoranalog
1710961291592.png (100.4 KiB)
1710961355106.png (40.0 KiB)
1710961622494.png (103.1 KiB)
2 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.

tadpole48 avatar image tadpole48 commented ·

I think I managed to work out the errors in the original instructions, I hope you don't mind if I re-list it with my interpretation...


Step 1: Download anyspi.dbto


cd /u-boot/overlays

wget https://github.com/raspberrypi/firmware/raw/master/boot/overlays/anyspi.dtbo



Step 2: Create run files


cd /opt/victronenergy/dbus-adc

mkdir service

cd service

nano run


add these 3 lines to run file (then exit Nano with save)...


#!/bin/sh

exec 2>&1

exec softlimit -d 100000000 -s 1000000 -a 100000000 /opt/victronenergy/dbus-adc


mkdir log

cd log

nano run


add these 3 lines to run file (then exit Nano with save)...


#!/bin/sh

exec 2>&1

exec multilog t s99999 n8 /var/log/dbus-adc



Step 3: Change "run" files Permissions


chmod 755 /opt/victronenergy/dbus-adc/service/run

chmod 755 /opt/victronenergy/dbus-adc/service/log/run



Step 4: Create a Symbolic Link pointing to the new service folder in the /service/dbus-adc folder


ln -s /opt/victronenergy/dbus-adc/service /service/dbus-adc



Step 5: Add one line to /u-boot/config.txt


nano /u-boot/config.txt


add this 1 line to the end of the config.txt file (then exit Nano with save)...


dtoverlay=anyspi:spi0-0,dev="microchip,mcp3208"



Step 6: Create your own dbus-adc.conf file


nano /etc/venus/dbus-adc.conf


Here you need to put your own custom information, for example:


device iio:device0

vref 1.8

scale 4095


label "Tank 1"

tank 0

label "Tank 2"

tank 1

label "Tank 3"

tank 2

label "Tank 4"

tank 3


label "Temp 1"

temp 4

label "Temp 2"

temp 5

label "Temp 3"

temp 6

label "Temp 4"

temp 7


1 Like 1 ·
tadpole48 avatar image tadpole48 commented ·

I'm in a similar position, but struggling with the "what works" above, I noted a couple of errors above with the use of "_" instead of "-" (Step 2 cd /opt/victronenergy/dbus_adc should be dbus-adc) and I do not appear to have the same file structure, when finished with the above my directory tree is different, I don't know where I went wrong!

Should the line "root@raspberrypi2:/opt/victronenergy/dbus-adc/service/log# more run" really be in the log/run file?

Any help would be much appreciated.

0 Likes 0 ·
0 Answers

Related Resources

GX Tank 140 product page

Connecting tank monitoring to Cerbo GX

Additional resources still need to be added for this topic