How can I use i2c without a board?

Hello, I’m going to make a motion with JETSON nano, adafruit’s ADS1115, and buttons.
The code is as follows.

import RPi.GPIO as gpio
import busio
import board
import time
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn


i2c=busio.I2C(board.SCL, board.SDA)
ads=ADS.ADS1115(i2c, address=0x48)


chan1 = AnalogIn(ads, ADS.P0)
chan2=AnalogIn(ads, ADS.P3)

while 1:
    if gpio.input(SW3):
        print(chan1.value, chan1.voltage)
    else : print(chan2.value, chan2.voltage)

The following error occurs when trying to execute the code
‘ValueError: A different mode has already been set!’

RPI without using “import board” to eliminate errors.If there is an I2C provided by GPIO, I would like to use it, but RPI.Is there any I2C keyword provided by GPIO?

Thank you for reading it.

hello j613943745,

such failure is due to the pin has configured. you may dig into the code to revise the settings.

may I know what’s the actual use-case, would you like to have GPIO-based i2c bus multiplexer to route the i2c signals?
please also check Cam I2C Mux on Jetson Xavier NX in Device Tree - #17 by JerryChang for reference,

Thank you for your answer. The actual use case means what kind of movement do you want me to do?

When you press the button, you want to read the value of the sensor attached to Adafruit’s ADS1115 module and output it.

hello j613943745,

please check this kernel documentation, it also shows the paragraph to demonstrate the bindings.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.