InPace is an Arduino based fitness wristband, with an accompanying iOS application, that can provide live feedback on how the user is pacing themselves during a run, walk or cycling route. It tracks GPS locations and current times to compare the users current performance with previous attempts at the route. The iOS app allows the user to manage their routes, view their route drawn out on a map, and view a graph which displays analytics computed during the route. Future features may include heart rate monitoring and calories burned.
InPace was created by Hans Heidmann, Madison Rockwell, Sean Tranchetti, and Calvin Hicks at CU Boulder during the Spring 2015 semester.
Step 1: How Do the InPace Electronics Work?
The whole system is powered by a 3.7V 500mAh Lithium Polymer battery.
Setting the "on/off" switch (which is located in the center of the control panel in the picture above) to the ON position will allow the LiPo charging module's red (+) wire form a connection to the voltage regulators (+) input. The battery's black (-) ground wire is connected to the voltage regulators (-) input.
The voltage regulator converts the LiPo battery's output voltage of ~3.7V into 5V. This is the default setting but this voltage regulator is capable of 4-12V DC output voltage by adjusting the fixed resistor. The regulator is only capable of providing a maximum of 1A (1000mA) of current. InPace consumes 750mA (+/- ~150mA) while powered on so this limitation is not a problem.
The voltage regulator's (+) and (-) output pins are connected by a red and black wire to a piece of PCB that I cut down into a 6x4 pins section using a Dremel tool. The purpose of this PCB is power distribution. 12 of the pins (half of them) are used as a common 5V VCC; the other 12 are used as a common Ground.
The Arduino Pro Mini's "RAW" pin (labeled VIN on an Arduino Uno and most other boards) is connected to one of the (+) pins on the power distribution board I made. The VCC (+) and GND (-) pins of the following are also wired to the power distribution board: the Bluetooth 4.0 module, the RGB LED, and the Control Panel.
All of the Modules are connected to the Arduino as follows:
Adafruit microSD Card Read/Write Pins
CS -> pin D-10
MOSI -> pin D-11
MISO -> pin D-12
CLK -> pin D-13
Adafruit Ultimate GPS_Module Module Pins
RX --> pin D-2
TX --> pin D-3
Red Bear Lab BLE Mini Bluetooth 4.0 Module Pins
(BLE Mini) RX --> TX (Arduino)
(BLE Mini) TX --> RX (Arduino)
momentary tactile push button --> pin 8 (for sending Bluetooth data)
momentary tactile push button --> pin 9 (for starting/stopping GPS data logging)
Common Anode RGB LED
4 pins: Red | VIN | Green | Blue |
(1) Red --> pin A0 (on the Arduino)
(2) VIN --> VCC (on the power distribution board)
(3) Green --> pin A1 (on the Arduino)
(4) Blue --> pin A2 (on the Arduino)
If everything is properly connected and the Arduino has been programmed with my InPace code, 3 virtual states will now exist. These are known as systemState (int) within the code.
If systemState = 1, the system is doing nothing but waiting for user interaction. The RGB LED will be Red. If it hasn't already, the GPS module will be attempting to get Satellite fix.
If the GPS button is pressed, the Arduino is notified via digital pin 9, systemState is changed to 2, and the RGB LED will turn Green. When systemState = 2, the InPace code parses the NMEA GPS satellite data that the GPS module is feeding the Arduino. I used the Arduino SoftwareSerial Library to make pins 2 and 3 act like RX and TX pins to enable the communication with the GPS module. After being parsed into strings, the GPS data is then written to the microSD card through pins 10-13 (Arduino) which are connected to the microSD breakout as noted above. Longitude, Latitude, Date, and Time are appended to a text file gpsdata.txt (the only file on the microSD card).
Here is an example of how the GPS data strings are saved to the microSD card.
-105.269462 40.005664 04/22/2015 23:47:14 -105.269363 40.005630 04/22/2015 23:47:16 -105.269409 40.005664 04/22/2015 23:47:17 -105.269340 40.005699 04/22/2015 23:47:20 end
If the GPS button is pressed again, data-logging will be stopped. If the Bluetooth button is pressed while systemState = 2, nothing will happen.
If the Bluetooth button is pressed while the Arduino is back in "virtual state 1" (systemState = 1, waiting for user interaction), systemState will be set to equal to 3 and the text file's data will be sent over bluetooth. This is done by iterating through all of the lines of the gpsdata.txt file and printing it to Serial as a UTF-8 encoded strings. The RGB LED will be Blue until the every line of gpsdata.txt has been sent over Bluetooth through Serial (pins 0 and 1, RX and TX of the Arduino) at a Baud Rate of 57600.
Step 2: Hardware and Software
- Arduino Pro Mini (5V/16mHz)
- Sparkfun "FTDI Basic" (USB Mini to FTDI programmer, 5V)
- Common Anode RGB LED (4 pins, See my pin description below)
- 2 brown-black-red resistors (1KΩ 5% tolerance)
- 3 red-black-brown resistors (200Ω 5% tolerance)
- 2 Micro Momentary Tactile Push Buttons
- Small 3-pin On/Off Switch
- Adafruit Ultimate GPS Breakout Board
- Adafruit microSD Card Breakout (Input Voltage: 3-5 Volts)
- 3.7 Volt Single Cell 500 mAh LiPo Battery
- Adafruit "MicroLipo" Lipo Charger
- Power Booster "DROK® Slim Boost Converter Module" (DC 2.5-6V to 4-12V Voltage Regulator)
- Red Bear Labs "BLE Mini v1.1" Bluetooth 4.0 Transceiver
- Xcode 6.1
- Arduino IDE
Step 3: Circuit Design
I used a free program called Fritzing to create a digital prototype of the circuitry.
Step 4: Receiving GPS Satellite Data
I was originally planning on using a cheap imported GY-GPS6MV2. This module worked but it usually took a while to get a satellite fix. It's important that the system gets a satellite fix as soon as possible after being powered on, so that the user doesn't have to wait before starting a walk, run, bike ride etc.
After doing more research, I decided to buy Adafruit's "Ultimate GPS" breakout board, which "can track up to 22 satellites on 66 channels, has an excellent high-sensitivity receiver, and a built in antenna." I also purchased an external GPS antenna to get satellite fixes almost instantly, which really helped expedite the GPS testing phase, especially since I was mostly indoors while building and programming InPace.
I used the TinyGPS library to parse the NMEA GPS satellite data. I'm using digital pins 2 and 3 on the Arduino Pro Mini and Arduino's SoftwareSerial library to communicate with the GPS module. Using Software Serial is necessary because I need the real RX and TX pins (digital pins 0 and 1) for Bluetooth communication.
Step 5: Reading/Writing to a MicroSD Card
I had originally planned on using Sparkfun's microSD breakout board. After deciding that a 5V/16mHz Pro Mini would be a better micro-controller for the system than a 3.3V/8mHz Pro Mini, I would have had to use my digital logic lever converter to communicate with the Sparkfun microSD breakout. Considering that everything needed to fit in a wristband, I decided to ditch the Sparkfun electronics and save them for another project.
I settled on using Adafruit's microSD breakout board, which can handle a supply voltage of 5V as well as communicate with 5V logic. I also bought a generic 8 GB micro SD card on Ebay.
I wired it to the Arduino Pro Mini as follows:
( Breakout Board Pin -> Arduino Pin )
- CS -> pin D-10
- MOSI -> pin D-11
- MISO -> pin D-12
- CLK -> pin D-13
Step 6: Bluetooth (BLE 4.0)
I was originally planning to solder a generic HM-10 bluetooth 4.0 chip. There is an an open source HM-10 breakout board made by Ladvien, which would make it easier to solder, and show the HM-10 pinout. OSH Park will make you 3 of them for $6.80! I needed to get the Bluetooth up and running as soon as possible, so I didn't have time to wait for these to be manufactured.
I settled on using my Red Bear Lab BLE Mini for the system's Bluetooth. The BLE mini is basically a "plug and play" bluetooth transceiver. To use it, I supply it with 5V, and hook its RX & TX pins up to the Arduino's RX & TX pins and write some Arduino code such as Serial.println("Hello");
Step 7: RGB LED, Momentary Push Buttons, and a Switch
Testing the micro-electronics was a very important and interesting phase of creating InPace.
For the InPace hardware, I was originally using an addressable RGB LED that has a WS2812 driver inside it. After proving itself slightly unreliable, which I believe was due mainly to signal noise or induced currents, I still had enough open I/O pins on my Arduino Pro Mini to use a standard common anode RGB LED.
- One of the push buttons is for starting/stopping GPS data logging to the microSD card.
- The other button is for sending GPS data stored on the MicroSD over Bluetooth to the InPace iOS app.
Step 8: Making a 'Control Panel' for the System
After I had breadboard-tested the 2 buttons, the switch, and RGB LED, I thought of a way to make this part of the circuitry much smaller.
- I used my Dremel tool to cut some PCB into a smaller piece.
- Then I soldered on the buttons, the switch, the LED, and some resistors and wired it up to the Arduino.
- I detect button pushes by doing a digitalRead() on pins 8 and 9, which I choose to use for the Bluetooth and GPS buttons.
- I'm using Analog pins A0, A1, and A2 (a.k.a digital pins 14, 15, and 16) to ground each of the RGB LED pins.
Step 9: LiPo Battery Power System
For a while I was using a Sparkfun Powercell LiPo Charger/Booster. This worked great as an "all in one" charging and voltage boosting setup until I found it's limit and saw the magic smoke... Unfortunately the Powercell is only capable of providing a maximum of 500mA @ 5V. The InPace hardware needs more than 500mA so I put the fried Powercell in my electronics graveyard and did some research to see how I could solve this issue.
I settled on buying an Adafruit Mini LiPo Charger and a DROK voltage regulator. The Adafruit LiPo Charger has a female micro USB port and a female LiPo battery connector already soldered onto it. Alternatively you could supply the charger with any 5V DC source to x The Voltage booster is necessary to convert the LiPo battery's 3.7 Volts into 5 Volts and provide up to 1000mA of output current. For the record, the DROK product I'm using is capable of an input voltage of DC 2.5V-6V and an output voltage of DC 4-12V, which is set to 5V by default.
* I also soldered the jumper on the Adafruit LiPo charger to change the charging current from 100mA to 500mA.
Step 10: Programming the Arduino
After individually testing everything, it's time to solder the whole system together and program it.
The Arduino code can be downloaded from the InPace GitHub as a .zip or as follows:
- Open Terminal (If using a Mac).
- Type "cd Documents" and press the enter/return key to move to that directory.
- Type "git clone https://github.com/H-4-N-5/CS-3308-Project.git" and hit enter.
- This will clone the InPace GitHub repository in your Documents folder.
- Open the Arduino IDE.
- Click "File" --> "Open" and navigate to the folder you just cloned from GitHub.
- Go inside the folder titled "Arduino Code" and open the latest version. *currently v5
- Make sure you have the correct board (Arduino Pro Mini) and port selected and upload the code.
Step 11: SQLite Database
Step 12: Designing the IOS App
The InPace iOS app utilizes
- SQLite to store GPS data that was sent over from the InPace wristband in a database.
- Apple MapKit for viewing your route on a mapView
- Core-Plot to handle graphing user analytics.
The Xcode project and all of the Objective C code is available at https://github.com/H-4-N-5/.../InPace
Step 13: (Optional) 3d Printing Cases for the Electronics
I used an Autodesk program called 123D Design to create some 3D models for the cases.
This step is optional but recommended to create protective encasing for all of your precious electronics!