ChaosSpear
Posts: 5
Joined: Wed Jul 08, 2020 3:58 pm

Changing pins for ADS1115

Sat Aug 01, 2020 7:40 pm

Just like the topic says - I've got a project that will involve a UCTronics TFT screen that plugs directly into the GPIO, so I need to move the SDA/SCL wires for my Analog-Digital Converter to GPIO channels 5/6.

I'm using this python code to set up the i2c:

Code: Select all

import board, busio
i2c = busio.I2C(board.SCL, board.SDA)
I thought it would be as simple as changing the arguments passed to busio.I2C, so I went into python, did dir(board) and assumed that the D0-D27 were the GPIO channels, but changing the argument to (board.D6, board.D5) didn't work.

Any help?

ChaosSpear
Posts: 5
Joined: Wed Jul 08, 2020 3:58 pm

Re: Changing pins for ADS1115

Mon Aug 03, 2020 4:05 am

Okay, so I found this: https://raspberrypi.stackexchange.com/q ... spberry-pi

And I made the changes to /boot/config.txt as it said, but when I run the python program it still says that there is no hardware i2c there.

I know I'm doing something dumb... please someone save me from myself?

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Changing pins for ADS1115

Mon Aug 03, 2020 5:17 am

Hardware I2C is available on GPIO 2/3 only on the Pi. If busio insists on using hardware I2C you will need to find an alternative solution.

ChaosSpear
Posts: 5
Joined: Wed Jul 08, 2020 3:58 pm

Re: Changing pins for ADS1115

Wed Aug 05, 2020 7:32 am

joan wrote:
Mon Aug 03, 2020 5:17 am
Hardware I2C is available on GPIO 2/3 only on the Pi. If busio insists on using hardware I2C you will need to find an alternative solution.
EDIT: re-wrote this post as I realize I was really off the mark.

Firstly, thank you for the reply. Second, from what I'm reading, I can use GPIO 2/3 for both SPI and I2C at the same time, right? So I can use my screen and my ADC at the same time, by connecting them both to GPIO 2/3?

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Changing pins for ADS1115

Wed Aug 05, 2020 9:28 am

ChaosSpear wrote:
Wed Aug 05, 2020 7:32 am
joan wrote:
Mon Aug 03, 2020 5:17 am
Hardware I2C is available on GPIO 2/3 only on the Pi. If busio insists on using hardware I2C you will need to find an alternative solution.
EDIT: re-wrote this post as I realize I was really off the mark.

Firstly, thank you for the reply. Second, from what I'm reading, I can use GPIO 2/3 for both SPI and I2C at the same time, right? So I can use my screen and my ADC at the same time, by connecting them both to GPIO 2/3?
I2C is a multidrop bus. The RPi is the master/controller. Each slave/sensor device has a unique address between x'03' and x'77'. So as long as two slave devices have unique bus addresses they can share the I2C bus.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Interfacing (DSI, CSI, I2C, etc.)”