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.

17 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.

  3. I guess no one has told any of you the I2C bus exists and is easily accessable from the PCI slots in your desktops ….

    Just grab an old modem or whatever card, cut all the traces except the I2C (and/or SPI) pins, solder on a pin header and/or some old VGA/HDMI/CAT5/serial cable to get it out of the case (you can go out the PCI slot below it or out the front of a 5.25″ bay with a cover that slips off to hide the cable, since apparently some of y’all need hand holding because you’re too busy NOT looking at pinouts), and tada you have access to one of a handful of the PCs I2C buses.

    Considering the convoluted way some of y’all put your projects together, daisy chaining dev boards together because “well this tutorial tells me how to plug this into that, but this that tutorial plugs that into this” instead of ….. ACTUALLY LEARNING SOMETHING ….. when using these systems specifically intended to learn electronics on…….I’m honestly not surprised none of y’all tried to see if a I2C line was inside a modern PC.

    I’m not surprised, but I am very disappointed.

    PS – No, I will not be nice. Nice is what got us to this place of superficial knowledge actually built upon nothing but plugging this wire into that one, and the raise of the willfully maliciously ignorant, and empowered opinionated Karens. It’s time for the bad feeling of public ridicule to come back. Not emotional cruelty, we knew the difference in the before times. But this whole ‘look I did a thing (by following a step by step tutorial and learning nothing of substance), but don’t look at me because I’m awkward and nonconfrontationally OCD about eating in my cry closet full of pop-culture fanfic art I don’t show anyone because I suck at everything I’ve only ever tried once and failed at therefore my biased assumption is the only sufficiently informed correct one about what the zeitgeist thinks of me and if you don’t agree then that is bullying and being negative and negativity is baaaaaaaaad!’ thing the post n’oughties generations have going on need to end. It’s making you all wienies barely able to function, much less express any level of confidence…. Some of the loudest proponents of inclusivity in the modern age I have come across in my travels have been some of the most narrow minded prejudicial people I have ever met. And I’m from San Bernardino…..yeah, THAT San Bernardino…..with family from Arizona, Florida, Chicago, and Missouri. So seriously, and I am saying this in the hopes of sparking some self-awareness and internal reflection, y’all need help…. Pretty words don’t make pretty people.

    In this essay I will…….

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.