Hi,
I have two grove I2C motor driver connect by grove base hat on raspberry pi 3b:
- Raspberry pi 3b x 1
- Grove base hat x 1
- I2C motor driver x 2
- DC motor x 3
Case1:
When use a I2C motor driver connect 2 DC motors(default address 0x0f), it can control DC motor speed and direction.
Case2:
When use two I2C motor drivers connect 3 DC motor(one for default, other set to 0x0a), it shows “remote I/O error”
Case3:
When use a I2C motor driver connect 1 DC motor(set address to 0x0a), it shows “remote I/O error” too.
Case4:
when I2C motor driver connect to Grove base hat, the command
i2cdetect -y 1 is not working, even use default address(0x0f)
below is my sample code in python3:
import time
from grove.grove_i2c_motor_driver import MotorDriver
import datetime
def addSecs(tm, secs):
fulldate = datetime.datetime(100, 1, 1, tm.hour, tm.minute, tm.second)
fulldate = fulldate + datetime.timedelta(seconds=secs)
return fulldate.time()
addml = 5 # add 5 ml
addinterval = addml*30
motor1 = MotorDriver(address=0x0f)
motor2 = MotorDriver(address=0x0a)
try:
print("time Begin = {}".format(time.strftime("%H:%M:%S")))
t1 = datetime.datetime.now().time()
t2 = addSecs(t1, addinterval)
while datetime.datetime.now().time() < t2:
motor1.set_dir(True,True)
motor2.set_dir(True,False)
motor1.set_speed(20,20)
motor2.set_speed(100,0)
time.sleep(1)
print("time End = {}".format(time.strftime("%H:%M:%S")))
except KeyboardInterrupt:
print("time Interrupt = {}".format(time.strftime("%H:%M:%S")))
error message output:
time Begin = 19:57:52
Traceback (most recent call last):
File “motor.py”, line 31, in
motor2.set_dir(True,False)
File “/usr/local/lib/python3.7/dist-packages/grove/grove_i2c_motor_driver.py”, line 88, in set_dir
self.bus.write_i2c_block_data(self.I2CAddr, self.__DirectionSet, [dir, 0])
File “/usr/local/lib/python3.7/dist-packages/smbus2/smbus2.py”, line 622, in write_i2c_block_data
ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error
Exception ignored in: <function MotorDriver.del at 0x76733b70>
Traceback (most recent call last):
File “/usr/local/lib/python3.7/dist-packages/grove/grove_i2c_motor_driver.py”, line 61, in del
File “/usr/local/lib/python3.7/dist-packages/grove/grove_i2c_motor_driver.py”, line 80, in set_speed
File “/usr/local/lib/python3.7/dist-packages/smbus2/smbus2.py”, line 622, in write_i2c_block_data
OSError: [Errno 121] Remote I/O error
Can someone help me find out the problem?
Thank you.