A DIY smart chair that reminds you to take breaks

I am sure many of you, like me find yourself so engrossed in work sometimes that you forget the sense of time. It is this period where you are at the top of abilities, with a lazer sharp focus. The psychologist Mihaly Csikszentmihalyi called this state as a state of “Flow”. But if your work is sitting down in front of a computer, then it means that your body is not taking those vital breaks it needs.

In fact it is recommended to take break after every 20-30 min of the work. If you are not thinking about these rest breaks then someone needs to. Enter, a chair that can tell you to standup, stretch and move around after 30 min.

Solution Overview

On a simple level, we need a distance and time calculator that takes into account how far an obstruction is in front and how long has it been there.

Ultrasonic sensor can measure the distance and we can get the sitting time or moving time through basic code. When a person’s sitting time exceeds the recommended time, the buzzer starts to buzz. For eg., As shown in the figure below the buzzer will start at 10:20 AM after the person has been sitting for 20 minutes.

An abstract description of the concept.

Arduino Implementation

Components & Circuit Diagram

We need an arduino uno board, an ultrasonic sensor, a buzzer and a resistor.

The components and the circuit needed.


Getting the distance of the object in front

Main function used is pulseIn() which gives you the time travelled by the sound waves from trigger to receiver.

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  digitalWrite(pingPin, HIGH);
  digitalWrite(pingPin, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH pulse
  // whose duration is the time (in microseconds) from the sending of the ping
  // to the reception of its echo off of an object.
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  // convert the time into a distance
  cm = microsecondsToCentimeters(duration);

//THIS IS THE FUNCTION microsecondsToCentimeters
long microsecondsToCentimeters(long microseconds) {
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the object we
  // take half of the distance travelled.
  return microseconds / 29 / 2;

Getting the moving time and sitting time

You have to use two main functions : millis() and tone().


This function basically gives you time to since the first time it is invoked. It’s a like a watch that someone has started at a particular moment.

Now let’s say you want to know how long has the person been sitting on the chair, you need to take the clock reading when the person stands up and subtract the clock reading when the person sat down. Hence the line of code -> “timeMoving = counterMoving – counterSitting”. This way you would only get the time duration for which the person was sitting.


This is again a simple function which allows you to switch on the buzzer by specifying which pin it is connected to and which frequency of sound should it emit. For eg. tone(ledPin, 261). The function noTone() switches off the buzzer, you just need to give the pin number it is connected to.

if(cm <= avgSeatLenght){
    counterSitting = millis()/1000;
    timeSitting = counterSitting - counterMoving;
    Serial.print("Sitting Time ");
    if (timeSitting > recommendedTimePeriod){
    Serial.print("Please Take a Break");
     //add a buzzer
    tone(ledPin, 261);
  if (cm > avgSeatLenght){
    counterMoving = millis()/1000;
    timeMoving = counterMoving - counterSitting;
    Serial.print("Moving Time ");

What’s Happening Under The Hood

I measured my seat length and kept as the threshold distance after which the code will assume that the person is sitting on the chair. The ultrasonic sensor is measuring the distance of any obstacle in front, if the person’s distance is less than the seat length, the sitting timer kicks in and starts counting the seconds/minutes elapsed. If that time is more than the recommended time period to sit on a chair, the buzzer starts buzzing!

As the person stands up from the chair, the moving timer kicks in and the buzzer gets the signal to stay quiet. This cycle of sitting timer and moving timer continues as the person sits and move.

Since the distance is 37 cm and the time is more than the set duration, the print messages in the bottom right tells you that the code is working!

What’s Ahead

Honestly! I had this idea in mind for a while and it became the reason for me to learn Arduino. But if I get time I would like to make a small prototype and test it out with my chair. If the product works out you may never know, you could be using it with a mobile app that gets all the data from Arduino and allows you to see your sitting habits like timing and duration etc.

There are other cool open source ideas like this one which tells you if your posture is correct, I wish these ideas could come together and form a comprehensive smart chair solution for the end users which is affordable and provides value at par with the commercialised products.

That’s it from my side. Ciao!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s