Jonathan Li
Created January 21, 2019 © GPL3+

Bike Mounted Journey Tracker

It serves you the latest and greatest stats of your most recent bike journey: average speed, duration, distance, and road roughness.

BeginnerFull instructions provided7 hours81

Things used in this project

Hardware components

Rapid IoT Prototyping Kit
NXP Rapid IoT Prototyping Kit
×1

Story

Read more

Schematics

Blueprint for the Bike-Mounted Journey Tracker

This schematic describes the overall components of the Bike-Mounted Journey Tracker and their jobs.

Code

Acceleration Display with Cloud source.zip

C/C++
1. Upload and run this code onto your Rapid IOT Device
2. Enable Bluetooth on your smartphone
3. Open the NXP Rapid IOT App and navigate to My Devices
4. Search for the Device called Acceleration Display with Cloud and provision it
5. To begin recording your journey, tap the app page icon
6. To stop recording your journey, tap back button (or on iOS swipe back) to leave the app page
7. To see the Cloud Storage dataset for your journey, navigate into the Device Settings and download the Cloud Storage Dataset
8. Make sure to clear Cloud Storage dataset before beginning a new journey
No preview (download only).

report_stats.py

Python
1. Download Cloud Storage Dataset from NXP Rapid IOT Device Cloud Storage
2. Rename the file to "data.csv" and put it in the same directory as this Python 3 file
3. Run this Python 3 file
import csv
import datetime
from statistics import stdev

# Accelerations x y z
ax = []
ay = []
az = []

timestamps = []

with open('data.csv', newline='') as datafile:
	reader = csv.reader(datafile)
	next(reader, None)
	for row in reader:
		ax.append(float(row[1]))
		ay.append(float(row[2]))
		az.append(float(row[3]))
		timestamps.append(row[4])

# Velocities x y z
vx = 0.1 * sum(ax)
vy = 0.1 * sum(ay)
vz = 0.1 * sum(az)

average_speed = (vx**2 + vy**2 + vz**2)**0.5
total_time = (datetime.datetime.strptime(timestamps[-1], "%Y-%m-%dT%H:%M:%S.%fZ")-datetime.datetime.strptime(timestamps[0], "%Y-%m-%dT%H:%M:%S.%fZ")).total_seconds()
distance = average_speed * total_time
stdev3d = (stdev(ax)**2 + stdev(ay)**2 + stdev(az)**2)**0.5

print('average speed:', '%.3f'%average_speed, 'ft/sec')
print('duration:', '%.3f'%total_time, 'seconds')
print('distance: ', '%.3f'%distance, 'feet')
print('road roughness:', '%.3f'%stdev3d)

Credits

Jonathan Li

Jonathan Li

1 project • 0 followers

Comments