0

I am trying to run Motor.py code from Freenove. I can see that my ads7830 IC is up and running

i@raspberrypi:~/Freenove_Kit/Code/Python_Code/13.1.1_Motor $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- 4b -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

But when I run my code, I get error that I2C address can't be found. Why?

pi@raspberrypi:~/Freenove_Kit/Code/Python_Code/13.1.1_Motor $ python Motor.py 
Program is starting ... 
Not found device in address 0x48
Not found device in address 0x4b
No correct I2C address found, 
Please use command 'i2cdetect -y 1' to check the I2C address! 
Program Exit. 

Address detection code is

def __init__(self):
    super(ADS7830, self).__init__()
    self.cmd = 0x84
    self.address = 0x4b # 0x4b is the default i2c address for ADS7830 Module.

def analogRead(self, chn): # ADS7830 has 8 ADC input pins, chn:0,1,2,3,4,5,6,7
    value = self.bus.read_byte_data(self.address, self.cmd|(((chn<<2 | chn>>1)&0x07)<<4))
    return value

The code which calls the above check is

def setup():
    global adc
    if(adc.detectI2C(0x48)): # Detect the pcf8591.
        adc = PCF8591()
    elif(adc.detectI2C(0x4b)): # Detect the ads7830
        adc = ADS7830()
    else:
        print("No correct I2C address found, \n"
        "Please use command 'i2cdetect -y 1' to check the I2C address! \n"
        "Program Exit. \n");
        exit(-1)
3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.