Arduino based Sitting Sensor

This project is an Assignment for my Make Things Interactive class, where I use Arduinos as a tool to learn basic electronics.


This challenge has us tasked with creating a solution to help with back pain. We must design a arduino based solution that:

  • Alerts the user when they have sat at their desk for 1 hour (or a configured time).

There are 4 Extra Challenges that can be completed

  1. A snooze button that stops the alert and extends the time for 5 minutes.
  2. Alerts the user after they have been away from their desk for longer than 30 minutes
  3. Changes the alarts based on the time of day (Allowing 15 minute breaks between 9am-12pm, hour long between 12-5pm, and 20minutes between 2-5pm)
  4. Sent alert notifications to the users phone.

Design Diagrams

The design is pretty simple, all that is needed physically is the button for snooze, the RTC module, and the Force Sensitive Resistor. Everything else is done with programming.


Arduino Code

You can download the latest version of the code from my git server.

The basic idea for this code is to read the raw input from the Force Sensitive Resistor, and then smooth that out, using the running average, this makes it so moving around slightly doesn’t count as the user getting of the chair completely, this running average outputs to the variable average, this is used as the main input from the sensor by the program.

When it marks the user as sitting down (when the sensor is greater than the sensorGate), it writes the current unix time to satDownTime variable, while the loop variable will check if that matches, using now() == satDownTime + maxSitTime && isSitting == 1. (Sitting time can change depending on the TimeAlarms)

Breaks are calculated by getting now() == satDownTime + breakTime which is similar to the calculation used for sitting down time, but satDownTime is set when the user got off the chair

I’m now regretting the terrible naming scheme of these variables

When the user stands up, the program notes that, and sets isSitting to 1, and sets satDownTime to the current time. and starts comparing against the break time instead.

The button is continously scanning inside the loop, when it is pressed, it will set snoozed to one, so the button press cannot be counted twice, then adds the snoozebutton (duration of snooze: 5 minutes) to snoozeTime, which is added BACK into the break time checker.

The alerts works by printing a line directly to the serial connection, which the user will have open, or have a custom program to read the message and forward that to the notification service.


Notifications would be difficult to implement without making physical changes, like adding a bluetooth, internet or sim card attachment to the arduino, because you would need to send the PC a message through the Serial connection, and have a program that’s listening on the other end, which can convert that to a http code to send off to a push notification service.

If we were going the internet route, it would be very easy. Just hook up either a wifi or ethernet connection for the arduino, and then sign up to pushbullet, or any other push notifcation service, and then tell the arduino to send a HTTP request to the api. The example pushbullet code is sourced here