Ometh Abeyrathne
Email ometha12@gmail.com

Home/AI/MicroNet

MicroNet

A neural network library in C++ small enough to run on an ESP32 microcontroller, and the end of a long habit of writing networks from scratch.

When
2023 to 2025
Built with
C++, ESP32, PlatformIO, C, Python, Fortran

MicroNet is a neural network that runs on an ESP32, a microcontroller with about half a megabyte of memory. There is no framework underneath it. It is my own C++ network library, ported to the chip.

The example is four inputs, two hidden layers of six neurons each, and two outputs, running on the chip itself. The sizes are a few numbers in one file, and the limit is the memory: the README's advice for a network that doesn't fit is to make it smaller, or to move from floating-point to fixed-point numbers.

How I got there

I didn't want to use neural networks without knowing what was inside them. So I kept writing them from nothing, each time a little further. MicroNet is where that ended up.

One neuron at a time

The first was a perceptron network in C in 2023: three perceptrons wired up to behave like an XOR gate, written with no references. Its README apologises for the oversights, and admits I couldn't get the NOT gate's bias right.

Then a single neuron in Python that tells apples from oranges by weight, diameter and colour. And the exercises from the Neural Networks from Scratch book.

Whole networks

By 2025 it was a proper multi-layer perceptron in C++, trained to learn XOR, then a better one built on a matrix library. There is also a perceptron in Fortran.