Micropython support for motor controller library M2T256 Pico


I am hoping to use 2 M2T256 dual motor controllers to drive 4 motors using I2C from a Raspberry Pi Pico. Pictured on one of the images within the product description, this appears possible (image showing a Pi Pico connected to M2T256 and motor). I assumed that this configuration would be able to use the provided Motoron Motor Controller Python library developed as would be the case if I used a Pi. However I am struggling to make this work, to me it appears that the library doesn’t support Micropython use, and I cannot get the installation of your library and the smbus2 library to work. I also cannot seem to find any information in the user guide either. I would love some help in suggestions on how I could operate this setup using the library provided, or some guidance on porting the library across to micropython if that’s possible.

As an addition, I am using Thonny on Windows with the Pi Pico connected as my programming environment.



Unfortunately, MicroPython does not provide an I2C library that is compatible with the smbus2 library used by our Motoron Python library. You might consider rewriting the MotoronI2C class in our library to use the MicroPython’s I2C class instead of smbus2.

Also, here is some basic code that uses the I2C class directly. It shows how to initialize the Motoron and then send a “Set all speeds” command with three speeds:

i2c = I2C(0, scl=Pin(21), sda=Pin(20), freq=100_000)

# reinitialize, disable CRC, clear reset error
i2c.writeto(16, bytearray([0x96, 0x74, 0x8b, 0x04, 0x7b, 0x43, 0xa9, 0x00, 0x04]))

def set_motors(m1, m2, m3):
    i2c.writeto(16, bytearray([
        m1%128, (m1%16384)//128,
        m2%128, (m2%16384)//128,
        m3%128, (m3%16384)//128

Please let me know if you have any additional questions.


We updated the Motoron Python library and it supports MicroPython now: