PyCon JP 2024

Fun with microcontrollers: Building a digital sundial using Python
2024-09-27 , 4F Track3

Using Python to program physical devices is both possible and fun.

Let’s explore what you can accomplish with just a bit of Python, a microcontroller, and a small display by using them to build a digital sundial that you can carry in your pocket.


The objective of this talk is to show how easy it is to build a Python application which runs on a single board computer. It will walk attendees through the steps of getting a Python application running on a microcontroller that is attached to a small display.

We use a circle drawn on the display to show the sundial broken into its different parts – dawn, daytime, twilight, and night. In order to correctly calculate the boundaries between these parts, we need the local time for solar day events.

For a given latitude-longitude, we can get that data from the sunrise-sunset.org API, the use of which is free (as long as attribution is given). Once we have the details for solar events, we have all the information we need to draw the sundial on the display.

The rest of the presentation shows the implementation of the digital sundial - both the Python code and the hardware.

NOTE: Depending on which ends up working better, the hardware platform used will either be a Raspberry Pi Zero using CPython or an Adafruit Feather M4 Express using CircuitPython.


Why did you choose this topic?:

I am interested in using Python to solve everyday problems. Microcontrollers are an inexpensive way to tackle small problems in the physical world. This topic allows me to bring those together in a surprisingly easy way.

Knowledges and know-how the audience can get from your talk:

From this talk, attendees will understand how to get started writing Python applications that run on a computer about the size of their thumb.

Prior knowledges speakers assume the audience to have:

Basic understanding of Python

Audience experiment:

Beginner

Language of presentation:

English

Language of presentation material:

English

See also: Fun With Microcontrollers

Scott Irwin is a senior engineer at Bloomberg, where he has worn many hats. During his decade at Bloomberg, he has led teams, developed Python applications and libraries that are part of the tools used by the company’s clients to discover and use relevant functionality on the Bloomberg Terminal, and taught internal training courses.

Scott is also a Python educator who has led live online training events hosted on the O'Reilly learning platform.