Folks,
I’ve so far had nothing but failure in my endeavours to get a simple ads1115 module recognised and usable on my beagley-ai.
I connected the module to GPIO 2 and 3, and powered it via pins 4 & 6 (+5V and GND), so that’s the hardware part out of the way.
i2cdetect -l returns the following output:
i2cdetect -l
i2c-1 i2c OMAP I2C adapter I2C adapter
i2c-2 i2c OMAP I2C adapter I2C adapter
i2c-3 i2c OMAP I2C adapter I2C adapter
i2c-4 i2c OMAP I2C adapter I2C adapter
i2c-5 i2c OMAP I2C adapter I2C adapter
A simple ls of the device files returns:
ls -lah /dev/i2c-*
crw-rw---- 1 root gpio 89, 1 Jun 22 02:59 /dev/i2c-1
crw-rw---- 1 root gpio 89, 2 Jun 22 02:59 /dev/i2c-2
crw-rw---- 1 root gpio 89, 3 Jun 22 02:59 /dev/i2c-3
crw-rw---- 1 root gpio 89, 4 Jun 22 02:59 /dev/i2c-4
crw-rw---- 1 root gpio 89, 5 Jun 22 02:59 /dev/i2c-5
I used the Adafruit python module for the ADC module, and the test code below (my device is at address 0x49, and connected to GPIO 2/3 as stated about:
import Adafruit_ADS1x15
# Create an ADS1115 ADC (16-bit) instance.
adc = Adafruit_ADS1x15.ADS1115(0x49, busnum=1)
GAIN = 1
print('Reading ADS1x15 values, press Ctrl-C to quit...')
# Print nice channel column headers.
print('| {0:>6} | {1:>6} | {2:>6} | {3:>6} |'.format(*range(4)))
print('-' * 37)
# Main loop.
while True:
# Read all the ADC channel values in a list.
values = [0]*4
for i in range(4):
# Read the specified ADC channel using the previously set gain value.
values[i] = adc.read_adc(i, gain=GAIN)
print('| {0:>6} | {1:>6} | {2:>6} | {3:>6} |'.format(*values))
# Pause for half a second.
time.sleep(0.5)
The output is below:
eading ADS1x15 values, press Ctrl-C to quit...
| 0 | 1 | 2 | 3 |
-------------------------------------
Traceback (most recent call last):
File "/home/ahmed/Adafruit_Python_ADS1x15/examples/./simpletest.py", line 42, in <module>
values[i] = adc.read_adc(i, gain=GAIN)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/Adafruit_ADS1x15-1.0.2-py3.11.egg/Adafruit_ADS1x15/ADS1x15.py", line 192, in read_adc
File "/usr/local/lib/python3.11/dist-packages/Adafruit_ADS1x15-1.0.2-py3.11.egg/Adafruit_ADS1x15/ADS1x15.py", line 128, in _read
File "/usr/local/lib/python3.11/dist-packages/Adafruit_GPIO/I2C.py", line 127, in writeList
self._bus.write_i2c_block_data(self._address, register, data)
File "/usr/local/lib/python3.11/dist-packages/Adafruit_PureIO/smbus.py", line 357, in write_i2c_block_data
self._device.write(data)
OSError: [Errno 121] Remote I/O error
This very same module, code and hardware hookup works perfectly on a Raspberry Pi 4. And whereas the raspi-config on a Pi 4 would allow the I2C bus to be enabled, the beagley version of the command is not so fortunate or capable - there are no entries for any useful interfaces.
Help anyone?
Thanks
Ahmed.