ADC issues - Navio2

Hi guys,

Do you have ADC testing code in either C++ or Python for the Navio2?

I’m trying to connect a sonar Rangefinder to my Navio2, but hitting a brickwall.

The examples in C++ and Python don’t work:

C++:
Failed to read device(-1): Input/output error Failed to write reg: Input/output error Failed to write reg: Input/output error Failed to write reg: Input/output error

Python:
Error accessing 0x48: Check your I2C address Error accessing 0x48: Check your I2C address Traceback (most recent call last): File "ads1x15_ex_singleended.py", line 40, in <module> volts = adc.readADCSingleEnded(0, gain, sps) / 1000 File "/home/pi/navio/Python/ADC/Adafruit_ADS1x15.py", line 223, in readADCSingleEnded val = (result[0] << 8) | (result[1]) TypeError: 'int' object has no attribute '__getitem__'

Ok, partially solved…

remember to use the Navio2 github repo for the examples!

Still erroring out on the python example though

@Mikebert4 Sorry, the Python examples have not been updated for Navio2 yet, but we are already working on it.

@mikhail.avkhimenia - thanks for the response, I’ve got the ADC example working for me now (see below) but I can’t get the data into APM - I’ve tried pin 4 and pin 5 in APM, but no avail.

…hacked C++ ADC example…

I’ve hacked the C++ example to output voltage from all of the channels provided in /sys/kernel/rcio/adc/ reading from each of the 5 files in that dir and outputting thus:
(ch0 | ch1 | ch2 | ch3 | ch4 | ch5)

example output:
4.8320V | 0.0000V | 0.0160V | 0.0220V | 0.0180V | 0.0700V 4.8320V | 0.0000V | 0.0160V | 0.0220V | 0.0180V | 0.0700V 4.8320V | 0.0000V | 0.0160V | 0.0220V | 0.0180V | 0.0700V 4.8320V | 0.0000V | 0.0160V | 0.0220V | 0.0180V | 0.0700V 4.8320V | 0.0000V | 0.0160V | 0.0220V | 0.0320V | 0.0660V 4.8380V | 0.0000V | 0.0260V | 0.0220V | 0.0320V | 0.0660V

So, that gives me a channel mapping thus:

ch0 = always 4.832v
ch1 = always 0v
ch2 = unknown (just noise seen)
ch3 = unknown (just noise seen)
ch4 = ADC (green wire in photo)
ch5 = ADC (blue wire in photo)