Using a JRK with Micropython

Hello! A while back I finally managed to make a working speedometer for my car using a Raspberry Pi with a JRK G2 21v3 and a one of the micrometal gear motors with feedback. At the moment I’m using USB control with good success. However, the RPi in my car is doing several other things and I had the idea to make the speedometer more standalone so that I don’t have to worry about boot times or losing it if some other software on the Pi hangs or causes issues. My plan was to use a Pi Pico as I already have the code written in Python and I figured it would be a fairly straightforward transition. However, as things go, I’m not sure it’s quite as “plug and play” as I was hoping it was going to be.

Long story short, is there something like a Micropython library for the JRK or what all would be involved in that? I had originally set up the JRK via I2C, but had some issues with that on the original Pi setup that I don’t think the Pico will have, so my plan was to go back to that (can always fall back to serial or SPI if needed, though I think all of them will still need a library). I see the Python example in the documentation for the JRK uses smbus2, but is this actually necessary on the Pico? Is it possible to talk directly with the I2C bus via the machine library? I haven’t really played with microcontrollers for the better part of 10+ years and even then it was using stuff like PBasic or really low level stuff, so trying to wrap my head around things. I know there is Arduino code out there for the JRK, so I’m sure this can be done, but as the rest of my code is already in Python and I’ve never used an Arduino, I’m not familiar with their code and don’t really want to port everything if I can get away with it.

Hello.

We do not currently have a Micropython library for the Jrk G2, but prompted by your post, we have added a Micropython I²C example (similar to the Python example you mentioned) to the Jrk G2 user’s guide. You can find it in the “Example I²C code for MicroPython” section. As described there, it is designed to run on the Raspberry Pi Pico as written, so you can use that as a starting point.

Brandon

Awesome, thanks! I’ll take a look and start playing with it to see what I can do.

1 Like