Beagley-ai: DFR0553 i2c ADS1115

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.

fred@bby1:~$ cd /boot/firmware/extlinux
fred@bby1:/boot/firmware/extlinux$ sudo nano extlinux.conf
label microSD (default)
    kernel /Image
    append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 resume=/dev/mmcblk1p2 rootwait net.ifnames=0 quiet
    fdtdir /
    fdt /ti/k3-am67a-beagley-ai.dtb
    fdtoverlays /overlays/k3-am67a-beagley-ai-csi0-imx219.dtbo /overlays/k3-am67a-beagley-ai-i2c-arm.dtbo
    initrd /initrd.img

This adds the overlay for i2c and the imx219, omit the camera if you don’t use it.

To check

$ cd /sys/firmware/devicetree/base/chosen/overlays
$ /sys/firmware/devicetree/base/chosen/overlays$ ls
k3-am67a-beagley-ai-csi0-imx219.kernel  k3-am67a-beagley-ai-i2c-arm.kernel  name

To find the other overlays

fred@bby1:/boot/firmware/overlays$ ls

So gpio2/gpio3 is /dev/i2c1 by default on bootup. Can you please share an Amazon link of what module this is…

Thanks for your response. Tried, and failed. Below are the contents of my extlinux.conf:

menu title BeagleY-AI microSD (extlinux.conf) (swap enabled)

timeout 50

default microSD (default)

label microSD (production test)
kernel /Image
append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net.ifnames=0 quiet
fdtdir /
fdt /ti/k3-am67a-beagley-ai.dtb
fdtoverlays /overlays/k3-am67a-beagley-ai-hdmi-dss0-dpi1.dtbo /overlays/k3-am67a-beagley-ai-lincolntech-185lcd-panel.dtbo /overlays/k3-am67a-beagley-ai-csi0-imx219.dtbo /overlays/k3-am67a-beagley-ai-csi1-imx219.dtbo
initrd /initrd.img

label transfer microSD rootfs to NVMe (advanced)
kernel /Image
append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net.ifnames=0 init=/usr/sbin/init-beagle-flasher-mv-rootfs-to-nvme
fdtdir /
fdt /ti/k3-am67a-beagley-ai.dtb
initrd /initrd.img

label microSD (debug)
kernel /Image
append console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02800000 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net.ifnames=0
fdtdir /
fdt /ti/k3-am67a-beagley-ai.dtb
initrd /initrd.img

label microSD (default)
kernel /Image
append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 resume=/dev/mmcblk1p2 rootwait net.ifnames=0 quiet
fdtdir /
fdt /ti/k3-am67a-beagley-ai.dtb
#fdtoverlays /overlays/<file>.dtbo
fdtoverlays /overlays/k3-am67a-beagley-ai-dsi-rpi-7inch-panel.dtbo /overlays/k3-am67a-beagley-ai-i2c-arm.dtbo
initrd /initrd.img

Neither the 7" DSI panel works, nor the I2C interface.

Thanks again,

Ahmed.

Tried and failed. Here’s my /boot/firmware/extlinux/extlinux.conf content:

menu title BeagleY-AI microSD (extlinux.conf) (swap enabled)

timeout 50

default microSD (default)

label microSD (production test)
    kernel /Image
    append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net.ifnames=0 quiet
    fdtdir /
    fdt /ti/k3-am67a-beagley-ai.dtb
    fdtoverlays /overlays/k3-am67a-beagley-ai-hdmi-dss0-dpi1.dtbo /overlays/k3-am67a-beagley-ai-lincolntech-185lcd-panel.dtbo /overlays/k3-am67a-beagley-ai-csi0-imx219.dtbo /overlays/k3-am67a-beagley-ai-csi1-imx219.dtbo
    initrd /initrd.img

label transfer microSD rootfs to NVMe (advanced)
    kernel /Image
    append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net.ifnames=0 init=/usr/sbin/init-beagle-flasher-mv-rootfs-to-nvme
    fdtdir /
    fdt /ti/k3-am67a-beagley-ai.dtb
    initrd /initrd.img

