Skip to main content

A port of Grove Motor Driver TB6612FNG library for python and RaspberryPI. This library also includes easing functions to control your motors with smooth transitions.

Project description

RaspberryPi Grove TB6612FNG Motor Shield Library

PyPI pyversions PyPI version shields.io

This is an open source port of the official Grove Motor Shield TB6612FNG library for Arduino to Python for Raspberry Pi.

Features

Requirements

  • RaspberryPi I2C enabled
  • Python 3.13 or higher

[!NOTE] This library was tested in 2025 on Raspberry Pi 5 8GB with Raspberry Pi OS (64-bit Debian 1:6.12.47-1+rpt1 2025-09-16) with kernel version 6.12 running Python 3.13.5 and library version 0.3.0.

Getting started

1. Enable I2C on your Raspberry Pi

If you have not done so already, you will need to enable I2C on your Raspberry Pi. You can do this by running sudo raspi-config in your terminal, then navigating to Interfacing Options -> I2C and enabling it. After that, you may need to reboot your Raspberry Pi.

2. Install Python

You can install the latest version of python on your Raspberry Pi by running the following commands in your terminal:

sudo apt update
sudo apt install python3 python3-pip python3-venv

It is recommended to use a virtual environment for your python projects. You can create one by running the following commands:

python3 -m venv .venv
source .venv/bin/activate

3. Install the library

Install this library:

python3 -m pip install raspberry-i2c-tb6612fng

4. Example usage

import time

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)

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raspberry_i2c_tb6612fng-0.3.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raspberry_i2c_tb6612fng-0.3.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file raspberry_i2c_tb6612fng-0.3.0.tar.gz.

File metadata

  • Download URL: raspberry_i2c_tb6612fng-0.3.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for raspberry_i2c_tb6612fng-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5b3d1582b67fbabe0ff3d8c5af08b0864dc695927bb39fcde755f615c9403d10
MD5 cc2d3c188f5e435a6117c46b919a5a33
BLAKE2b-256 d84d93012be8c27f5a15a7fc5f2b23b4b659ae378e5cae6eb89e55c2ca7e3411

See more details on using hashes here.

File details

Details for the file raspberry_i2c_tb6612fng-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for raspberry_i2c_tb6612fng-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c12535aa556a470c9794bdd0de45d77b18341e01b473c7c6912ddf58e3d96ab6
MD5 c57db2c5734cc65a49e11117ce48df78
BLAKE2b-256 04d5beca47cd22703ed4c8df02566163e4252ded7f2990c38ebab6c2d85c9fe2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page