Python Matrix Creator HAL using SPI


I just wrote a simple python implementation for using everloop and some sensors directly over the spi / wishbone bus. This gives python developers a much better performance communicating fastly with the creator device.

The code is still under heavy development, eventually i’ll put it on PyPi as a new module.

It only uses matrixio-creator-init and python_periphery (SPI).


[Solved] Unable to get sensor data of Matrix Creator on RPI 3b
Using gpio's for pwm through MALOS layer

I was reading about the spi bus and trying to understand why it exists. Thank you for your clear instructions on enabling it on the pi. However, page 10 of this thread

Has a post by bomba that indicates more configuration is necessary

Add the device tree overlays in /boot/config.txt/

Bringing up the can interface and Adjusting the bitrate to match your needings.

Install can-utils

Are these steps needed ? I realize that’s an old thread and do not know if it’s relevant


i don’t know, i use the default settings provided by the overlay / raspi-config and i don’t have any needs to change it. no lags so far. :slight_smile:


Cool! Did you also manage to get the Sound from Matrix voice? Python Errors with pyaudio on missing matrix_micaray_channel8 (missing on the creator board and not in tmp…)


Not realy it maybe possible to implement mic access through spi, but they are currently developing some kernel modules for pcm and other stuff, so it is better to wait for that (, or to use the temp files. My next target is to implement some basic gpio access and eventually pwm. All in mind to switch to the kernel dirvers, when they are official available.



  • Docker example
  • python3 compatibility


First attempts with GPIO / PWM, Looping Louie and he went crazy.


Now you can build your own Looping Louie with Python. :slight_smile:

I have just commited the reimplementation of the python-matrixio-hal. It now uses the native cpp Matrix HAL drivers and not the SPI interface anymore. Follow the readme.

Change log:

  • GPIO / PWM support added + Led Examples (using GND and PIN 0)
  • setup script for installing as python package to your environment / virtualenv
  • the docker example is currently brocken, needs investigation
  • examples moved to examples folder
  • temporary fix for the everloop matrix HAL driver (brocken by myself, pull request is open).

Final thoughts:
The reimplementation is almost as fast as the old one, in some parts even faster. By moving away from the SPI device to the matrix drivers, it should be easier to keep the lib up to date in the future.


  • docker example fixed

now you can install the package with pip:

pip install python-matrixio-hal


This is nice! I have got the leds running on a docker, but I also want to be able to access the mic array.
I could not find then in your code, was is not implemented yet?


I’m still waiting for the kernel modules to be officially released, then python developers can use pyaudio. What do you want to implement with the mic array? doa, speech recognition, or something else?


I an creating an add-on for home assistant (Hass IO ).
So far I have split all the Snips services and have separate add ons for that.
An add-on for hassio is actually just a docker container, so I have used your example to build an addon.

This runs nice and the leds spin like a maniac :smiley:

So, next step is to be able to use the mic array to detect my hotword and do some nice visual effects :slight_smile:

I will see if a can post a small video :slight_smile:



one way could be using snowboy it should work with arecord and the matrix alsa pipes, but the snd device needs to be forwarded to the docker container. an other way could be using the mics directly through the cpp hal drivers, but i did not implement that in the python driver. maybe i do some hacks on the weekend to get snowboy integrated in the python hal drivers, or pocket sphinx

you can also use the matrix malos services to implement your addons, there is also a wakeword detection engine. For me the python hal drivers are rather meant to be used for “performance” critical implementations, or simple applications where there is no need for the malos service overhead.

keep in mind the python hal driver is using the spi device with no locking mechanism so having multiple applications using the spi device could make some trouble with the mic array. thats one reason they are implementing the matrix kernel modules, to coordinate the different driver to not use the spi device in parallel.


I actually have a Snowboy Addon to work with Snips, see my repo here:

I want to implement the hermes protocol from Snips, so this Matrix add on will need to function as the Audio Server. The HotWord add-on (already working), will then hopefully be able to light up the leds if the hotword is detected.
At this point, all the addon play nice together, I use the Snips Audio Server for now. This works with the alsa drivers (usb mic).

I do not know if you are familiar with HassIO, but that is based on a resin image, but with spi enabled.
You can not install any software on it (well, you can but that kinda blows the whole hassio idea)
I tried to get things going on docker with the matrix malos (and the kernel modules), but could not (yet) get things running when I saw this post. The kernel modules was my first point, so that the different apps using SPI would not clash (in theory)
So I tried to get your example running and was happy it worked! After that I saw no options to access the mic_array.
While I would really like to have it, at this point I am one step further being able to access the Matrix Voice on a docker container, in the form HassIO Addon :slight_smile:

My next step will probably be to see if I can get the kernel models running in a container and hopefully as an addon after that.


ah ok, maybe we can discuss that on a chat plattform (hangout, irc.) write me a private message, so i can share you some of my experience with the matrix stuff.


Ok cool, although my weekend is quite occupied :wink:
This is my video by the way:


I have got the MalOS working in a docker now and could run the everloop.js :slight_smile:

That is a big step forward for me, next to try the micarray



python-matrixio-hal version 1.1.0 got released


  • support for the new matrix cpp hal drivers
  • it now supports both kernel modules and the legacy spi-device
  • use of the new firmware version and everloop size detection