Happy New Year's Eve! Although I have limited experience with Arduino microcontrollers, I have no experience with the Raspberry Pi Pico board, or with MicroPython (though I have lots of experience with Python).
I am looking to control a stepper motor via a SparkFun TB6612FNG motor driver using a Pico 1 that is running MicroPython that I'm programming via VS Code. The stepper motor is a NEMA-17 "BJ42D15-26V09" that I pulled from a scrapped Ender-3. I've wired the motor to the driver according to a guide from Adafruit (their motor driver uses the same IC). Given that the Adafruit guide references a Metro board for control, I've connected to pins 1, 2, 4, and 5 on the Pico.
Relevant links for the above stuff:
- SparkFun TB6612FNG motor driver: https://learn.sparkfun.com/tutorials/tb ... ware-setup
- Adafruit motor driver wiring guide: https://learn.adafruit.com/adafruit-tb6 ... cuitpython
- NEMA-17 "BJ42D15-26V09" stepper motor spec sheet: https://hssn.hs-ldz.pl/datasheet/BJ42D22-23V01.pdf
- Pico 1 pinout: https://datasheets.raspberrypi.com/pico ... Pinout.pdf
If someone would like for me to create a Fritzing diagram or some such diagram for the wiring, I would be happy to (haven't tried Fritzing yet, but I am willing Image may be NSFW.
Clik here to view.
).
So, the issue: I am struggling to find a MicroPython library from which I can control this stepper motor from the TB6612FNG motor driver. I've previously used this same driver and motor with a Teensy 4.1 microcontroller, which was programmed from the Arduino IDE. The SparkFun site uses Arduino whereas the Adafruit site provides tutorials for both Arduino and CircuitPython. The most promising option I have found is "RpiMotorLib" (link: https://github.com/gavinlyonsrepo/RpiMo ... ip-or-pipx). This is made with Raspi computers in mind, as opposed to the Pico or some such Raspi microcontroller. For this reason, I am unsure of the difference between the GPIO pins on a Raspi 4 vs. the GP or SPIO pins on the Pico 1. However, this library provides a specific example for the TB6612FNG motor driver with a stepper motor, so it seems to be a promising option.
Can anyone provide any advice regarding whether this library would work with a Pico 1? And if not, does anyone else have any other suggestions? Though I could write something myself, I would like to avoid doing so.
I have also found Blinka from Adafruit, whose original use case is to allow users to utilize CircuitPython libraries on MicroPython devices (link: https://learn.adafruit.com/circuitpytho ... cuitpython). However, this honestly seems to be a bit bulkier than what I'm wanting, such that writing a few custom functions seems overall more useful, but I could be entirely wrong. (Why more useful? If I use stepper motors with a Pico in the future, it would be nice to have a compact MicroPython library that works, as opposed to converting from CircuitPython to MicroPython every time).
So, to conclude, I'm looking to drive a NEMA17 stepper motor via a SparkFun TB6612FNG motor driver using a Pico 1 running MicroPython. If anyone could recommend a MicroPython library that allows this to work, I would appreciate it! Otherwise, writing my own or possibly using Blinka (along with the Adafruit CircuitPython library) are also potential options.
Thank you for reading, and thank you in advanced for your help!
-
I am looking to control a stepper motor via a SparkFun TB6612FNG motor driver using a Pico 1 that is running MicroPython that I'm programming via VS Code. The stepper motor is a NEMA-17 "BJ42D15-26V09" that I pulled from a scrapped Ender-3. I've wired the motor to the driver according to a guide from Adafruit (their motor driver uses the same IC). Given that the Adafruit guide references a Metro board for control, I've connected to pins 1, 2, 4, and 5 on the Pico.
Relevant links for the above stuff:
- SparkFun TB6612FNG motor driver: https://learn.sparkfun.com/tutorials/tb ... ware-setup
- Adafruit motor driver wiring guide: https://learn.adafruit.com/adafruit-tb6 ... cuitpython
- NEMA-17 "BJ42D15-26V09" stepper motor spec sheet: https://hssn.hs-ldz.pl/datasheet/BJ42D22-23V01.pdf
- Pico 1 pinout: https://datasheets.raspberrypi.com/pico ... Pinout.pdf
If someone would like for me to create a Fritzing diagram or some such diagram for the wiring, I would be happy to (haven't tried Fritzing yet, but I am willing Image may be NSFW.
Clik here to view.

So, the issue: I am struggling to find a MicroPython library from which I can control this stepper motor from the TB6612FNG motor driver. I've previously used this same driver and motor with a Teensy 4.1 microcontroller, which was programmed from the Arduino IDE. The SparkFun site uses Arduino whereas the Adafruit site provides tutorials for both Arduino and CircuitPython. The most promising option I have found is "RpiMotorLib" (link: https://github.com/gavinlyonsrepo/RpiMo ... ip-or-pipx). This is made with Raspi computers in mind, as opposed to the Pico or some such Raspi microcontroller. For this reason, I am unsure of the difference between the GPIO pins on a Raspi 4 vs. the GP or SPIO pins on the Pico 1. However, this library provides a specific example for the TB6612FNG motor driver with a stepper motor, so it seems to be a promising option.
Can anyone provide any advice regarding whether this library would work with a Pico 1? And if not, does anyone else have any other suggestions? Though I could write something myself, I would like to avoid doing so.
I have also found Blinka from Adafruit, whose original use case is to allow users to utilize CircuitPython libraries on MicroPython devices (link: https://learn.adafruit.com/circuitpytho ... cuitpython). However, this honestly seems to be a bit bulkier than what I'm wanting, such that writing a few custom functions seems overall more useful, but I could be entirely wrong. (Why more useful? If I use stepper motors with a Pico in the future, it would be nice to have a compact MicroPython library that works, as opposed to converting from CircuitPython to MicroPython every time).
So, to conclude, I'm looking to drive a NEMA17 stepper motor via a SparkFun TB6612FNG motor driver using a Pico 1 running MicroPython. If anyone could recommend a MicroPython library that allows this to work, I would appreciate it! Otherwise, writing my own or possibly using Blinka (along with the Adafruit CircuitPython library) are also potential options.
Thank you for reading, and thank you in advanced for your help!
-
Statistics: Posted by goldenlark_ — Wed Jan 01, 2025 3:46 am