Introduction: Building a Device That Clips to Your Belt and Tracks How Much Time You Spend Inside and Outside

Our goal in this step-by-step instructable is to build a device you can clip to your belt and wear throughout the day.  This device will log data that, when downloaded to a back-end server system, will provide a report showing the location history of your day along with the breakdown of how much time you spent indoors and outdoors.

A quick rundown of how the system will operate is as follows:

The accelerometer constantly looks to see if the user is in motion.  While the user is at rest, the unit takes a GPS and temperature reading every 15 minutes. When motion is detected the GPS unit is turned on.  After 2-minutes passes the GPS unit and thermometer again take samples.  If motion was detected during that two minute period the 2-minute wait and sample period repeats until the user is at rest again. This is done in order to conserve energy.

All the GPS and temperature data is stored on the SD card.  Upon pushing the button on the front of the unit, all data is off-loaded (requires a USB connection to a laptop) and sent to a back end server system for analysis.  The backend algorithm (coded in Java) extracts the useful features from the data (such as GPS error, # satellites and temperature) to build a decision tree that classifies the location as indoor or outdoor. The algorithm also utilizes the assistance of online public weather API's as well a GIS web service which tells if lat/long points are within a building or not, to produce a report for the user.  The report shows the amount of time (discrete periods of the day) ,and location history along with whether the user was inside or outside.

The arduino code, backend algorithm code as well as the GIS server can be found at

This requires the following equipment:
Arduino Uno
Arduino WiFi Shield
GPS Unit (LS20031)
BMP085 Thermometer/Barometer
ADXL335 Accelerometer
LED Light
2.2K Ohm resister
9V Battery pack
Adafruit Arduino Case
Various wires..

This instructable was made as part of the final project requirement in the
CS graduate course "Tangible Interactive Computing" at the University of
Maryland, College Park taught by Professor Jon Froehlich. The course
focused on exploring the materiality of interactive computing and, in the
words of Hiroshii Ishii, sought to "seamlessly couple the dual worlds of
bits and atoms." Please see for more

A video tour of the project as well as a quick overview can be seen here:

Step 1: Add Arduino Uno to the Shell

We will use the following shell from Adafruit to encase the project  This shell can be used for many other projects and is designed to hold an Arduino and an Ethernet shield within the case.  The WiFi shield must be a touch wider than the Ethernet shield as the shell barely screws together tight when you put it together with both devices in there.  Once you place wiring into the female pins there is a small amount of pressure being applied to the Arduino itself, but I do not think this pressure will cause any damage to the shell or the Arduino.

The shell has a nice few screw hole designed to hold the Arduino.  We'll screw the Uno itself to the shell using the enclosed screws and move on....

Step 2: Install WiFi Shield and SD Card

The WiFi shield slides nicely onto the Arduino Uno itself.  If you are not building this exact project please be sure to read the following page as it outlines what pins are necessary for the WiFi shield and SD card

Failing to recognize these pin-outs will cause either the shield or your external peripheral to stop working. 

We'll simply slip the shield onto the Uno and slip the SD micro card into the shield itself and continue....

Step 3: Solder Wire to the Barometer/Thermometer

I chose the BMP085 barometer/thermometer to gather the temperature.  The barometer proved insufficient for our needs but the thermometer works nicely for our purposes.  This device does require the Wire.h library and several functions to simply produce a temperature but this device is reliable.  A good example of how to use this device can be found at:

 chose to solder wire to the pin-outs, as shown, to allow more flexibility in the placement of the device.  Leads would add to the inflexible size of the device as wires allow me to bend them as needed all the way down to the breakout board. 

We will explore wiring later in the project, for now we simply just solder the 6 - 3" wires to the breakout board and trim them later as needed.

Step 4: Solder Wires to the GPS Unit

The GPS will sit on the side of the case along with the wiring for the button and the LED.  The unit itself is also quite size-able so I will simply solder wires directly to the GPS unit.  This will allow me to place the unit where I see fit and not have the additional constraints that leads might provide.  

We will not use the TinyGPS library due to memory constraints and thus only read data off of the GPS unit through its serial connection.  A good tutorial on how to use the GPS unit can be found here:

The colored wires (from left to right) are to be connected as follows:

Orange - 3.3V  (the GPS can handle 5V as well if needed). 
Green - Signal / Serial TX
Black - Grnd

We chose digital 8 to power the device as it gives us the ability to switch the unit on and off as it draws quite a bit of power.  We will use the accelerometer to dictate when we need to gather a GPS signal.  Thus simple 'digitalWrite(8, HIGH)' and 'digitalWrite(8, LOW)' commands will allow us to easily switch on and off the unit.

We tape the back of the GPS unit to prevent shorting from taking place in the event a bare wire makes contact with the Unit.  This also protects the back of the unit as it will later be packed tight into the shell.

Step 5: Solder Leads to Accelerometer

I chose to solder 90-degree leads to the accelerometer instead of directly soldering wires to the device. The layout within the case will be such that the accelerometer will have more free space around it.  Leads also allow for easy integration with a breadboard if I decide to use the accelerometer in a future project.  Thus I will essentially have a plug-and-play accelerometer with the help of a few wire with female connectors on one end.

Step 6: Prepare the Accelerometer

Now that the accelerometer is plug-and-play ready we will prepare the wiring to allow such a connection.  We will use pre-terminated wires that have female connections on one end and male leads on the other end.  The male ends tend to break if bent too much so I'll cut off the male ends and strip the wires, leaving about 2" of free wire on each.  We'll trim each as needed later as we connect to the Uno. On the female side, I'll wrap every other end in electrical tape to eliminate any shorts that may occur if the touch one another as I connect them to the leads.  

We then plug each end into the leads of the accelerometer in an alternating pattern as show in the picture.  We'll conclude the connection by wrapping the connections in electrical tape.  

Our connection scheme will be as follows:

VCC - 3.3V ONLY!  Don't fry the device  :)
GND - common ground.  We will place this in the ground pin just below the 5V (we will use the other ground for the barometer/thermometer later)
X - Analog 0
Y - Analog 1
Z - Analog 2

Step 7: Connect GPS Unit

We will actually start connecting devices at this point.  As noted earlier, the green wire (from RX pin connection on GPS unit) will go to the TX pin (digital 0) on the Uno. The power cable will go to Digital 8. The ground will stay out for now.  We'll later attach the ground lines from other peripherals to this wire as many things need to share a common ground. 

One thing to note about the GPS unit with this connection:  The RX/TX connection pins replaces the serial communication of the USB serial cable once this unit is powered up and running. Thus, if the GPS unit were cabled up to the 3.3V or 5V connection vs. the digital pin you would not be able to upload code to the Uno as the GPS unit would be using the Serial.  One should use a similar wiring approach when testing the GPS unit to allow for code uploading.  Otherwise you will need to disconnect either the power or serial wire each time you need to upload code.

Step 8: Connect Accelerometer

We will now connect the accelerometer to the Uno.  As we only have one 3.3V connection we pull the power cable across the Uno to reduce the amount of soldering required.  Digital 2 will power the accelerometer.  The ground will go to the 2nd ground below the 5V pin. The X, Y and  Z cables all go to Analog 0, 1, and 2 pins.  

We then turn the accelerometer such that we can lay it along the Uno/Shield on the side of the analog pins.  If the wires are too long, we can trim them down and re-strip as needed to prevent too much excess wiring within the case.

Step 9: Add Battery Pack

The only complaint I have with the Arduino case is that it does not offer an easy way to place a battery.  We could simply place a battery in the back of the case itself but we would have to secure it to the case somehow.  The plastic 9V case we have fits perfectly within the internal pins of the case, allowing us to simply place it into the bottom shell.  We run the barrel connector and wiring up along the side with the accelerometer to allow us to plug the batter into the Arduino at a later time.

Step 10: Connect Thermometer

We now connect the thermometer to the Uno.  This unit will utilize the i2C bus on the Arduino Uno (via analog 4 & 5 and the Wire.h library).  Our connections will be as follows:

VCC to the 3.3V pin
Ground to the ground just below the 5V
SCA to Analog 4
SCL to Analog 5

We will not use the center two connections for this project.  

Note we trim the wires to minimize excess wiring again but we need enough wire to place the thermometer atop and in the center of the shield.  

The goal is to allow the thermometer to sit behind the square hole that is in the center of the shield.  This hole is here to allow things to come into/go out of the shell.  The shell has a door that you can use to close up the hole but we will leave it open to allow the thermometer to gauge the air outside of the shell, otherwise we might shield the thermometer from being able to accurately measure the ambient temperature.  We want to ensure when we place the top half of the shell on this unit the thermometer sits within that open space.

Step 11: Wiring Plan for Button

With the use of a 2.2K Ohm resister and a simple button, we will add the ability to signal to the device that we are ready to off-load data.  The button itself has 4 leads.  We first lay out the wiring of this connection on a breadboard to validate the wiring scheme. This enables us to test the button and ensure we will get a good signal.  We also do this so that one can clearly see how the wiring will work. The hot and ground are on the top side of this button.  The ground also has a 2.2K Ohm resister coming off of it.  The signal line is attached to the lead opposite the ground and runs to digital 6 on the Arduino WiFi Shield.  The ground runs to the common ground.  In an effort to reduce the number of wires we need to solder we will power the button through Digital 3.  Thus in this picture the hot is being fed by digital 3.

Step 12: Prepare Common Ground for the Button/GPS/LED

We now start tying together electrical components that will share the common ground on the side of the digital pins.  We solder together the wire that has the ground for the GPS unit, the button (going through the 2.2K Ohm resister first) and another wire that will serve as the ground for an LED (described later) and tie all of them into the small green wire that will actually connect to the Arduino Uno.  This allows the GPS unit, button and LED to share the only ground pin on that side of the Uno.

Step 13: Connect LED

We now wire up the LED.  We solder the LED to the ground we wired up in the last step, as well as to a wire that leads to digital 5. When the button on the shell is pushed, this LED will provide feedback to the user that that data is being off-loaded from the device. The LED will remain lit during the entire off-loading process and then turn off.  Through a series of digital Writes we will enable and disable the LED. 

Step 14: Drill Holes/glue Button

Holding the button up on the front case, I marked 4 spots on the back side of the shell where I needed a hole for the button to sit in and pass wires through.  Using a drill and 1/16" drill bit, I drilled four holes through those spots.  I then dropped the button into place by placing the leads into the holes and, with a hot glue gun, glued the button to the case.

Step 15: Wire Up the Button

Using the same types of wires we used to connect the accelerometer we will connect the button to the Arduino.  We again cut off the male ends and strip the cables to appropriate lengths.  The female ends will connect to the button through the back of the shield as shown in the picture.  We will connect three cables (as noted in the wiring example earlier) as necessary for use.  The wires I used were too short to allow one to easily leave the shell open.  Thus I extended the wires by soldering them to longer wires and wrapping the connections with electrical tape to again prevent any shorts.  At this point I can open the shell with the wires for the buttons being too short.

Reiterating the connections we have:

A common ground
A connection coming from digital 5 (reading the signal)
A connection coming from digital 3 (powering the button.  This is the power we will switch through the button)

Step 16: Close Container

We now close the case.  This is probably the hardest part of this process as we have to lay the GPS unit along the side of the device, careful not to pinch any wires or leaving any wires underneath the GPS unit.  Doing so will make closing the case hard as the GPS unit is as wide as the case itself; and a wire running under the unit will thicken the needs of the project.  We carefully tuck the light just behind the end of the unit so that it does not protrude beyond the end of the case and risk getting bent or broken.  

We use the 4 screws that accompanied the shell to close it up.  All that is missing is a clip so we can clip the device to our belt....

Step 17: Print Belt Clip/Attach to Shell

The case we have is nice in that it holds the project together well and protects everything but it alone is not suited for wearing.  We could simply place it in our pocket but the size is a bit large, so...  We will print a clip that we can glue to the case to allow the unit to easily clip onto our belt.  Using TinkerCad we draw up a clip.  We then use ReplicatorG to create a .s3g file that we can easily load onto an SD card, place into a MakerBot 3D printer and print the clip.  After printing we will glue the clip onto the back of the case using a hot glue gun.

Step 18: Final Product

Our final product is a wearable device we can carry around on our belt all day.  The data is stored on the SD card, offloaded at night and where the back-end server system provides a report showing you how much time you spent indoors and outdoors throughout the day.

The composite code for the unit can be found here:

On the server side, we get a set of samples and each sample contains a unique identifier to identify the person whose data is being synced, GPS reading and temperature readings. The algorithm parses the GPS reading to determine whether its a valid GPS reading (fixQuality>0) or invalid GPS reading. For valid GPS data, we obtain the lat long and reverse geocode it. We also use meta data like  # satellites, location Error and the temperature reading as features in a decision tree to classify the location as indoor/outdoor. For invalid GPS readings, we just use the last known lat/long values for reverse geocoding.
The server side code can be found here:


kiwinewt made it! (author)2012-12-20

You have the wifi in there, why not program it to, as it is waking and reading every X minutes, to attempt to connect to the wifi if the last connection was > X hours ago? This way it would be faster and easier to download the data - no buttons! ;)
Also, If I was building this I would put a solar panel on the pack to charge from the sun with optional usb charging (LED for low battery?). I think that the use for this is going to be quite rugged - look at an average day... - and as such you have too many ports and buttons and suchlike sticking out which can be caught/gunked/etc...
Apart from that... I have had the idea for something like this in my head for a while. I think I might take your idea and run with it... :) Thanks!

