Saturday, February 17, 2018

Tinkering with MicroPython

I recently came across a neat embedded project, MicroPython, which is a port of the Python language to ARM microcontrollers. The possibilities offered by this are amazing in my opinion. Python is used extensively by folks outside of the embedded world, software engineers, data scientists etc. By allowing embedded system programming in Python, MicroPython opens the doors for a large audience to try their hands at tinkering hardware. In addition Python being an interpreted language, you can execute any code on the device interactively, through a serial prompt on your host machine. Again this frees up the time spent in compiling code, writing FW etc, as one can simply try out new things on the device on the fly.

Super excited about this project, I decided to order a PyBoard. This is a STM32 based reference board for the MicroPython project. The MicroPython is an open source project and has been ported to a number of platforms, some of them are listed here. Since the PyBoard is the reference platform, I decided to start with this, as I figured this would have a better level of community support and compatibility. Couple of days later, I had received my PyBoard, neatly packaged in an anti-ESD bag. My first thought on seeing it was it sure is small 😊. After unpacking the board and soldering a bunch of headers, it was good to go.

Hello, World!


Every programmer starts with a Hello, World! program, or in embedded systems, a blinky LED program. On the pyboard, this is the simple script below:


from pyb import LED led = LED(1) while True: led.toggle() pyb.delay(500)
And this is the pyboard running it...


More experiments = More fun


After the blinky LED program, I tried to interface the pyboard with an 8x8 led matrix, driven by a max7219. I found a library to control an led matrix with MicroPython here, but since it could only draw single pixels, I decided to extend it with a font to draw characters. If you want to tweak the library, the datasheet for the max7129 can be found here. Here's the led matrix displaying a simple hello world program...

The library and the test program can be found here.




Future experiments


Currently I'm in the process of writing some more libraries for the pyboard to interface with various modules I have. Planning to create something useful with the pyboard in the coming weeks...




Sunday, February 11, 2018

Hello, World!

Hi there, welcome to my blog. A little bit about me - I am an electrical engineer who loves to build stuff. I absolutely can't get enough of tinkering and making things; mostly electronics, some woodworking as well. I have decided to chronicle my various projects, experiences and thoughts in this blog.

As of writing this post (02/18), I work as a hardware engineer at a major electronics manufacturer and live in the SF Bay Area. Living in the SF Bay Area is an amazing experience if you are an engineer and like to build stuff. I am really fortunate to have worked with and learnt from some of the smartest and coolest minds, and I do hope I'm able to share something smart and cool with you!