Notice: Due to the Chinese National Day, Our office will be closed from Oct 1st to Oct 7th. Please schedule your PCB order ahead of time.

Sitting Reminder with Time Tracker

10/05/2019

Table of Contents

 


Project Overview

 

The majority of office workers tend to forget or neglect to take a break after several tedious hours of work. Sitting down for a long time can cause adverse health effects to a person’s wellbeing. Because of this, we decided to build a project that can track a person’s sitting time and remind them to move. If a person has been sitting for let’s say,  2 hours, it will alert them to walk around/stand up and do some light exercise.

 

The project will track how long they have been sitting down for in hours/mins. After the maximum ‘sitting’ time is reached, it will alert them to stand up and walk around.

 

This project will be utilising the Zio Qwiic Ultrasonic Distance Sensor to detect and track a person. The device will be strategically placed on top of a screen/monitor facing the person sitting down, in front of his/her computer.

 

 

Difficulty Level

Zio Youngling

 

Helpful Resources

 

For simplicity purposes, this tutorial assumes that you have a full understanding and know-how to configure Zio development boards. 

For this project, we assume you have already configured Zuino M Uno to interface with Arduino IDE. If you haven't done so, we have a separate post on our development board guides. Check them out below:

 

 

Schematics

 

Setup & Configuration


You will need the following modules to build this project:

 

 

Step 1

Daisy chain the modules together.


Step 2

Download and install the following libraries to your Arduino IDE:


Step 3

Upload the Full Project Code to your board. 

 

 

Code

 

Plug your Uno to a computer. Download and Flash the code below to your Uno using the Arduino IDE.

 

 

Alternatively, you can download the code from our Github page.

 

 

Code Explanation

 

From the start, the sensor will detect a human’s presence sitting within the distance of 75cm. At this time, all counters will be initialized to zero. 

 

uint16_t time_sit1 = 0;
uint16_t time_sit2 = 0; 

uint16_t time_leave1 = 0;
uint16_t time_leave2 = 0;


uint16_t lim = 75; //Distance range from sensor to the seat
uint16_t maxsit_time = 7200000; //Set the maximum sitting time in ms

 

Inside the loop function, the sensor will first detect for human presence. If no object is within the detection range, a ‘leave counter’ will start to track the time when nobody is present.

 

if(distance*0.1 < lim){// detects if a person is within the detection range
    distance_H = Wire.read();  
    distance_L = Wire.read();  
    distance = (uint16_t)distance_H<<8;
    distance = distance|distance_L;
    sit();  
    time_leave1++; //tracks the time nobody is around
    calculatetime();

 


If he/she has been sitting for more than 2 hours, the code will display a message for the person to take a break. 

 

 if(time_sit2 > maxsit_time){
      maxsit();
      time_leave1 = millis()/1000;
      time_leave1++;
      calculatetime();

 

If the person decides to take a break, the code will check again if there is human presence. If no presence is detected, the sitting counter will reset to zero and the leave counter will start. The sensor will track the time that the person has left their workspace to take a break.

 

else if (distance*0.1 > lim){//detects if a person is out of range
      calculatetime();
      Serial.print("Time sit : ");
      Serial.print(time_sit2/1000);  
      Serial.println(" sec");  
      time_sit1 = millis()/1000;
      Serial.println("Nobody");
      time_sit1++;
      delay(1000);
      

 

 

Demo

 

Place the Zio Qwiic Ultrasonic Distance Sensor on top of your computer monitor. 

Note: It is better to put it above the computer to avoid any objects being detected by the sensor which could distort the results.


You can view the sitting time results on the OLED display attached to the device.

 

 

How it works

 

The Ultrasonic Distance sensor will track and detect a sitting person if he/she is sitting within the range of 75cm (the distance from the monitor to the seat) from the sensor. 

 

It will track the number of hours that the person sat and the distance from the sensor.

 

If he/she is not within the specified 75cm range, the sensor will assume that the person left his/her sitting area. The OLED screen will display the time a person left after sitting down.

 

If the sensor has tracked and detected that a person has been sitting for more than 2 hours straight, the screen will display a message to let him/her take a break.

 

Got questions or suggestions? Or just want to greet us? Drop us a comment below!

Leave a Comment