Fitness Tracker Activity
Estimated Time: 1 Hour
You will have the opportunity to mimic data interception from a fitness tracker using radio signals. After gathering data from your partner, you will be able to interpret and graph the results using simple techniques. From the interpreted data, you will be able to tell what kind of activities your partner is doing.
Step 0: The Basics
- Micro::Bit Coding Options
- [Click here to code with JavaScript/Blocks] (https://makecode.microbit.org)
- Click here to code with MicroPython
- Radio Signal Basics
- Serial Basics
- Basic Math Skills
- We will be finding the acceleration in 3 different directions: x, y, and z.
- To find the total acceleration, you need the following equation:
Acceleration = \sqrt{x^2+y^2+z^2}
Step 1: Gather Materials
- Micro::Bit (1 per person / 2 per team)
- Micro-USB Cable
- Battery Pack (Equivalent to two AA batteries)
Step 2: Get Familiar With Fitness Trackers
-
A Fitness tracker will gather data about its surroundings and send it somewhere else to be synthesized. For example, Fitness watches will measure things like heart rate and steps. They will then send that information to your smart phone to be shown to you. We will be making a fitness tracker, that tracks your acceleration. It will send this data to another Micro::Bit that will graph it on the computer using Python. You will be able to see how much someone is moving, based on the graph.
-
Below is code snippet that gets the acceleration and sends it over the radio to the fitTracker receiver
def capture_data():
x_Accel = accelerometer.get_x()
y_Accel = accelerometer.get_y()
z_Accel = accelerometer.get_z()
radio.send(str(x_Accel) + ',' + str(y_Accel) + ',' + str(z_Accel))
Step 3: Download The Files
-
Download (click on) the following file to get started: 05_FitTrack.zip
-
Unzip FitTrack.zip (right click on the FitTrackLab.zip and select "extract all". Then, just pick where you want to save your copy of these files). Notice there are three folders/directories in FitTrackLab:
- HexFiles: This folder/directory holds all of the .hex files, or files that are ready to be run on a Micro::Bit.
- JavaScript: This folder/directory holds all of the JavaScript code for the labs. This includes base code and completed code. The base code is code that you can start with instead of creating new projects from scratch. Completed code is code that members of the CEDAR lab completed that you can look at if you get stuck.
- Python: This folder/directory holds all of the Python code for the labs. This also includes base code and completed code.
Step 4: Open your editor.
- For JavaScript/Blocks, you will use the Micro::Bit online editor: MakeCode. Here, you can switch back and forth between JavaScript and Blocks by clicking on the button/slider in the top center of the screen.
-
For Python, you can use Mu (click here to see Mu) or the online editor (click here to get to the online editor).
-
Python must be downloaded on your computer to run serial_reader.py. You can still complete this lab without serial_reader.py with a chrome extension here.
Step 5: Flash the base code.
If you don't remember how to flash code to your Micro::Bit, see the instructions here.
Step 6: Programming!
-
Read through the links under the prerequisite skills section. This will enable you to understand the basics of the lab. You want to be able to answer the following questions (answers here):
- If someone sends a message over radio waves, who can access that message?
- What method do you use to send data over radio on a Micro::Bit?
- What method do you use to run a block of code every time data is received?
- How do you find the total acceleration from the x-acceleration, y-acceleration, and z-acceleration?
-
Read the running instructions below to get an idea of how the final program should work.
-
Find a partner that programmed their Micro::Bit in the same language as you (so if you used JavaScript, find someone who also used JavaScript).
-
Begin by choosing who will be the tracker and who will be the hacker. The tracker will be the user of a fitness tracker. They will use their Micro::Bit to collect data about their movements. The other partner, the hacker, will obtain their data. See the running instructions for how to run the experiment.
-
Follow the running instructions to run the program and analyze the data. These instructions will explain how to graph the data. From the graph, the hacker should make a guess about the activities that the tracker was doing (walking, running, jumping, and so on).
-
Switch hacker and tracker roles and run again. After analyzing the data, have the new hacker make a guess about the activities of the new tracker.
-
Chat with your partner about the issues with wireless data transmission. What are some potential solutions to these problems? Can you think of a simple encryption solution that allows you to mask the data being sent? Can you reverse the encryption to use the data?
-
With your partner, employ a solution in your code. Run the experiment one last time and to see if your solution worked. What worked well in your solution? How could your solution be improved?
Running Instructions
-
Designate 1 Micro::Bit as the receiver and 1 as the fitness tracker, both will have the same program written to them. However, one must be plugged into the computer to receive the data.
-
A check mark will appear to show the Micro::Bits are ready.
-
Double click on serial_reader.py in the code directory (recommended) or use the chrome extension: here.
-
If you are using the chrome extension, launch the application and select the appropriate COM port (if you only have one device plugged in there will only be one option). Select a Baud Rate of 115200 and click on connect.
-
To start gathering data, hit the A button on the fitness tracker and a heart will appear.
-
To stop gathering data, hit the B button on the fitness tracker and the check mark will reappear.
-
When you are done sending data, hit the A and B buttons at the same time to finish and a happy face will appear.
-
If you used serial_reader.py, a graph of the data will automatically plot. If you used the chrome extension, continue to step 8.
-
Copy and paste the data from chrome to Excel or Google Spreadsheets (select comma-separated when you paste the numbers).
-
Obtain the total acceleration for each row. This is calculated by squaring each value and taking the square root of the sum. In other words, in cell D1, paste this:
=SQRT((A1)^2+(B1)^2+(C1)^2)
-
Click on the bottom right corner of D1 and drag down to the bottom of your data. This will make the same calculation for each row.
-
To graph the data, highlight the D column and click on the graph button. Some adjustments can be made to make the data easier to read, but the default is simply the total acceleration, ideal for showing different activities.
Step 7: Further Exploration
-
Can you think of a way to track steps instead of acceleration? Maybe the fitness Tracker could also detect temperature? What else can be deduced from knowing someone's acceleration throughout the day? Spend some time exploring with your Micro::Bit and see what kind of improvements you can make. Try to steal data from other group's fitness Trackers.
-
Are you able to steal fitness data from another group's tracker?
-
What's the problem with sending unencrypted data over radio?
-
What can you do to make it harder to steal your fitness Tracker data
The GenCyber Wyoming COWPOKES program is supported by the National Security Agency and the National Science Foundation through Award #H98230-18-1-0095. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation, the National Security Agency, or the U.S. government.