Recently got to use Grove - I2C Motor Driver (TB6612FNG) with my Raspberry Pi.
For this, I wrote and released my own port of Arduino library for this module to Raspberry Pi and python3.
This library also includes easing functions to control your motors with smooth transitions.Easing functions are available for dc motors only.
Hi @MarkusBansky
We have tested the library you wrote. But we meet some problem, Using your library we can drive the motor to rotate. But sometimes when typing python3 test.py to run, it will report the error in the picture below.
I can find I2C address when using sudo i2cdetect -y 1.
Hi,
Unfortunately I am not able to reproduce this error, this might be because of the i2c bus being busy.
Could you tell me more info about the environment you are running this on?
Hi @MarkusBansky
Thank you for your reply.
1.Raspberry pi 4B
2.Python 3.7
3.pip(18.1-5+rpt1).
4. The raspberry-i2c-tb6612fng I was download in here.
5.
# import default libraries that are used in this example
import time
# import the library
from raspberry_i2c_tb6612fng import MotorDriverTB6612FNG, TB6612FNGMotors
# create an instance of the driver, connected to i2c
driver = MotorDriverTB6612FNG()
# drive both motors forward
driver.dc_motor_run(TB6612FNGMotors.MOTOR_CHA, 200)
driver.dc_motor_run(TB6612FNGMotors.MOTOR_CHB, 200)
# pause for a second
time.sleep(1)
# stop the motors
driver.dc_motor_break(TB6612FNGMotors.MOTOR_CHA)
driver.dc_motor_break(TB6612FNGMotors.MOTOR_CHB)
Hi, Unfortunately I don’t have Pi4 to test this on, from searching similar problems, this might be related to the bus connections, not the code itself, as then it won’t work at all.
I would suggest checking all connections or trying different hardware.
As soon as I will get Pi4 I would be able to test this.