Posture Regulator with LED Alert – Silent

This is a second iteration on the device using a Seeed accelerometer as posture sensor that sends alerts when the user’s posture lapses from the position desirable for working extended periods in the seated position.  The previous version used a buzzer on a relay circuit as an alert.  It produced a sound that could drive one to distraction.  This version uses a LED that simply turns red when the user wearing the accelerometer slouches or leans too far from the desirable vertical position.

The modules used in this application are shown in the following screen shot from the .NET Gadgeteer Designer.

Posture Accelerometer Sensor LED Alert

Posture Accelerometer Sensor LED Alert

This implementation of the posture sensor is different from the previous version in that it doesn’t require a relay circuit to turn on a buzzer.  It uses the GHI Electronics multicolored LED module.  It also uses the Seeed OLED Display module instead of the larger and more expensive Display T35 from GHI Electronics.

The application logic is similar in this version to the previous except that it omits the relay circuit and turns on the LED instead of the buzzer.  The following illustration shows the working components.

Posture Sensor with LED Alert

Posture Sensor with LED Alert

The Program.cs file for the application is shown in the following code block.

using System;
using Microsoft.SPOT;

using GT = Gadgeteer;
using Gadgeteer.Modules.Seeed;
using Gadgeteer.Modules.GHIElectronics;

namespace PostureAccelerometerLED
{
    public partial class Program
    {
        void ProgramStarted()
        {
            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
            button1.ButtonPressed += new Button.ButtonEventHandler(button1_ButtonPressed);
            accelerometer.ContinuousMeasurementInterval = new TimeSpan(0, 0, 0, 0, 600);
            accelerometer.MeasurementComplete +=
                new Accelerometer.MeasurementCompleteEventHandler(accelerometer_MeasurementComplete);
            Debug.Print("Program Started");
        }

        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            if (button.IsLedOn)
            {
                accelerometer.StopContinuousMeasurements();
                button.TurnLEDOff();
            }
            else
            {
                accelerometer.StartContinuousMeasurements();
                button.TurnLEDOn();
            }
        }

        void accelerometer_MeasurementComplete(Accelerometer sender, Accelerometer.Acceleration acceleration)
        {
            oledDisplay.SimpleGraphics.Clear();

            if (acceleration.Z < 1)
            {
                oledDisplay.SimpleGraphics.DisplayText("Leaning... .",
                    Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Red, 25, 25);
                led.TurnRed();
            }
            else
            {
                led.TurnOff();
            }

            oledDisplay.SimpleGraphics.DisplayText("X: " + acceleration.X.ToString(),
                Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Green, 20, 50);
            oledDisplay.SimpleGraphics.DisplayText("Y: " + acceleration.Y.ToString(),
                Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Green, 20, 75);
            oledDisplay.SimpleGraphics.DisplayText("Z: " + acceleration.Z.ToString(),
                Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Green, 20, 100);
        }

        void button1_ButtonPressed(Button sender, Button.ButtonState state)
        {
            accelerometer.Calibrate();
        }
    }
}

One surprising discovery in this version is that the Accelerometer.StartContinuousMeasurements method has to be set at a lower frequency than the previous version.  Having the relay running on the board changed the configuration so that the button could interupt the continuous measurements and turn off the measurements.  In this version I found that pushing the on/ off button had no effect until I slowed the rate of continuous measurements.

For more details on this scenario, see Posture Regulator using .NET Gadgeteer Accelerometer from Seeed Studio.

, , , , ,

  1. #1 by Tom on March 25, 2012 - 10:48 AM

    I am looking to by a sensor for my back while working in a seated position. Is this produce for sale?

    • #2 by Michael Dodaro on March 25, 2012 - 11:42 AM

      You can build it. If that is a problem, I can probably find somebody to help. Or send to you.

  2. #3 by Karl on June 19, 2012 - 11:24 AM

    Hi Michael

    Thanks for this post, but could you explain this line: if (acceleration.Z < 1)

    I guess the intent, but what is the exact definition of "acceleration.Z", is it an angle? If a measure of acceleration then what if you slouch really slowly? Would the sensor recognise the angle of your slouching?

    I'm looking to get the relative angle from the calibration base, is that possible?

    Thanks

    Karl

  3. #4 by Michael Dodaro on June 19, 2012 - 11:54 AM

    Karl,
    This is easier than it seems. The accelerometer measures “proper acceleration”, which is not necessarily the coordinate acceleration, that is, the rate of change in velocity along any axis. Instead, “it is the acceleration associated with the phenomenon of weight experienced by a test mass at rest in the frame of reference of the accelerometer device”. see: http://en.wikipedia.org/wiki/Accelerometer . I used to think I understood vectors, but I had to figure this out by trial and error with the accelerometer output showing on the display.
    When the accelerometer is calibrated with at vertical Z axis, Accelerometer.Z, will be < 1 if I slouch.
    All it means for this application is that the device should be calibrated in the upright posture you want to maintain, and then it will remind you to sit up if you slouch.

  4. #5 by Fabio on August 5, 2012 - 8:38 AM

    But when you attack the sensor to the shirt, how can you be sure it is perpendicular?
    The chest is not perfectly straight

    • #6 by Michael Dodaro on August 5, 2012 - 9:36 AM

      It doesn’t have to be exactly perpendicular, because when you call the calibrate function, it sets a position from which any movement is detected.
      Try it while watching the output on the oled display, and I think you’ll get the idea.

  5. #7 by Vahid on February 2, 2014 - 9:11 PM

    Hi Michael,

    Great work. Is there any way you can use the Accelerometer in the chair to detect the position of the posture/spine (instead of attaching the accelerometer to the shirt/jacket. It will be uncomfortable to attach it every time) ? If not, by what mechanism or device can we detect position of the posture/spine from the chair?

    Thanks

    Vahid

    • #8 by Michael Dodaro on February 2, 2014 - 9:14 PM

      Vahid, I think you could attach the accelerometer to the chair. If it isn’t parallel to the spine when seated in the chair, then you’d have to adjust the setting to compensate. But it works the same way.

Leave a comment