Introduction: Multipurpose Activity Monitor

Log the activity and location of the user over a 24 hr period and present the data in a user-friendly form without interrupting your daily activities! The final product is similar to a FitBit or other fitness tracking products.

An accelerometer is used to count the number of steps taken.

A pulse sensor is used to count the number of heart beats and calculate BPM.

A GPS module is used to keep track of location.

Step 1: Design Specifications / Materials

Design

  • Portable and Light
  • Record data over 24 hours
  • Powered by an external battery
  • Logs data onto SD card
  • Optimize signal to noise ratio
  • Comfortable placement of sensor and circuitry
  • Box pocketed at the hip

Materials

  • Arduino Uno
  • Accelerometer MMA7361
  • Ultimate GPS Logger Shield - Includes microSD slot
  • 1 GB SD card and adapter
  • 9 V battery
  • Pulse sensor for Arduino
  • Prototyping board
  • Jumper wires
  • 1 kohm resistor
  • Soldering kit
  • Headers

Step 2: Assembling GPS Shield

Stack the Adrafruit GPS logger on top of the arduino (you may need to solder on the headers on the analog inputs if they are not there already).

Note: Make sure that the switch on the GPS shield is on SoftSerial if you are going to log data onto an SD card.

Step 3: Soldering

We're going to need to power both the pedometer AND the pulse sensor at the same time. Solder together some prototyping board and headers together so that there are two headers EACH for the 5V and GND. In our case, we soldered a 8 part header to the board for the pins of the accelerometer. Solder more headers on the respective nodes for the 5V, GND, and ZOUT of the accelerometer. Solder wires to the board from another set of headers that will be used for the pulse sensor into the nodes for 5V, GNS, and analog input.

The 1 kohm resistor connects from 5V to sleep mode on the accelerometer to turn on the accelerometer, which is desirable in this case since we want to track activity throughout the day.

Step 4: Pedometer Code

First we need to convert the analog input voltage values to acceleration in g-force units. Create a function: float val2g(int val){return ((((val/1023.0)*5000.0)/800.0)-2.0625);

Now we need to determine what constitutes as a “step”. We recorded acceleration values in x,y, and z as we walked around and found that it was sufficient to use the z-axis acceleration with a simple threshold of 2g. Our code is attached.

Step 5: Heart Rate Code

The pulsemeter returns a simple voltage analog input that mirrors an ECG. To determine a heart rate, we stored the voltage values into an array. If the values were increasing throughout the array, and the difference of the lowest and highest voltage values were greater than a threshold (we used 150mV), we counted it as a peak. We used booleans to prevent double dipping. We counted our heart beats over 15 seconds and then multiplied by 4 to get beats per minute. Our attached code includes visualization to see what threshold should be used.

Step 6: GPS Code

We used the sample GPS parsing code that can be found on adrafruit’s site. https://learn.adafruit.com/adafruit-ultimate-gps/parsed-data-output. It is a little difficult to fix to take the module outside clear of buildings and wait for the red fix LED to stop blinking. After the initial fix, the module will take less time to “refix”. Remember the include the adrafruit GPS libraries!

Step 7: Connecting Everything Together!

We are very interested in logging our data to an SD card. Put all three codes above into one file and make sure that it still runs smoothly. Import the SD libraries. in your setup, you are going to need to initialize the SD card. You should already have variables that store the BPM and the number of steps. Create a string that stores the GPS time, GPS longitude, and GPS latitude. We added booleans so that we log only when GPS data is retrieved (approximately every 2 seconds in our code) even though the loop runs every 50 ms. Now we need to write this data to the SD card. At the bottom of the loop(), we wrote all these values each to its own line on a .txt file on the SD card. The format is time,steps,heart rate,latitude,longitude. We also placed our circuitry inside a box Our code is attached.

Step 8: Finished Product

We decided to compare our pedometer and GPS tracker to commercialized products. A group member used his phone's Google Fit App alongside our activity monitor. Our monitor detected 1567 steps and the phone detected 1601 steps, which comprises a 2.1% error- not bad. The GPS tracker also logged every other second. I formatted the latitude and longitude into a Google Fusion table in order to overlay the GPS coordinates onto Google Maps to provide an image that was easy to read. Sure enough, the GPS coordinates displayed accurately showed our track.