LogbookESP-Mosaico

The board that knows I'm here: the ESP-Mosaico presence sensor, measured

Log
35 of 39
Date
Reading
3 min read

Short answer. The white dome on the interaction module is a passive infrared sensor. It reads like a plain pin, 0 or 1, on GPIO 4 when the module sits on the left of the board, on GPIO 5 when it sits on the right. Sitting in front of it, I get seen every few seconds. Hidden, it saw nothing for more than fourteen minutes. That is enough for a simple rule: a room is empty after five minutes without a single detection.

Close-up of the ESP-Mosaico interaction module: a faceted white dome, the presence sensor, next to the two touch keys and small clear lenses. Behind it, the board's screen and its coloured buttons.

The small white dome

The “Vision Combo” kit comes with a module that snaps magnetically onto the side of the board: six LEDs, two keys, a light sensor, and this dome. Underneath sits a presence sensor of the same kind that switches on a hallway light. It does not see a person, it sees a change of heat in its field, through the facets of the dome.

The idea was simple: the board, sitting on the desk, should know whether I am in the room. Not who, not how many, just someone.

The ESP-Mosaico seen from above on a black mat: on the left the camera module with its orange lens, in the middle the square screen with three buttons (in French: talk to Mosaico, show an object, MosaiCue), on the right the interaction module and its white dome.

Where to read it

Nothing in the documentation says which pin it answers on. The answer is in the module’s driver, public on GitHub: the sensor is on pin 4 of the module connector, and the board maps the pins from one side to the other. Module on the left, GPIO 4. Module on the right, GPIO 5.

From there, it is a pin like any other. In Lua, on the board:

local gpio = require("gpio")
gpio.set_direction(5, "input")   -- module on the right
print(gpio.get_level(5))          -- 1 = someone is moving, 0 = nothing

I read it five times a second and count every change from 0 to 1. Each detection is logged with its time and its length.

What it sees, measured

Two tests, one evening, nothing fancy.

  • Sitting in front of the board, working: one detection every few seconds, each lasting 2 to 15 seconds. Sitting and working, you move enough for it.
  • The sensor hidden, with me still in the room: zero detections in 14 minutes and 26 seconds. Not one false signal.

A false signal would have been the real problem. A sensor that fires on its own makes any rule useless.

The five-minute rule

The sensor only says “someone is moving now”. To know whether the room is occupied, you have to add time. The rule I kept, based on the measurements:

  • leaving: five minutes without any detection;
  • arriving: a detection after at least five minutes of quiet.

Five minutes, because sitting in front of it, I was never left unseen for more than a few seconds. The margin is wide, and it avoids calling the room empty while someone reads without moving.

What broke

The first version stopped the app as soon as it started, without a word in the log. The culprit was a name: I had called the pin library gpio, while that name already stood, higher up in the program, for the LED pin. The program overwrote it, then stopped dead on the next line. Once the name was changed, everything worked. Since then, the app writes the cause of any stop to its log before shutting down: the next failure will not be silent.

What’s next

For now, arrivals and departures are only logged. The goal is elsewhere: an arrival in the room should wake a desk robot, and it should say hello. First, I still need to check that the sensor never fires on its own in a truly empty room, with sunlight or a draught.

Sources

Lire en français