Disclaimer: The blueprints and information made available on this page are examples only and are not to be used for production purposes. Twilio disclaims any warranties and liabilities under any legal theory (including, without limitation, breach of contract, tort, and indemnification) in connection with your use of or reliance on the blueprints. Any liabilities that arise in connection with your use of these blueprints shall solely be borne by you. By accessing and downloading these blueprints, you agree to the foregoing terms.
Problem Commercial vehicle fleet managers are required by law to track various driver and vehicle behaviors. Beyond the data logging mandated by law, there are other behaviors that employers might want to track. If they had a low-cost, reliable, and technical monitoring solution, they could remove or minimize the risks associated with their fleet management.
Solution We will create a Twilio-powered Fleet Tracker that uses off-the-shelf components to track and log: miles driven, hours of uptime and downtime, locations, average speed, and fuel consumption.
Degree of Difficulty (1-5): 2 This device requires some knowledge of the C programming language, microcontroller basics, and GPIO wiring.
Before we get started, here's a quick overview of what you'll need to build the Fleet Tracker:
Electronic Components In order to build your own Fleet Tracker, you'll need the following items:
- 1x Twilio Programmable Wireless SIM
- 1x Programmable Wireless Starter Pack
- 1x OBD-II adapter
- 1x GPS antenna
- 1x RF antenna
- 1x Arduino header pins
Serverless Twilio Fleet Tracker involes 3 separate development process
- Twilio Runtime Functions
- Angular Single Page Application
- MultiTech Dragonfly hardware
If you do not want to build everything yourself, you could skip all steps related to building assets, and take artifacts and instructions from https://github.com/twilio/wireless-fleet-tracker/tree/serverless/assets directly.
- Build twilio-runtime-utils with
make build
- Setup PATH to twilio-runtime-utils.sh shell script
- Checkout
twilio-connected-devices
branch of wireless-co-pilot
Go to runtime
directory.
$ twilio-runtime-utils.sh -c context-local.yaml run Authenticator/descriptor.yaml Authenticator/testdata/simple.yaml
{"success":true,"username":"twilio","ttl":3600,"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0.eyJqdGkiOiJTSzI2MzQ3MTM2N2E0OGI2Yjc4NjEyZTQyYzA5ZmFkNmI3LTE0OTUyMDQ5NDkiLCJncmFudHMiOnsiaWRlbnRpdHkiOiJ0cnVtcCIsImRhdGFfc3luYyI6eyJzZXJ2aWNlX3NpZCI6IklTYzg5NThjOGIzODNmZmM2YjhkMTc2ZmJlYmViMWE1YTkifX0sImlhdCI6MTQ5NTIwNDk0OSwiZXhwIjoxNDk1MjA4NTQ5LCJpc3MiOiJTSzI2MzQ3MTM2N2E0OGI2Yjc4NjEyZTQyYzA5ZmFkNmI3Iiwic3ViIjoiQUM3OTMzOTk2M2E5OWY0NzZlNmYwYjMyMTRhYmQ0OGE5ZCJ9.IPQ5QTkTacXaQ4YI4nifii_yrabI5Fk5gzYse8M4tT4"}
$ twilio-runtime-utils.sh -c context-local.yaml run FleetManager/descriptor.yaml FleetManager/testdata/list.yaml
$ twilio-runtime-utils.sh -c context-local.yaml run FleetManager/descriptor.yaml FleetManager/testdata/add.yaml
...
Currently twilio runtime RESTful API is not available, manual deployment process is needed. However you could follow instruction generated by the following commands:
$ twilio-runtime-utils.sh -c context-local.yaml deploy FleetManager/descriptor.yaml
$ twilio-runtime-utils.sh -c context-local.yaml deploy Authenticator/descriptor.yaml
For Twilio Fleet Tracker, two functions are required:
- Authenticator, token authentication for Admin UI
- FleetManager, list/add/delete/genkey for vehicles
Go to angular
directory.
$ npm install
$ ./node_modules/.bin/grunt dev
$ ./node_modules/.bin/grunt build
Upload these files to Twilio Runtime assets:
$ ls -lh angular/build/assets/*.{js,html,js.map}
-rw-r--r-- 1 zmiao TWILIO\Domain Users 1.7K Aug 16 16:41 angular/build/assets/index.html
-rw-r--r-- 1 zmiao TWILIO\Domain Users 16K Aug 16 16:41 angular/build/assets/index.js
-rw-r--r-- 1 zmiao TWILIO\Domain Users 63K Aug 16 16:41 angular/build/assets/index.js.map
-rw-r--r-- 1 zmiao TWILIO\Domain Users 160K Aug 16 16:41 angular/build/assets/styles.js
-rw-r--r-- 1 zmiao TWILIO\Domain Users 343K Aug 16 16:41 angular/build/assets/styles.js.map
-rw-r--r-- 1 zmiao TWILIO\Domain Users 465K Aug 16 16:41 angular/build/assets/vendor.js
-rw-r--r-- 1 zmiao TWILIO\Domain Users 2.0M Aug 16 16:41 angular/build/assets/vendor.js.map
- Create an ARMmbed developer account
- Visit the Dragonfly Fleet Tracker repository
- Click the yellow Import into Compiler button
- Click the Import button
That's it! As a reminder, full instructions for this tutorial can be found in the Fleet Tracker Blueprint.