Fred Cave's MicroPython Story

Contents

Introduction

I have long held an interest in processors and digital design since the beginnings of the consumer accessible era of the microcomputer in the late 1970s. Through the years I never had the time nor money to pursue this as a serious interest.

My ensuing career (amongst other things) involved muli-million dollar process control projects in large industrial processing plants. I learnt much about the operational hardware (sensors, valves, etc), motor control, industrial data buses and networks, process logic and sequencing (mainly PLC based), SCADA and so on.

All very interesting and it paid the bills but was way too expensive and involved to be called an away from work hobby.

The Emerging World of Microcontrollers

micro:bit
ATmega4808 - microcontroller with 8-bit AVR processor

In the last decade or so, computer tech magazines have been publishing articles referencing the IoT (Internet of Things) phenomena, the availability of cheap microcontrollers (MCU) and the possibilities of getting involved in an interesting new hobby.

OK, so where to start? Just prior to Christmas 2021 I came across an advertisement from a local electrical & computer department store offering the micro:bit V2 at a good sale price. Having suggested to my wife that this might make a good Christmas present I am now bitten by the bug and busily making up for decades of lost time.

The micro:bit documentation suggested the Microsoft MakeCode editor. After just a few minutes of playing with this I quickly decided that dragging graphical blocks of "code" around to build "programs" was not what pushed my buttons.

Then my online research led me to MicroPython and the Mu Editor. As well as providing the MicroPython language interpreter, Mu comes with a micro:bit specific MicroPython module, microbit, and the capability to flash user programs to this little microcontroller board.

The MicroPython Programming Language

I was aware of the increasing popularity of the Python computer language but had not used it in a serious manner. MicroPython is a slimmed down version of Python V3 designed and optimised specifically with microcontroller programming in mind. There is quite a bit of literature out there but it wasn't really what I was after.

Too often it involved Linux; a great OS but not where I wanted to go. I've played with Linux and used it successfully for the provision of critical security functions on control networks but the software I need to run for several other of my hobbies simply isn't available on this platform.

Learning a new language from YouTube videos also just doesn't work for me.

Being unable to find any useful tutorials[1] or manuals suitably pitched at a systems designer and coder with practical industry experience I armed my self with several (bulky!) books on the Python V3 language, the MU Editor and a micro:bit and taught myself by practical trial and error what MicroPython could (and couldn't) do.

The Humble micro:bit

micro:bit

What follows is my journey of discovery with the MicroPython language and executed on a micro:bit. After completing each chapter of the book I wrote short stubs of code, flashed it to the micro:bit and recorded what worked and what didn't work.

As stated previously in this post, MicroPython doesn't implement all the standard Python V3 language but as I discovered there is enough there to get most things done.

An entire website dedicated to using MicroPython with the simple but clever micro:bit as a program test bed has evolved from this world of discovery. The more pages I authored, the more I found needed to be written. Anyway, hopefully I have managed to cover the topic in reasonable depth!