CircuitPython: Creating Custom Boards

Want to run Adafruit’s cool new electronics Python distribution on your board? Now you can!

Over the past six months I have spent a lot of time porting different libraries to the Robo HAT MM1 board developed by Robotics Masters. This has lead to discovering a lot about these libraries, how they work behind the scenes and most importantly - what to do to add new boards in the future.

This is the second in a series of write ups I will be doing to help others who wish to port libraries for their boards. Many of the sources of information can be vague or difficult for outsiders to understand. I hope to ‘demystify’ and explain how to achieve a successful port for everyone.

Today, we will be looking at the CircuitPython (and MicroPython) platform. It is a growing community started by Adafruit and is very active. There are currently only a few different board variants - mostly produced by Adafruit - but has gotten a lot of traction lately thanks to new Crowd Supply projects (like the Robo HAT MM1).

CircuitPython is a special programming language developed by Adafruit that is based on Python but focused purely on writing code for hardware. It has many thousands of libraries for different sensors. It makes programming motors, servos, sensors and other bits easy. CircuitPython doesn’t require any software on your computer - it runs natively on supported boards and appears as a USB drive.

Before You Begin
Before you begin with porting a software library or firmware to your board, you must know a few key points about the technology you are using and be able to answer the questions below.

What processor are you using?
What architecture does it use?
Do I have access to the datasheet for this microprocessor?
Is there a similar board on the market that uses the same microprocessor?
These are very important. It will impact on many aspects of how you approach the development process.

It is very clear from the CircuitPython documentation that only a few processors are supported or maintained by Adafruit. These include the SAMD21 and SAMD51. CircuitPython is derived from the more commonly used MicroPython which supports many more processors - ESP8266, ESP32, Teensy, PIC and others. You can use the same process for porting to MicroPython as they have the same repository set up.

The datasheet for a microprocessor is absolutely vital to ensure that the board responds as expected when you compile the firmware. Without it, you will not be able to set the correct pin output functions or configure serial ports.

Once you have all the information you need about the processor you are using, you can start to look at the software and modify it to work for your custom board.”


Related Content