The effects of sitting for hours on end have long been proven deadly. The most striking for me was the quote that sitting for 8 hours is has the health impact of smoking 1.25 packs of cigarettes.
For a non-smoker like me, that's just unacceptable. The solution to that is so simple, which is all the more reason for me to follow it. All one needs to do is take a 1min walk every 30 minutes. This helps the blood flow, and virtually counters the side effects of sitting in front of a computer all day.
Enter Lazydoro! The goal is to build a simple wrist device that tracks your body movement, and nudges you to get up and move every 20-30 minutes for a while.
The end project will be using a Pro Trinket, an accelerometer (haven't decided on which one yet). and a plain old LiPoly battery. For now (since my pro trinket's haven't arrived yet), I'll be using an UNO for R&D.
Adafruit Pro Trinket
TDB, currently evaluating the ADXL345
So, after coming back from vacations, and with the new Pro Tinket arrived, it was time to test my assumptions. It looks like it's gonna work just fine for simple data logging. As a refresher, here's the idea
Sample every 50ms, and keep the sum of forces applied to the sensor (for a completely still object, that should be 1g). Measure the max-min within every 20 samples (1 second), and flag each second as active or inactive.
My research so far shows that when sitting or standing, very few seconds are flagged as active (the ones where you pick up a glass to drink whater, for example), and the majority of seconds are flagged as active when walking.
So, just to take this further, i moved the circuit to use the newly-arrived Pro Trinket. I've also added the LiPo charging circuit to un-tether myself from the computer, and slightly modified the code to log data on an SD on top of sending them over Serial. Since we only log 1 byte (active/inactive) per second - well, 2 including the newline - there is plenty of space in the SD. My main concern is battery life, which i'm also going to test in this iteration.
Here's a video of the current iteration. Can't wait to try it out this Monday at work. The LEDs are there just for me to be able to know that this thing is working, and to add a couple of drain to stress the battery a bit.
Goal: Gather data of 1 day including walking, standing, and sitting. Evaluate battery life. Settle on final algorithm to discern between stages.
Next Target: The next iteration should include the final algorithm, and some kind of notice for the user when they need to start working, so it should be the first functional prototype. Next goal should be to settle on the final notification type (as much as i'd like to add electroshock, it will be hard to convince others at work to wear this, not to mention battery life!), and work on power-saving.
Looks like the idea works. I've group the samples into seconds (20 samples per second), and flag each second as "active" or "inactive" based on the difference between the max & min acceleration values within that second. That is, if the difference is above a certain threshold, then we have movement.
It's quite obvious in this graph that this works quite well, and helps us keep the data manageable. You can also see that even when standing or sitting, there are some 1-5 second periods of activity, as I was moving my mouse, and simulated coffee drinking and talking to the phone. But, looking at the graph, it should be really easy to distinguish walking and these random, momentary movements.
I didn't have time to write an update last week, but I did make some progress.
I've gathered more data, of me working on my Standing Desk, myself walking, but also of a friend sitting.
I've cleaned up the data, and I've compared the 3 states. I created a graph of the accumulated force for each stated, which can be found here.
I created another graph, which is basically the same one, with a limit of 1000 records, and a timelined X axis (values were sampled every 50ms, so you'll need to multiply the X axis values with 0.05 to get Time).
For our purposes, it looks like the algorithm to distinguish between sitting/standing and walking is going to be quite easy. It looks like my walking has a very distinct pattern that repeats every 1/2 seconds (or 10 samples).
So I'm thinking of gathering min & max every second, and flagging it as "active" or "inactive". Then we can distinguish walking vs sitting/standing based on the amount of active seconds.
But, being in Istanbul for vacations, and since I didn't think far enough to bring my Arduino with me, I'll work out the algorithm on the sample data I have, and then onto the actual stuff.
I'm still waiting for my Adafruit Pro Trinket to arrive (it takes a while to get them here in Greece), so I used an Arduino Leonardo instead.
I've used two accelerometers so far. I started with the ADXL377, which I could find here i Patras, Greece, but it turned out to be completely the wrong tool for the job. It measures acceleration of up to 200g, so its resolution is really bad.
I've ordered an ADXL337, which is similar to the 377 but measures up to 3g and has much higher accuracy, and I'm waiting for it to arrive.
In the meantime, I managed to borrow an ADXL345 from a friend, and I may very well end up using this, because it supports sleep mode, interval and threshold based interrupts and I2C/SPI communication, which will probably be necessary to lower the power consumption to a paint where it can last a few days.
In any case, I've managed to gather some data of my acceleration pattern while sitting, and I've posted them on a GitHub Page.