Vision-based Method

Computer vision executes various techniques and approaches to identify objects in digital images, such as R-CNN, Fast R-CNN, Faster R-CNN, and YOLO, among others. The process of object recognition is quite complex and consists of a range of related tasks, including image classification, object localization, and object detection.

For better understanding, I attach the example of image recognition using a Region-based Convolutional Neural Network (R-CNN):


However, such technologies are quite demanding in use due to the following factors:

Since I believe that technologies should be easy to implement and available to more users, I’d like to offer a no less effective way to detect room occupancy, which will help to overcome the challenges mentioned above.

Sensor Data + TinyML Algorithms

In this tutorial, I’ll demonstrate how to efficiently use tabular data and automatically build a tiny machine learning model based on environmental sensor data to detect room occupancy.

But before describing the process in detail, I want to share the main advantages of my method:

Model Training

Now let me proceed with the step-by-step procedure of the TinyML model creation.

This is a binary classification task as we need to predict whether a room is occupied or not, based on data from environmental sensors, such as temperature, humidity, light, and CO2.

For my experiment, I used an open-source “Occupancy Detection” dataset available on the UCI Machine Learning Repository: https://archive.ics.uci.edu/ml/datasets/Occupancy+Detection+

For model training, I use a free no-code platform, Neuton TinyML. Here are the steps of the process:

That’s all I needed to start model training :)

The trained model turned out to be super small and accurate, according to all the canons of TinyML. Looking ahead, I also provide Total footprint and RAM usage in the table :)

Just note the small number of coefficients (only 60!). And, most importantly, the model’s accuracy (which is 98%) is not affected by the small size which is fantastic!

For the purity of the experiment, I wanted to compare the metrics of Neuton’s model with the model built with one of the most used platforms, TensorFlow Lite for microcontrollers. But unlike Neuton, TF Lite for Microcontrollers requires a 32-bit platform, and therefore it would not be possible to deploy it to Arduino Mega 2560 which has an 8-bit MCU (ATmega2560).

Model Deployment

For model deployment, generate the C library on the Neuton platform by clicking on the “Download” button. The contents of the library include the model, a set of functions used to perform preprocessing operations, and a set of functions used by the application logic to execute the model and read prediction results.

The code is available here: https://github.com/Neuton-tinyML/arduino-room-occupancy

To integrate the library, take the following steps:

Since I use CSV data as input, I will send 4 different conditions (which are described by values of features) of the room to detect its occupancy.


To emulate the work of a model, I connected a microcontroller to a computer via a serial port, and the communication took place in a binary format.


A sound signal on the video notifies that there is a person in the room.

I hope that my tutorial proved that you don’t need to be a computer vision genius to implement real-world projects. Now you know an alternative way to detect room occupancy by leveraging the power of TinyML, which doesn’t require high costs or efforts, just a free no-code platform!