Skip to the content
PCBKitNew board
2 layers42 × 14.2 mmDml21m, the printed circuit board in 3D

Notes on Machine Learning on edge for embedded/sensor/IoT uses

Size
42 × 14.2 mm
Copper layers
2
Thickness
1.6 mm
Parts
34
Nets
42
Pads
136
Tracks, vias
0, 0
Routed
Not yet
KiCad
KiCad 9.0 (file 20241229)
Created
17 Jul 2019
Updated
24 Sep 2026

Overview

Dml21m is an open-source printed circuit board by jonnor, from the jonnor/embeddedml repository on GitHub. It is a 2-layer board of 42 × 14.2 mm with 34 parts on 42 nets.

It is built around the PY32F003F18U6TR, LIS2DH12 and LP4054HB5F, with the XC6206P332MR, BC547B and PTS647SM50SMTR2LFS among its other parts. Its parts include 11 resistors, 6 ICs, 5 capacitors, 3 diodes and 3 connectors. It belongs with the sensors and measurement boards of this library.

Main components

6

README

README.md

Machine learning on embedded devices

Focused primarily on running inference/prediction/feed-forward part on a microcontroller (or small embedded device). Training phase can run on a standard computer/server, using existing tools as much as possible.

Background

What and when to use machine learning

The defaults right now are to do conventional signal processing (no learning) in sensor, and stream raw data to the cloud for storage and processing. Machine learning happens in the cloud. If gateways are used, they mostly forward communication (no data processing).

On-edge processing valueable when

  • Local response needed. Autonomy
  • Adaptable response needed. Over time, in context.
  • Low/predictable latency needed
  • Sending raw sensor data has privacy implications. Audio, video.
  • Unreliable connection
  • High bandwidth sensor input. Audio, video, accelerometer/IMU, current sensor, radiowaves.
  • Low bandwidth algorithm output
  • Events of interest are rare
  • Low energy usage needed
  • Full/raw sensor data is not valuable to store
  • Sensor system should be low cost

Example usecases

  • Predictive maintenance, using audio/vibration data
  • Activitity detection for people, using audio/accelerometer data. Assistive tech, medical
  • Appliance disaggregation, using aggregated power consumption data. "Non-Intrusive Load Monitoring" (NILM)
  • Anomaly/change detection for predictive maintenance, using audio/vibration data, or electrical data
  • Gesture recognition as human input device, using accelerometer/gyro data.
  • Speech/command recognition as human input device, using microphone. Keyword/Wake-word detection
  • Battery saving in wireless sensors. Normally sending day/week aggregates, on event/anomaly detection send data immediately
  • Health status of animals via activity detected using accelerometer
  • Monitoring eating activity using accelerometer 1
  • Environmental monitoring, using microphone to detect unwanted activity like cutting down trees
  • Adaptive signalling and routing for wireless transmission in Wireless Sensor networks
  • Electronic nose using arrays of MEMS detectors
  • Material identification using reflecive spectrometer 1

More notes on Applications

Motivation

  • Why the Future of Machine Learning is Tiny (devices) Tiny Computers are Already Cheap and Everywhere. Energy is the Limiting Factor.We Capture Much More Sensor Data Than We Use.
  • embedded.com: Bringing machine learning to the edge Predictions are much lower bandwidth than the raw sensor data (e.g. video) It allows for local adaptation in the AI logic (L-DNN) It achieves lower latency between observed event and action resulting from AI logic "the most important question is what is the least amount accuracy and computation complexity we can do while still delivering the business value?" Top mistake: "Continuing with the top down approach ‘let’s make it perform the task first and then squeeze it on device` instead of switching to bottom up ‘let’s make it run on device and fulfill all hardware constraints first, and then tune it for the task at hand’."
  • How to run deep learning model on microcontroller with CMSIS-NN. Why run deep learning model on a microcontroller? Sensitive data gets to the cloud, photos, and audio recordings. The company who sells this may charge a service fee to use its service and even worse sell your private data. It won't work without the network connection to the server. Data traveling back and forth between the device and server introduces lag. Require network and wireless hardware components on the circuit design which increase the cost. It might waste bandwidth sending useless data.

Own contributions

Presentations

Lecture notes

Open source software

  • emlearn. Machine Learning inference engine in C99 for Microcontrollers and Embedded devices. Since 2018.
  • emlearn-micropython. Efficient and convenient Machine Learning and DSP for MicroPython. Since 2024.

Fun projects

Commercial projects

Learning material

Books

Articles

Tools

