Simulating the presence of a colleague

Simulating the presence of a colleague

At this time of Covid-19 pandemic, many people are working from home. It's also the case for part of Yoctopuce's staff. To stay connected, we created a small application which detects if a person is at his home work place and updates the color of a led at Yoctopuce's premises.

To do so, we used two modules: a Yocto-RangeFinder and a Yocto-Color-V2. The Yocto-RangeFinder enables us to detect the presence of the person. We simply stuck it with double-sided tape to the lower edge of the screen with the distance sensor facing the desk chair. The module is directly connected to a USB port of the machine.

We used double-sided tape to stick the Yocto-RangeFinder at the bottom of the screen
We used double-sided tape to stick the Yocto-RangeFinder at the bottom of the screen

In this way, we can measure the distance to the first object (or person) located in front of the screen. This system is very primitive but, against all odds, works very well. The measures are not perturbed by sun rays as we are inside and, by configuring a one second statistic analysis window, the measures are not noisy. For more details on how the statistic analysis window works, you can read this post that we wrote last year.

Virtual presence of the colleague
Virtual presence of the colleague

Without actually noticing it, we always settle in at the same distance from the screen and it is very easy to detect whether the person is present or not. In our experience, a 15 to 20cm window is enough to detect whether the person is in front of the keyboard.

The empty work place
The empty work place

To be frank, the system is used only by the writer of this post, so it's quite possible that this system doesn't work as well with other people. In our case, the desk chair cannot get too close to the screen because of the armrests, but depending on your own desk and work place configuration, it may not work so well.

The application

For the application code, we modified the Electron application that we described in a previous post. Instead of displaying the temperature with a Yocto-Meteo, the application monitors the measures of the Yocto-RangeFinder and updates the leds of the Yocto-Color-V2 at Yoctopuce's premises.

The code is simple. We register a periodic callback for the Yocto-RangeFinder and if the "target" is in the configured range, we light the Yocto-Color-V2 in green.

let was_present = false;
let min_distance = 400;
let max_distance = 600;

async function updatePresence(bool_ispresent) {
  let color;
  if (bool_ispresent) {
    color = 0x00ff00;
  } else {
    color = 0xff0000;
  let ledCluster = YColorLedCluster.FirstColorLedCluster();
  while (ledCluster != null) {
      let activeLedCount = await ledCluster.get_activeLedCount();
      await ledCluster.rgb_move(0, activeLedCount, color, 500);
      ledCluster = await ledCluster.nextColorLedCluster();

async function rfChangeCallBack(obj_fct, measure) {
  let dist = measure.get_averageValue();
  let elementById = document.getElementById('live_val');
  elementById.innerText = dist + "mm";
  let presence;
  if (dist > max_distance || dist < min_distance) {
      presence = false;
  } else {
      presence = true;
  if (presence !== was_present) {
      was_present = presence;

async function deviceArrival(module) {
  let serial = await module.get_serialNumber();
  let product = await module.get_productName();
  if (product.startsWith("Yocto-RangeFinder")) {
      let rf = YRangeFinder.FindRangeFinder(serial + ".rangeFinder1");
      await rf.set_rangeFinderMode(YRangeFinder.RANGEFINDERMODE_DEFAULT)
      await rf.set_timeFrame(1000);
      await rf.set_reportFrequency("4/s");
      await rf.registerTimedReportCallback(rfChangeCallBack);

As usual, the complete code of the application is available on GitHub:


As you can see, while very basic, this system works.


Note that we did this for the fun of it, and not to spy on our employees. We hope that you are doing well and that we'll all soon be able to go back to work in real offices :-)

Add a comment No comment yet Back to blog

Yoctopuce, get your stuff connected.