TinyML: Revolution in Machine Learning on Microcontrollers

Reading time: 5 min.

Artificial intelligence, machine learning, neural networks, or large language models. These are terms that are becoming increasingly common. With the progress of technology, they are no longer reserved only for a few specialists but are becoming widely available to anyone with internet access.

Not long ago, to integrate machine learning – a key area of artificial intelligence – with devices, significant computing power was required. However, the latest technological trends and the development of ‘No-code’ tools, which allow for the creation of applications without writing code, have brought us TinyML technology. It revolutionizes the approach to machine learning on devices, enabling data processing directly on the spot, without the need to send it to the cloud.

What is TinyML and why is it worth getting interested in

What exactly is TinyML? It’s an abbreviation for ‘tiny machine learning,’ a field focused on running machine learning models on microcontrollers and Internet of Things (IoT) devices. Thanks to TinyML, we now have the capability to process data and make decisions locally, eliminating the need to transmit information, such as from sensors, to external servers.

The models used within TinyML are optimized for size and performance, allowing them to operate on less powerful systems while still providing a satisfactory level of accuracy.

In the face of an increasing number of IoT devices and growing pressure for privacy protection, TinyML is becoming a crucial tool. With the ability to process data locally, sensitive information does not leave the device, significantly enhancing user privacy levels. Moreover, local data processing reduces latency, decreases energy consumption, and extends battery life in our devices, which is vital for IoT devices that must operate autonomously for extended periods, like several years.

Key Technologies and Libraries in the World of TinyML

TinyML, focusing on running machine learning models on microcontrollers and other small devices, uses many specialized libraries and technologies. Here are some of them:

  • TensorFlow Lite for Microcontrollers, a simplified version of TensorFlow Lite dedicated to microcontrollers. It allows the running of machine learning models on devices with very limited resources.
  • Edge Impulse, a platform that enables the creation, training, and deployment of TinyML models, especially for IoT devices. Edge Impulse provides comprehensive tools for the entire process.
  • X-Cube-AI is a tool from STMicroelectronics that enables the transformation of machine learning models into optimized C code for STM32 systems.

How does the preparation of a TinyML model look like?

Preparing a TinyML model is a multi-step process aimed at adapting, optimizing, and deploying a machine learning model on small, resource-constrained microcontrollers. The stages of this process are as follows:

  1. Data Collection: Gathering relevant data from sensors and other sources.
  2. Model Training: Creating and training a simple model on standard hardware.
  3. Quantization and Optimization: Reducing the precision of the model weights and other optimization techniques.
  4. Model Conversion: Converting the model to a format suitable for TinyML tools.
  5. Hardware Testing: Testing the model on the target microcontroller.
  6. Application Integration: Integrating the model with the target software and hardware.
  7. Energy Optimization: Adjusting the model for minimal energy consumption (if required).
  8. Deployment and Update: Installing the model on devices and conducting any necessary updates.

In what projects can we use TinyML?

Now that we understand what TinyML is and how to create models, we can consider in which aspects such miniature ML models can be used.

One example is sound detection, where TinyML models can be used to create a sound detection system that can detect alarm sounds or identify specific sounds in the natural environment like bird or insect noises, which can be useful for biologists.

Another application is fall detection in wearable devices such as smartwatches. TinyML can be used to detect sudden changes in motion that may indicate a fall or car accident and automatically send notifications to relatives or emergency services.

Image recognition using TinyML models can be used, for example, to identify animals in camera traps or monitor the filling of garbage bins in cities, but also for identifying people or recognizing signs and symbols.

Another example is the possibility of building a smart home based on TinyML models, where the system could help in managing energy in the home based on learning energy consumption patterns, or automatically adjusting parameters such as temperature and lighting to optimize and enhance user comfort.

TinyML models can also be used in the aspect of creating Smart City, where there are intelligent parking lots that can monitor available spaces and more efficiently inform drivers about free parking spots. They can also count or recognize vehicles, which can allow for the optimization of traffic light operation, ultimately helping to streamline traffic flow.

