Can't get I2C to work
Senna-chan opened this issue · 1 comments
Senna-chan commented
I am trying to connect to the Adafruit Motor hat(that uses the Adafruit PWM code), but the code can't find a I2C device
Error
System.InvalidOperationException: No I2C device exist on the specified pins
at Raspberry.IO.InterIntegratedCircuit.I2cDriver.GetBscBase (ProcessorPin sdaPin, ProcessorPin sclPin) [0x000a5] in <filename unknown>:0
at Raspberry.IO.InterIntegratedCircuit.I2cDriver..ctor (ProcessorPin sdaPin, ProcessorPin sclPin) [0x00020] in <filename unknown>:0
at motorTest.Motor_Hat..ctor (Int32 addr, Int32 freq) [0x00081] in /home/pi/motorTest/motorTest/adafruit_ports/Motor_Hat.cs:42
at motorTest.MainClass.Main (System.String[] args) [0x00008] in /home/pi/motorTest/motorTest/Program.cs:9
Motor_Hat.cs(Relevant code)
public Motor_Hat(int addr, int freq = 1600){
_i2caddr = addr;
_frequency = freq;
for(int i=1;i<5;i++){
motors.Add (new DC_Motor (this, i));
}
steppers.Add (new Stepper_Motor (this, 1));
steppers.Add (new Stepper_Motor (this, 2));
var I2CDriver = new I2cDriver (ProcessorPin.Pin03, ProcessorPin.Pin05);
_pwm = new Pca9685Connection (I2CDriver.Connect(addr));
_pwm.SetPwmUpdateRate(_frequency);
}
Am I doing anything wrong? The hat does work with the python code.
Senna-chan commented
After looking in the tests I found a example-code for the PCA9685. I will try to look if I can use the test and to possibly port the motorhat code to the raspberry-sharp-io library.