gramsky made it! (author)gramsky2012-12-20

Two EXCELLENT points.

First the WiFi...

That was in the ORIGINAL idea. Unfortunately the Arduino WiFi shield is not very robust. If you look no stackoverflow or evern the Arduino Forums you will see multiple threads where I asked what I was doing wrong in my pursuit of this implementation. Apparently the shield is designed/coded to connect once, stay connected to a AP and send data as needed. Migrating connections from AP to AP is not easily accomplished and you run out of memory doing so. Migrating this from an Arduino platform (IE raspberry pie, beaglebone or the like, though keeping the footprint small) would work. Though a cell phone would as well though you'd likely lose the thermometer part AND cell phones are not really wearables, so someone could easily move around without the cell phone.

Now, solar panel, LED for battery, etc. I originally wanted to use a LithION battery to power this but I had a mix of batteries with different amperages. Thus I could not use the materials I had in stock and had to resort to a 9V for now. Solar panel might work to keep a charge but the panels needed (that I am aware of) would be large. Doesn't mean this cannot be done....

Thanks for the thought and ideas!

kiwinewt made it! (author)kiwinewt2012-12-20

Thanks for the reply :) Is 10cmx10cm too big? (just as an example)

gultekin made it! (author)gultekin2016-10-28

I don't think that would work. That only produces 0,7W meaning ~75 mA. You would need atleast 4 or 5 of these. Would you wear A4 paper sized solar panel.