Open-source

  • emlearn. Inference engine for microcontrollers. Supports converting scikit-learn models to plain C code. No dynamic allocations. No runtime needed.
  • TensorFlow Lite for Microcontrollers. Supports neural network models made with TensorFlow (including Keras). Can run on wide range of platforms. Since November 2018. Supports ARM Cortex M, RISC-V, ESP32/Xtensa and Linux/MacOS host. Requires a runtime, aroud 20 kB.
  • onnx2c. Allows generating C code from ONNX models.
  • iree. Compiler. Has bare metal target. Around 30 kB runtime.
  • executorch. C++ framework for deploying PyTorch models. Focused on custom backends, NPUs etc. Microcontroller CPU less in focus. Around 50 kB runtime. Supports bare-metal via "Portable" operations, or specialized for Cortex M.
  • nnom - Fixed-point neural network compiler for microcontrollers. Supports wide range of networks. Outputs plain C code. Can use CMSIS-NN on ARM Cortex M.
  • Embedded Learning Library by Microsoft. Discontinued in 2024 Set of C++ libraries for machine learning on embedded platforms. Includes code for kNN, RandomForest etc. Also has some node-based dataflow system in place it seems. JavaScript and Python bindings.
  • uTensor. Export Tensorflow model to mbed/ARM microcontrollers. Not supported on ESP32 or RISC-V or similar. Lower activity since 2021.
  • sklearn-porter. Can compile DecisionTreeClassifier and SVC models to C. Uses dynamic memory. Not optimized for use on embedded devices.
  • microTVM. Depends only on the C standard library, and runs bare metal such as STM32 and NRF52 microcontrollers. Is under development. Which models are supported on microcontrollers not specified.

Low-level libraries

  • gemmlowp. Low-precision matrix multiplication. Only general matrix multiplication ("GEMM"). C++11
  • CMSIS-NN. Neural network operations for ARM Cortex M.
  • esp-nn. Neural Network functions Espressif ESP32 (Xtensa and RISC-V).
  • . Can be used bare-metal, but more focused on mobile/server grade (Cortex A+ etc).

Proprietary

  • X-CUBE-AI for STM32

Historical

  • nn4mc_cpp. Neural Networks for Microcontrollers. Supports Keras natively. Provides instructions for PyTorch et.c via ONNX. Documentation for using from Python is lacking, as well as the type of networks supported. Does not seem maintained since 2020.
  • micromlgen. Generate C code for microcontrollers from Python's sklearn classifiers. Archived in 2024.

Models

A range of Machine Learning models are useful in an embedded devices setting. Classical methods are used when the amount of data is quite small, and neural networks for large datasets and complex inputs.

Below are notes on the various models in the context of embedded Machine Learning, including model size and compute-time optimization.

More topics

State of the Art in 2019

Of ML inference on general-purpose microcontrollers.

text
TODO: update for 2023
  • Deep models have efficient implementations for ARM Cortex-M. Ex: CNN and RNN in CMSIS-NN, FC in uTensor
  • Some implementations available for non-neural models that can be used. Ex: SVM,RF,AdaBoost in sklearn-porter
  • A few special-designed ML algorithms made. Ex: ProtoNN, Bonsai
  • Basic tools available for converting Tensorflow models
  • Keyword-spotting/wake-word on audio well established. Used in commercial products (Alexa etc)
  • Human activity detecton on accelerometers.
  • Computer vision is actively developed
  • Lots of research and many announcements of low-power co-processors, but little on market yet

Limitations

  • Neural models lacking for non-ARM micros. ESP8266/ESP32
  • Non-neural models missing inference engines designed for microcontrollers
  • "Small DNN" work mostly on computer vision for mobile phones (model size 1000x of uC)
  • Few/no pretrained models available. Transfer learning little explored?
  • Very little documentation of entire development process. From planning, data aquisition, model design
  • Best practices underdocumented (or underdeveloped?)

Ways of advancing, make contributions

  • Faster inference. Power saving, or bigger problems.
  • Smaller models. Cheaper MCU, or bigger problems.
  • Better accuracy on a problem. Better user experience, new usecases
  • Solve a concrete usecase. Easier to deploy similar usecases
  • Comparison between approaches. Microcontroller, ML model
  • Libraries or tools. Lower time to market, enable more developers

Parts

