01/25/2015 at 00:14 •
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.
12/31/2014 at 19:05 •
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.
12/31/2014 at 16:41 •
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.
12/15/2014 at 12:19 •
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.