gramsky made it! (author)gramsky2012-12-21

Yes, that would likely work :)

haukeh made it! (author)2015-04-12

The composite code on github is no longer available. Can I find it elsewhere?

gramsky made it! (author)2012-12-22

Someone asked that I post some of the stackoverflow/arduino message board posts where I attempted to figure out some of my issues as well as a few that helped me isolate my issues. Thus here they are:,136086.msg1023835.html#msg1023835,134233.msg1009852.html#msg1009852

ursm made it! (author)2012-12-20

interesting project.
two points I would change
1. turn the installation by 180°.
2. solder a normal 9V battery clip to the board instead of using the bulky connector.
with that the top is "water tight".
I agree, for reading the data you have to open the box.

pizzro made it! (author)2012-12-19

your project is too expansive... maybe cost 200$.

gramsky made it! (author)gramsky2012-12-19

Yes, it is a touch expensive, but it is only a prototype at the moment. To my knowledge there is nothing around that distinctively tracks the inside/outside time of a person. This was more to prove it could be done with the hardware + back-end system than anything else. But yes, not many would really want to spend $200 for something like this. :)

randofo made it! (author)2012-12-19

Very cool. What do you plan to use this for?

gramsky made it! (author)gramsky2012-12-19

Plan is to gather the data over time and provide a visualization where one can quickly see how much time they spent inside and outside each day. Also plan to use a time wheel and show the patterns that do or do not exist over time (weeks-months). We are currently working to port this to a cell phone app and expand the ubiquitous computing world.

RoboTronics21 made it! (author)2012-12-19

Nice its like a personal mini black box datalogger
a good use for it is knowing wer ur kid is at all times and seeing what they are doing and wer they r going throughout the day.
Awesome man nice work

gramsky made it! (author)gramsky2012-12-19

Yes, that's totally what it is, much like a fitbit. Tracking kids was not so much the aim but rather to provide one a record of what parts of their day they spent inside and outside. Our initial aim was to also use the WiFi. We have a back-end server that provides a pretty good resolution. It would have been much more accurate and allowed for off-loading of data vs. the button to download data.

zigzagchris made it! (author)zigzagchris2012-12-19

They have had services like that to track children phones for a while. lucky enough not to have that experience