Skip to main content
BlogNewsTop News


By April 19, 2022No Comments

Written by Joey Hess

This was originally posted on Joey’s blog. For more content like this, click here.

I recently learned about the Zephyr Project, which is a rather neat embedded OS for devices too small to run Linux. This led me to wondering if I could adapt arduino-copilot to target Zephyr RTOS, and so be able to program any of the 350+ boards it supports using Haskell.

At the same time, I had an opportunity to give a talk at the Houston Functional Programmers group on February 1. So, I gave that talk about arduino-copilot.

That means, there were 2 weeks to buy hardware supported by Zephyr and port arduino-copilot to it. The result is zephyr-copilot, and I was able to demo it during my talk. You can watch it below:

YouTube player

This example can be used with any of 293 different boards, and will blink an on-board LED:

module Examples.Blink.Demo where

import Copilot.Zephyr.Board.Generic

main :: IO ()
main = zephyr $ do
        led0 =: blinking
        delay =: MilliSeconds (constant 100)

Doing much more than that needs a board specific module to set up GPIO pins etc. So far I only have written those for a couple of boards I have, but they are fairly easy to write. I’d be happy to help anyone who wants to contribute one.

Due to the time constraints I have not implemented serial port support, or PWM or ADC yet, although all should be fairly easy. Zephyr also has no end of other capabilities, from networking to file systems to sensors, that could perhaps be supported in zephyr-copilot.

My talk has now been published on youtube. I really enjoyed presenting again for the first time in 4 year), and to a very nice group of people. Thanks to Claude Rubinson for his persistence in getting me to give a talk.

If you have any questions or comments, please feel free to reach out to the Zephyr community on the Zephyr Discord Channel. 

Zephyr Project