adafruit / Adafruit_Python_Extended_Bus

Helper Library for Blinka to allow creating I2C and SPI busio objects by passing in the Bus ID
MIT License
33 stars 3 forks source link

Adafruit I2C connection have a conflict on RPi.GPIO mode set #2

Closed roxanaluca closed 4 years ago

roxanaluca commented 4 years ago

Hi,

I have connected PCA9685 and Arducam Multi Camera Adapter on Raspberry Pi 3B+. I am using bus 3 for the PCA9685 connection and I have GPIO 26 for SCL and GPIO 16 for SDA. The problem is that when I put Arducam Multi-Camera adapter and the I2C Adafruit together there is a issue regarding on the following line gp.setmode(gp.BOARD) ValueError: A different mode has already been set Could you tell me please how to solve this error?

I look forward to your reply. Many thanks,

makermelissa commented 4 years ago

Could you please provide the entire error message with line numbers? I'm not seeing gp.setmode(gp.BOARD) in the source code for this library.

roxanaluca commented 4 years ago

Traceback (most recent call last): File "main.py", line 186, in gp.setmode(gp.BOARD) ValueError: A different mode has already been set!

import RPi.GPIO as gp
from adafruit_extended_bus import ExtendedI2C as I2C
from adafruit_servokit import ServoKit
class MotorDriver():
    def __init__(self):
        i2c = I2C(3)
        kit = ServoKit(channels=16, i2c=i2c)
        if kit.servo[1].angle < 0 or kit.servo[1].angle > 180:
            kit.servo[1].angle = 30
if __name__=="__main__":
    gp.setwarnings(False)
    gp.setmode(gp.BOARD)
    gp.setup(7,gp.OUT)
    gp.setup(11,gp.OUT)
    gp.setup(12,gp.OUT)
ladyada commented 4 years ago

you probably cannot mix rpi.gpio with circuitpython

On Wed, May 6, 2020 at 12:07 PM Maria Roxana Luca notifications@github.com wrote:

Traceback (most recent call last): File "main.py", line 186, in gp.setmode(gp.BOARD) ValueError: A different mode has already been set!

import RPi.GPIO as gp from adafruit_extended_bus import ExtendedI2C as I2C from adafruit_servokit import ServoKit class MotorDriver(): def init(self): i2c = I2C(3) kit = ServoKit(channels=16, i2c=i2c) if kit.servo[1].angle < 0 or kit.servo[1].angle > 180: kit.servo[1].angle = 30 if name=="main": gp.setwarnings(False) gp.setmode(gp.BOARD) gp.setup(7,gp.OUT) gp.setup(11,gp.OUT) gp.setup(12,gp.OUT)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adafruit/Adafruit_Python_Extended_Bus/issues/2#issuecomment-624740631, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJINUIRX4OCJ3RYAKCEBQDRQGDNFANCNFSM4M2LINKA .

makermelissa commented 4 years ago

Yeah, mixing them isn't a good idea. Blinka makes use of RPi.GPIO under the hood for the Raspberry Pis and it's not liking the manual overriding.

roxanaluca commented 4 years ago

Ok.. but I had to set pin 7,11,12 to False and True. Could you tell me how can I use them?

makermelissa commented 4 years ago

Yes. You'll want to use digitalio for this. See https://learn.adafruit.com/circuitpython-digital-inputs-and-outputs/digital-outputs for more info.