CircuitPython Libraries on Linux & Google Coral

The next obvious step is to bring CircuitPython ease of use back to 'desktop Python'. We've got tons of projects, libraries and example code for CircuitPython on microcontrollers, and thanks to the flexibility and power of Python its pretty easy to get it working with micro-computers like Google Coral or other 'Linux with GPIO pins available' single board computers.

We'll use a special library called adafruit_blinka (named after Blinka, the CircuitPython mascot) to provide the layer that translates the CircuitPython hardware API to whatever library the Linux board provides. For example, on Coral we use the python libgpiod bindings. For any I2C interfacing we'll use ioctl messages to the /dev/i2c device. For SPI we'll use the spidev python library, etc. These details don't matter so much because they all happen underneath the adafruit_blinka layer.

The upshot is that any code we have for CircuitPython will be instantly and easily runnable on Linux computers like Google Coral.

In particular, we'll be able to use all of our device drivers - the sensors, led controllers, motor drivers, HATs, bonnets, etc. And nearly all of these use I2C or SPI!

Wait, isn't there already something that does this - Periphery?

Periphery is a pure python hardware interface class for Coral, it works just fine for I2C, SPI and GPIO but  doesn't work with our drivers as its a different API

By letting you use CircuitPython libraries on Raspberry Pi via adafruit_blinka, you can unlock all of the drivers and example code we wrote! And you can keep using periphery if you like. We save time and effort so we can focus on getting code that works in one place, and you get to reuse all the code we've written already.

What about other Linux SBCs?

Yep! Blinka can easily be updated to add other boards. We've started with the one we've got, so we could test it thoroughly. If you have other SBC board you'd like to adapt check out the adafruit_blinka code on github, pull requests are welcome as there's a ton of different Linux boards out there!

This guide was first published on May 12, 2019. It was last updated on Mar 28, 2024.

This page (CircuitPython & Coral) was last updated on Mar 08, 2024.

Text editor powered by tinymce.