In this project, we'll build a
protoype of a wearable fitness device designed to vibrate when it
detects stagnation. This device is low-cost and can help keep you on the
move.
Several times a week, I will look down and realize that I have been frozen at my desk for hours. This is what inspired the FitByte, a simple activity tracker that will notify you when you are inactive for a pre-set period of time. This is a simple build with a bit of through-hole soldering. The finished product will fit on your wrist, is a great conversation starter, and helps promote that healthy lifestyle we all pretend to be living.
Bill of Materials
Schematic
The heart of this project is the ATtiny85 which, although small in size, packs enough punch for this project. This microcontoller can be programmed with the Arduino IDE and is easy to fit into projects to keep cost and size down. With three analog inputs and two PWM outputs, the ATtiny85 has just enough I/O for this project.For our activity sensing needs, I am using the MMA7341LC 3-axis accelerometer which outputs each axis on a different analog line. This accelerometer also has a sleep mode that can be activated by the microcontroller to improve battery life. Our activity reminders will come through a disc vibration motor which, despite its small size, is powerful enough to be felt without drawing attention to your lethargic lifestyle. I found a powerful enough vibration by directly driving the motor from the AtTiny but a small transistor could be added to improve vibration performance.
Everything can be wired up according to the following wiring diagram:
Please Note:
- Capacitors C1, C2, C3, C4, and resistors R1 and R2 are contained in the MMA7341LC breakout board used for this project.
- The output impedance of the accelerometer is 32 kΩ and the signals connected to the ADC should have output impedance less than 10 kΩ; thus, it would be better to buffer the analog signals prior to analog-to-digital conversion.
Wiring
A big part of this project is the form factor. By keeping the components to a minimum the project can fit on two 1” square proto boards. These boards are small enough to fit fairly well on the average male wrist (assuming that my wrist is representative of the average male). One board will be used for the battery holder and the other will be used for the remainder of the components. These two boards will be joined with a few jumper wires, allowing the boards to flex in the middle and better contour to the wrist.Initially, I thought of putting the battery holder on the back of the protoboard and the components on the front. However, this felt too tall to wear comfortably. I’d recommend trying a few variations of component layouts before actually heating your soldering iron, just to ensure the best end result.
All the selected components are through-hole except for the CR2032 battery holder. The battery holder is surface mount, but it was pretty easy to solder onto the protoboard. I choose to use a surface mount battery holder to keep the profile low and because it looks much cooler than the through-hole variant.
To set up the power board, first, solder a wire to the middle of the board. This solder blob should be as small as possible to reduce the amount of pressure on the other solder joints and will make the negative connection to our battery. The other solder joints can be made where shown below. These solder pads are used to attach the surface mount battery connector positive terminals.
The battery holder is then placed on the solder balls and heat is applied from the top of the battery holder tabs until the pre-soldered holes reflow around the battery holder. This is relatively easy to do, but it requires a bit of patience. Be mindful about not touching the battery holder when you are soldering it down. It is an excellent heat sink and gets hot quick!
The other board will hold the fun part of the project: the ATtiny85 microcontroller, MMA7341LC accelerometer, vibration motor, and power switch. I found that the below layout worked well for this project. I left a row of solder holes free on the right-hand side for the attachment of the strap. You could attach a traditonal watch strap with to this project but I thought it would be fun to solder my own together with some common electrical components.
Most vibration motors have an adhesive backing so installation is a breeze. Measure twice, pull off the sticker once and away you go. I used the power and ground wires from the power board to attach the two protoboards together. This also allowed the activity tracker to flex in the middle and better conform to the wrist. Additional jumper wires can be used to ensure that there isn’t undue stress on the power cables.
This is how the project should look after being completely soldered together. It’s important to note that some protoboards have traces connecting adjacent solder pads. These are easily cut with a sharp knife but can lead to severe headaches if missed.
To make life easier, I checked my circuit as I soldered to ensure everything was wired up correctly. At this point, the activity tracker is complete. If you are going to be carrying the activity tracker in your pocket or strapped to a bag, it is ready to use.
Bonus Step: Make a Strap
I am planning on wearing mine as a more “traditional” activity band so I decided to make a suitable strap.I purchased a ribbon cable to use as a strap. This can be soldered onto the previously unused pads on either edge of the protoboard.
After measuring the strap for my wrist I soldered a row of stackable headers to either side of the strap as a way to connect the two ends.
Be sure to measure correctly before you trim the wires so that the strap fits. If you made it a bit short, or if multiple people will be wearing this activity tracker, a set of jumper wires can be used to extend the strap.
Program Flow
The idea behind the program is to notify the wearer if a predefined timer has run out. The program reads the accelerometer output signals, compares them to a threshold, and resets the timer if the threshold is exceeded. Below is a brief snippet of the code: const long maxAtRestMinutes = 15;
const long maxAtRestSeconds = (maxAtRestMinutes * 60);// This is the longest that the user can be at rest for (seconds)
int accelCenter = 1024/2; // 0g = Vdd/2
int thresholdHigh = 650;// This was determined to be a suitable level of activity (walking) by experimentation
int thresholdLow = (2 * accelCenter)-thresholdHigh; // thresholdHigh and Low are centered around 0g
void loop{
if(activityTimer > maxAtRest) // give reminder to get active
{
vibMotor();
activityTimer = 0;
}
if ( xVal < thresholdLow || xVal > thresholdHigh ||yVal < thresholdLow || yVal > thresholdHigh ||zVal < thresholdLow || zVal > thresholdHigh )
{
activityTimer = 0;
}
This code worked well but is not very energy efficient. To improve battery life, I put the microcontroller and accelerometer to sleep when I'm not checking the current acceleration. Both the ATtiny85 and MMA7341LC have low power modes to ensure that battery drainage is at a minimum. The ATtiny85 can be put to sleep for a predetermined amount of time, and the MMA7341LC falls asleep whenever Pin 7 is driven to logic low. This means that everything can be kept in a low power state unless the microcontroller is checking the acceleration data.
The program is asleep for the majority of the time but wakes up once every minute to monitor the accelerometer. While monitoring the accelerometer the program checks the acceleration values once a second for 5 seconds.
The acceleration values are compared to a pre-set activity threshold. If they exceed this threshold the activity timer is reset. When the activity timer expires, the vibration motor is activated to prompt the user to be more active.
The threshold values were determined by trial and error while performing various daily activities. For simplicity's sake, all acceleration values were compared against the same threshold. I think this is inefficient and could be improved in the future.
No comments:
Post a Comment