34
QtyValueFootprintReferences
510kResistor_SMD:R_0402_1005MetricR1, R2, R3, R6, R7
210uF 10VCapacitor_SMD:C_0402_1005MetricC1, C4
2120RResistor_SMD:R_0402_1005MetricR8, R11
21uF 10VCapacitor_SMD:C_0402_1005MetricC3, C5
23.3kResistor_SMD:R_0402_1005MetricR4, R5
2LEDLED_SMD:LED_0402_1005MetricD3, D4
2TP_PCBTestPoint:TestPoint_Pad_D1.0mmTP1, TP2
1100nF 10VCapacitor_SMD:C_0402_1005MetricC2
11N4001Diode_SMD:D_SOD-323D2
11kResistor_SMD:R_0402_1005MetricR9
133RResistor_SMD:R_0402_1005MetricR12
1BC547BPackage_TO_SOT_SMD:SOT-23Q1
1BM7161dml10:BM7161U6
1BuzzerBuzzer_Beeper:Buzzer_Murata_PKMCS0909EBZ1
1Conn_ARM_SWD_TagConnect_TC2030-NLConnector:Tag-Connect_TC2030-IDC-NL_2x03_P1.27mm_VerticalJ2
1Header 2.54mmConnector_JST:JST_SH_SM08B-SRSS-TB_1x08-1MP_P1.00mm_HorizontalJ4
1LIR1225dml20m:Battery_CR1220-HorizontalBT1
1LIS2DH12Package_LGA:LGA-12_2x2mm_P0.5mmU1
1Li charger 4054Package_TO_SOT_SMD:TSOT-23-5U2
1PTS647SM50SMTR2LFSJumper:SolderJumper-2_P1.3mm_Open_Pad1.0x1.5mmSW1
1PUYA P25Q16SH-SSH-ITPackage_SO:SOIC-8_5.3x5.3mm_P1.27mmU5
1PY32F003F18U6TRPackage_DFN_QFN:QFN-20-1EP_3x3mm_P0.4mm_EP1.65x1.65mmU3
1USB_C_Receptacle_PowerOnly_6PConnector_USB:USB_C_Receptacle_GCT_USB4125-xx-x_6P_TopMnt_HorizontalJ5
1XC6206P332MRPackage_TO_SOT_SMD:SOT-23-3U4

Questions

How big is the Dml21m PCB?

It measures 42 × 14.2 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Dml21m use?

34 parts, built around the PY32F003F18U6TR, LIS2DH12, LP4054HB5F and XC6206P332MR. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Dml21m KiCad files?

From the jonnor/embeddedml repository on GitHub, at the commit this page was made from: the board is projects/dollar_tinyml/hardware/dml21m/dml21m.kicad_pcb and its schematic emlearn/pulsemeter/hardware/ledarray/ledarray.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Dml21m design in my own project?

Its repository states no licence, so its author keeps all rights: ask jonnor before reusing the design.

More from jonnor/embeddedml

5
  • 2 layers52 × 26 mmDml10, the printed circuit board in 3D

    Dml10

    jonnor/embeddedml

    Notes on Machine Learning on edge for embedded/sensor/IoT uses

    51 parts317
  • 2 layers40 × 20 mmDml20m, the printed circuit board in 3D

    Dml20m

    jonnor/embeddedml

    Notes on Machine Learning on edge for embedded/sensor/IoT uses

    37 parts317
  • 2 layers15.2 × 10 mmLedarray, the printed circuit board in 3D

    Ledarray

    jonnor/embeddedml

    Notes on Machine Learning on edge for embedded/sensor/IoT uses

    16 parts317
  • 2 layers12 × 15.5 mmBm7161, the printed circuit board in 3D

    Bm7161

    jonnor/embeddedml

    Notes on Machine Learning on edge for embedded/sensor/IoT uses

    16 parts317
  • 2 layers14 × 12.5 mmTinypulse, the printed circuit board in 3D

    Tinypulse

    jonnor/embeddedml

    Notes on Machine Learning on edge for embedded/sensor/IoT uses

    12 parts317

Similar boards

  • 2 layers24.5 × 21.8 mmCharge core, the printed circuit board in 3D

    Charge core

    RockyMtnWolf/PY32-BQ25798-SolarCap-Charger

    Solar MPPT supercapacitor charger: PY32F003 + TI BQ25798. KiCad hardware (core board + test baseboard) and firmware with UART AT-command runtime configuration.

    39 parts1AGPL-3.0
  • 4 layers121.9 × 109.2 mmPlinkyblack hwmidi jacks, the printed circuit board in 3D

    Plinkyblack hwmidi jacks

    plinkysynth/plinky_public

    a public release of the plinky sw and hw

    300 parts227
  • 4 layers38.6 × 39.5 mmRuuvitag revb71, the printed circuit board in 3D

    Ruuvitag revb71

    ruuvi/ruuvitag_hw

    RuuviTag hardware projects

    64 parts115
  • 6 layers30 × 48 mmHolter, the printed circuit board in 3D

    Holter

    peterisza/mobilecg

    MobilECG II is an open source clinical grade Holter ECG. For more information, please visit http://mobilecg.hu.

    231 parts66
  • 4 layers80.7 × 78.7 mmOstentus hw, the printed circuit board in 3D

    Ostentus hw

    golioth/ostentus-hw

    A PCB front panel for Golioth's Aludel hardware platform

    77 parts17CERN-OHL-P-2.0
  • 4 layers36 × 46 mmPcb LR1110, the printed circuit board in 3D

    Pcb LR1110

    TheThingsIndustries/generic-node-te

    Generic Node Tracker Edition

    162 parts10
  • 2 layers85 × 54 mmImcp devkit, the printed circuit board in 3D

    Imcp devkit

    htmicron/thirdpartyHT32SX

    Third party contributions to HT32SX (https://github.com/htmicron/ht32sx)

    183 parts2