Bridging The PC And Embedded Worlds With Pico And Python

Although protocols like I2C and SPI are great for communicating between embedded devices and their peripherals, it can be a pain to interface these low-level digital interfaces to a PC. [Alexandre] typically used an Arduino to bridge between the PC and embedded worlds, but he got tired of defining a custom serial protocol for each project. Inspired by MicroPython’s machine module, [Alexandre] has developed u2if—an implementation of some of MicroPython’s machine module for PC—using a USB-connected Raspberry Pi Pico to bridge between a PC and low-level digital interfaces.

u2if consists of two parts: the PC portion is a Python implementation of a portion of the MicroPython machine module, and the Raspberry Pi Pico receives some custom C++ firmware. Thus far, [Alexandre] has implemented functionality for the onboard ADCs, I2C, SPI, UART, and GPIO lines as well as additional support for I2S sound and the WS2812B addressable LED.

Development board for Raspberry Pi Pico.

In addition to the u2if package, [Alexandre] has designed a PCB to break out all of the Raspberry Pi Pico’s interfaces in a handy 3×3.9″ board. We especially like that multiple headers are supplied for I2C, including one with enough space to mount an SSD1306 OLED display.

We think this could be an incredibly useful tool, and what makes it even more impressive is that it uses a board many of us already have laying around. If you want a dedicated device for interfacing with low-level digital buses, you may want to check out the GreatFET.

16 thoughts on “Bridging The PC And Embedded Worlds With Pico And Python

  1. That’s pretty neat! A bit like Adafruit Blinka, which lets you run CircuitPython code and libraries in cpython with either a single board computer or any computer and an interface board like the mcp2221A. It’s really neat, but it definitely doesn’t have as many gpio as the Pico.

    1. And now I saw the readme actually even mentioned Blinka, though only with ftdi. I try not to buy ftdi chips, and the mcp2221a is much cheaper anyway, just a couple bucks direct from Adafruit for the breakout board. Probably the coolest trick I’ve seen is being able to graph data live from the board in Jupyter. The mcp2221a did have one quirk of dealing with the scd30 but that’s been worked around (it doesn’t like the weird states even the sensor gets reset).

      Apparently the mcp2221 is just a pic with custom firmware factory loaded. I’ve definitely mistaken it for the similar-sized qt Py board I often have nearby, and it seemed plausible they were internally similar, though I suppose it makes sense microchip would use a pic preferably to a samd21. (Just like how my atmel ice apparently uses an avr32 chip, using what they’re most familiar with, they’ve had pic longer than they’ve owned Atmel) I’ve looked into firmata a few times but could never find enough info on it to actually use it for anything useful.

      Very cool work.

  2. Geez. My nephew, as a pre-teen, did this over 10 years ago using a Teensy 2. I am not certain, but think that he used firmata. He later used a Teensy 3.2 + bus pirate + buffered I/O + GPIB (IEEE488) to make a ‘universal’ bridge for the lab where he was working at the time.

    Search it. Bazillions of people have been doing this for bazillions of years. Regurgitation.

    1. Agree. Also dozens of break-outs and other designs like this for Arduino or Blue Pill have been produced over the last 12 years. The Kickstarter ones flop. The other ones form the various companies also flop unless the company built a whole ecosystem and pours tones of engineering and software into support and seminars and tours and repos and — it flops.

      Maybe the magic touch of government support and subsidized engineering talent and waiting till everyone else has tried will make it work for RPi. Maybe some firm education purchase contracts will help.

    2. Hmmm, it seems like this uses a board that wasn’t available when your nephew did it. I enjoyed reading about this, and think it’s a neat project.

      Perhaps you should look for the good in each project and relax your restrictions on seeing similar concepts used in more than one build. You may have seen a bazillion of these, but there are other people who haven’t, and still other people (like me) who don’t mind seeing good ideas used in multiple projects.

    3. It´s not really the same.
      Here you got a board that can already run micropython. With this python lib + firmware you can do actually all the micropython development on the computer, with all the debugging / editor / code analysis it can bring, then just move the code over the board when it´s ready.

      Firmata on the other hand can run on many more micro-controllers, even the most anaemic ones: But at the end you still have a target device running Firmata. It´s the goal.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.