Vehicle recognition and counting can help in streamlining the operation of traffic lights to alleviate traffic congestion.

How to start with TinyML?

To start working with TinyML, it is crucial to choose the right board or module that will enable efficient running of machine learning models. Here are a few popular choices:

Seeed Xiao ESP32-S3 Sense

The Seeed Xiao ESP32-S3 Sense is a kit consisting of two boards. The first contains the ESP32-S3 chip with a dual-core Xtensa 32-bit LX7 processor operating at frequencies up to 240 MHz. The second includes a small OV2640 camera with a resolution of 1600 × 1200 px, as well as a miniature microphone.

This kit is suitable for applications in shape recognition, QR codes, and thanks to the microphone, it can also recognize sounds.

We remain in the family of XIAO modules from Seeedstudio. Seeed Xiao BLE nRF52840 Sense is also a miniature module (measuring just 21 x 17.5 mm). This microcontroller, based on the ARM Cortex-M4 core, can operate at frequencies up to 64 MHz, and it provides Bluetooth 5.0, NFC, and Zigbee connectivity.

This makes it a viable option as a compact controller in a smart home. The board also includes sensors, a 6-axis IMU, and a PDM digital microphone. Noteworthy is the BQ25101 battery charging circuit, which can be extremely useful if we decide to use this board in mobile applications with battery power.

Seeed Xiao BLE nRF52840.
Wio Terminal - ATSAMD51 - RTL8720DN WiFi Bluetooth.

If size is not a primary concern but you need a module with extensive sensor capabilities, the Wio Terminal is worth considering. The first thing you’ll notice in this module is a colorful 2.4-inch display, along with a small 5-position blue joystick. The heart of the module is the ATSAMD51 microcontroller based on the Cortex-M4F core, and it also includes Realtek RTL8720DN chip providing Bluetooth LE 5.0 and WiFi 2.4 GHz / 5 GHz connectivity. Additionally, it features numerous peripherals; an IMU sensor, microphone, buzzer, microSD card slot, light sensor, and a 940 nm IR LED. And if that’s not enough, with two Grove-compatible connectors, you can connect one of over 300 available modules from this family. This truly opens up a vast array of possibilities!

For the board, you can purchase additional extensions:

If you’re interested in smart city applications or intelligent agriculture, it’s worth checking out the SenseCAP A1101 device. This device from the SenseCAP family is equipped with a camera with a resolution of 640 x 480 pixels and a maximum image recording speed of up to 60 frames per second.

It’s suitable wherever efficient image recognition or analysis is needed. For example, it can be used for detecting people or recognizing analog indicators such as gas or electricity meters.

The results obtained can be transmitted via the LoRaWAN network. The device has an IP66 protection rating and can operate in temperatures ranging from -40°C to 85°C.

SenseCAP A1101 - Vision AI Sensor - LoRaWAN.

Summary

TinyML opens up a completely new era in the world of electronics, combining the power of machine learning with the capabilities of miniature circuits and devices. Thanks to this synergy, we can create intelligent solutions that were previously unattainable for small, energy-efficient devices. As technology continues to evolve, we can expect increasingly advanced applications even in the smallest formats. This area is certainly worth watching as it has the potential to revolutionize many aspects of our everyday life in the coming years. So, let’s start experimenting, learning, and be part of this fascinating journey into the realm of TinyML.

Don’t wait any longer! The world of TinyML is full of opportunities, and with the right tools and knowledge, nothing is stopping you from becoming an expert in this field.

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

Share:

Picture of Patryk Mądry

Patryk Mądry

Patryk is our Product Manager. He graduated from the Automation and Robotics faculty at the Faculty of Mechanical Engineering of the Białystok University of Technology. He’s interested in technological news, mobile robotics and photography. He likes to drink good coffee.

See more:

Leave a Reply

Your email address will not be published. Required fields are marked *

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.