How to Enable I2C on AML-S905X-CC Le Potato

There are two I2C buses available on Le Potato in the same pin position on the 40 pin GPIO header as on most Raspberry Pi boards.

  • i2c-ao on pin 3 and 5
  • i2c-b on pin 27 and 28

To enable the I2C AO:

ls -al /dev/i2c-*
sudo ldto enable i2c-ao
ls -al /dev/i2c-*

To enable the I2C B:

ls -al /dev/i2c-*
sudo ldto enable i2c-b
ls -al /dev/i2c-*

After enabling, you can scan the i2c bus:

sudo i2cdetect -y I2CNUM

Replace I2CNUM with the i2c device that appeared from the ls -al /dev/i2c-*

Instructions as above work correctly.

Le Potato with Max7219 Display on SPI bus and PCF5774 Shift Register Keyboard on i2c bus.

Le Potato Time - YouTube

1 Like

I was trying to fool around with an i2c capacitive touch sensor, and ran into some strange behavior.

This is the sensor’s learning guide:

The sensors i2c address is 0x36, which I have confirmed with a RPi Pico. Before enabling any overlays (I really need to learn more about those) there is an i2c device already present with addresses 0x30 and 0x50 present.

Here’s what I get:


$ ls -al /dev/i2c-*
crw-rw---- 1 root dialout 89, 0 Sep  9 18:47 /dev/i2c-0
$ sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --      

When I enable the overlay for i2c-ao I get this:

$ sudo ldto enable i2c-ao

Overlay i2c-ao: applied

$ ls -al /dev/i2c-*

crw-rw---- 1 root dialout 89, 0 Sep  9 18:47 /dev/i2c-0
crw-rw---- 1 root dialout 89, 1 Mar  5 23:13 /dev/i2c-1

$ sudo i2cdetect -y 0

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --         
                
$ sudo i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- 36 -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

So I know I’m kind of on my own with the CircuitPython stuff, but when using their sample script I get errors including " ValueError: No I2C device at address: 0x36 "

Running the i2c scan script provided in the above link produced:

s$ python3 i2c_scan.py
I2C addresses found: [‘0x30’, ‘0x3a’, ‘0x50’]
I2C addresses found: [‘0x30’, ‘0x3a’, ‘0x50’]
I2C addresses found: [‘0x30’, ‘0x3a’, ‘0x50’]

This makes me think CircuitPython is talking to this mysterious /dev/i2c-0 instead of my desired device. Also, no clue where 0x3a came from.
Switching to i2c-b and pins 27 & 28 solves this problem despite i2c-0 still existing, so it seems to be related to pins 3 & 5.

Now Lady Ada’s script works fine:


$ sudo ldto disable i2c-ao

Overlay i2c-ao: removed

$ ls -al /dev/i2c-*

crw-rw---- 1 root dialout 89, 0 Sep  9 18:47 /dev/i2c-0

$ sudo ldto enable i2c-b

Overlay i2c-b: applied

$ ls -al /dev/i2c-*

crw-rw---- 1 root dialout 89, 0 Sep  9 18:47 /dev/i2c-0
crw-rw---- 1 root dialout 89, 1 Mar  5 23:53 /dev/i2c-1

$ sudo i2cdetect -y 0

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  

$ sudo i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- 36 -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

$ python3 soil_sensor.py 

temp: 24.70550595678  moisture: 357
temp: 24.602585485680002  moisture: 361
temp: 24.499680273360003  moisture: 361
temp: 24.70550595678  moisture: 362
temp: 24.70550595678  moisture: 1016
temp: 24.81485037426  moisture: 1016
temp: 24.81485037426  moisture: 1016

My System Info:

           `-mddhhhhhhhhhddmss`             angus@aml-s905x-cc 
        ./mdhhhhhhhhhhhhhhhhhhhhhh.         ------------------                   
     :mdhhhhhhhhhhhhhhhhhhhhhhhhhhhm`       OS: Lubuntu 22.04.2 LTS aarch64      
   :ymhhhhhhhhhhhhhhhyyyyyyhhhhhhhhhy:      Host: aml-s905x-cc                   
  `odhyyyhhhhhhhhhy+-````./syhhhhhhhho`     Kernel: 6.0.19-02543-g73f2949c2dd9   
 `hhy..:oyhhhhhhhy-`:osso/..:/++oosyyyh`    Uptime: 3 hours, 36 mins             
 dhhs   .-/syhhhhs`shhhhhhyyyyyyyyyyyyhs    Packages: 2044 (dpkg), 9 (snap)      
:hhhy`  yso/:+syhy/yhhhhhshhhhhhhhhhhhhh:   Shell: bash 5.1.16                   
hhhhho. +hhhys++oyyyhhhhh-yhhhhhhhhhhhhhs   Resolution: 1680x1050                
hhhhhhs-`/syhhhhyssyyhhhh:-yhhhhhhhhhhhhh   DE: LXQt 0.17.1                      
hhhhhhs  `:/+ossyyhyyhhhhs -yhhhhhhhhhhhh   WM: Openbox                          
hhhhhhy/ `syyyssyyyyhhhhhh: :yhhhhhhhhhhs   Theme: Arc-Darker [GTK3]             
:hhhhhhyo:-/osyhhhhhhhhhhho  ohhhhhhhhhh:   Icons: Adwaita [GTK3]                
 sdhhhhhhhyyssyyhhhhhhhhhhh+  +hhhhhhhhs    Terminal: qterminal                  
 `shhhhhhhhhhhhhhhhhhhhhhy+` .yhhhhhhhh`    Terminal Font: Ubuntu Mono 14        
  +sdhhhhhhhhhhhhhhhhhyo/. `/yhhhhhhhd`     CPU: (4) @ 1.512GHz                  
   `:shhhhhhhhhh+---..``.:+yyhhhhhhh:       Memory: 1275MiB / 1924MiB            
     `:mdhhhhhh/.syssyyyyhhhhhhhd:`                                              
        `+smdhhh+shhhhhhhhhhhhdm`                                                
           `sNmdddhhhhhhhddm-`                                                   



It’s not detrimental or anything, and I understand this is likely a CircuitPython issue not to be resolved here, but if there’s an easy and safe way to disappear this /dev/i2c-0 (I don’t even know what it is) it seems that would be far easier.

Also, what is the proper way to use an i2c device with the AML-S905X-CC? I’ve only ever used i2c devices with CircuitPython, and I’m looking to spread my wings.

Any insights would be appreciated.

You should specify the I2C device for CircuitPython. Not let it pick the first device.

Thanks for pointing me in the right direction!

For anyone else in need, I found the detailed instructions on how to do that here:

Now I’m going to read the rest of it before I ask any more questions.

1 Like

Le Potato i2c bus - Le Potato - Armbian Community Forums

I had seen this so was prepared for your observations.

I use smbus2 without any issues.

smbus2 · PyPI

I used “adafruit_extended_bus” instead of the regular “busio” I’d use on a microcontroller, as seen in the above link. It worked first try.

Now that I’ve got home and checked it out, smbus2 seems to be just what I was looking for as I take those next few steps away from micro-controller land. Thanks for all the help!