label microSD (debug)
    kernel /Image
    append console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02800000 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net.ifnames=0
    fdtdir /
    fdt /ti/k3-am67a-beagley-ai.dtb
    initrd /initrd.img

label microSD (default)
    kernel /Image
    append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 resume=/dev/mmcblk1p2 rootwait net.ifnames=0 quiet
    fdtdir /
    fdt /ti/k3-am67a-beagley-ai.dtb
    fdtoverlays /overlays/k3-am67a-beagley-ai-dsi-rpi-7inch-panel.dtbo /overlays/k3-am67a-beagley-ai-i2c-arm.dtbo
    initrd /initrd.img

Neither the dsi overlay nor the i2c overlay seem to do anything, since neither peripheral works.

I’ve also tried disconnecting the 7" DSI panel, removing its overlay, leaving only the i2c overlay in place. Still no love.

Thanks in advance.

Agreed and connected as such.

Not a module from Amazon, but here’s the data sheet link all the same. Works a treat on the Pi 4 and Arduino, all the way down to Nano.

Thanks.

We got them https://www.digikey.com/en/products/detail/dfrobot/DFR0553/9356341 let me grab one and test this week.

1 Like

Do you have a scope that can decode i2c, I would try sending data out that channel. If you can capture it then it is something buried in the python that is broke. Keep in mind, with python you are relying upon others to abstract out the key parts of the program.

Find some basic c test code and copy&paste and see what errors it kicks out. If the port is dead it will not open up and as result it will bounce back an error message.
Just got my board the other day and have not done anything with it, looking up the device tree for you was the first under the hood look at the board.

1 Like

The dsi overlay is for the i2c bus on the dsi/csi header…

the i2c overlay doesn’t do anything as the base device tree has it already enabled… (i’m planning to just remove k3-am67a-beagley-ai-i2c-arm.dts)

edit, oh it does enable 400000 vs 100000 maybe i’ll rename it as ‘fast’

Regards,

Not per se, but I do have a scope, and so can capture some output on the pins, and do a bit of manual decoding. Good idea, thanks for sharing.

I agree about the Python code, and will hack some C, although the fact that i2cdetect is blind to the device scan must say something.

Thanks again for the nudge. I’ll scope it and see what gives.

1 Like

Folks,

Mystery solved.

After a bit of scope probing, signals were looking noisy and unclean; made worse when the ADS1115 module was connected. Looking at the schematics to locate the pull-up resistors, one of the 2K2 reistors had a dry joint. Treated with a bit of TLC from a soldering iron brought everything to life.

Onto the next challenge: getting the display attached to the DSI port to work. I’ll start another thread for that.

Thanks for everyone who contributed to this thread.

Just to make things easier, i pushed a device-tree overlay for you…

cd /opt/source/dtb-6.1-Beagle/ ; \
git pull ; \
./build_n_install.sh

Then use this new overlay: /overlays/k3-am67a-beagley-ai-i2c1-ads1115.dtbo

label microSD (default)
    kernel /Image
    append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 resume=/dev/mmcblk1p2 rootwait net.ifnames=0 quiet
    fdtdir /
    fdt /ti/k3-am67a-beagley-ai.dtb
    fdtoverlays /overlays/k3-am67a-beagley-ai-i2c1-ads1115.dtbo
    initrd /initrd.img

and reboot

Your ads1115 should now register as an iio device…

iio_info

and you should see it under; /sys/bus/iio/devices/

Regards,

1 Like

Much obliged.

Quick question: where’s the repository I’m supposed to be pulling from? URL would be great.

Thanks again.

EDIT: never mind; found and sored.

I forgot to post that detail, this pre setup directory

/opt/source/dtb-6.1-Beagle/

It’s setup to this repo/branch Files · v6.1.x-Beagle · BeagleBoard.org / BeagleBoard-DeviceTrees · GitLab