Skip to content
ATC
All projects

Embedded library

Micropython Geiger

A Geiger-counter library for MicroPython, so a microcontroller can read a radiation sensor without dragging in a full CPython build.

Role
Creator
Period
2020
Micropython Geiger screenshot

The problem

MicroPython runs on microcontrollers where every kilobyte of flash matters. A Geiger counter needs pulse counting, timing and a little bit of statistics — a small problem that the standard library does not cover on a device this constrained.

The approach

The library provides the small, sharp set of primitives a counter actually needs: read the pulse count over an interval, convert it to an estimate of the dose rate, and expose the raw counts for anyone who wants to do their own statistics.

Designing for MicroPython rather than porting from CPython kept the module small and the memory profile flat. That constraint is the reason the library is usable on a device with 32 kB of RAM, which is the class of hardware a background monitor actually ships on.

Engineering highlights

  • Written for the target

    Porting a CPython module and trimming it afterwards leaves the wrong abstractions behind. Designing against MicroPython's constraints from the start leaves only what the device needs.

  • Raw counts stay available

    The library exposes the underlying count as well as the derived dose rate, so downstream code is never forced to trust the library's statistics.

At a glance

Runtime
MicroPython
Hardware
Geiger-Müller tube

Stack

  • Python
  • MicroPython
  • Embedded