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.
Solution We will create a Twilio-powered Co-Pilot that uses off-the-shelf components to track and log the following data:
- Miles driven
- Hours of uptime / downtime
- Locations
- Average speed
- Average acceleration rate / driver aggressiveness
- 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 Co-Pilot:
Electronic Components
- 1x Twilio Programma Wireless SIM
- Looking for access to Programmable Wireless? Use the Access Code blueprints
- 1x MultiTech Breakout Board
- 1x MultiTech Dragonfly Modem
- 1x Freematics OBD-II UART Adapter V2
- 1x (Optional) Status LED
- 3x (Optional with LED) Molex C-Grid Headers - 3 Position
- 4x Molex Contact Crimp Pin - 24-30 AWG Tin
- 1x GPS Antenna
- 1x RF Antenna
- 2x U.FL Extension Cable
Other Hardware
- 3x Thumb Screws For Body Covers 4-40x5/16"
- 3x Threaded Inserts for Body Covers 4-40 Thread
- 1x Bob Smith 103 Insta-Cure 2oz Super Thin Glue
- 1x 3M VHB Foam Tape
- 1x Molex Hand Crimper Tool - 14-24 AWG Side Entry
(Optional) 3D-Printed Parts In addition to the electronic components and mechanical hardware, the body of the Co-Pilot is fabricated from 3D-printed parts.
You can download the 3D CAD Model here
Using this 3D CAD Model, you have a few options for actually building the body:
- Print it, if you have access to a 3D printer.
- Alternatively, if you don't have access to 3D printer or want to ensure quality, you could use a third-party 3D printing service. We recommend Sculpteo or Voodoo Manufacturing.
(Optional) Laser-Cut Part The Co-Pilot has one clear acrylic cover panel that attaches to the outside of the 3D-printed case. You will need to build this as well. You can download the panel model here As with the body, you can make the panels yourself based on the designs or choose to use a third-party service. We again recommend Sculpteo.
Whether you are cutting and printing yourself or using a service, double check the units and dimensions of all parts after uploading.
Server Software You'll need a server to collect data. You can create your own or run our simple NodeJS backend Set up instructions here.
(Optional) 3D-Printed Parts Surface finishes and residues left on the parts will vary depending on the type of printer or service used to produce them. Third-party producers should produce finishes to specification and clean parts before they ship, but prints done yourself will require special attention.
- Always be sure to clean parts thoroughly according to the printer manufacturer’s directions. Double-check hard-to-reach areas like screw holes; these areas may need to be scraped out.
- Check to make sure that there are no remaining residues that could prevent adhesives or glues from performing adequately. If you are able to scrape material off a surface with your fingernail, it is likely that any adhesive used in that area will be unreliable.
- For cosmetic finishing in these areas, diligent 400-grit wet sanding will clean off the residue and leave a smooth, matte surface.
- For areas that will be covered by wires or electronic components, residues must be scraped off before assembly can begin. Any small, hard steel tool can be used. (Dental picks and chisels should work well.) Don’t worry about the appearance, as these areas will be covered after assembly.
(Optional) Laser-Cut Parts If you have access to a table router with a 45° chamfer bit, adding a small bevel to the outside edge of the acrylic can clean up the appearance of these parts. When assembling, be sure to keep the side with the bevel facing away from the enclosure.
Step 1: Prep Multi-Tech Break-Out Board.
- The breakout board is what allows us to interface the microcontroller to the Freematics OBD-II unit. Out of the box, there are a few features on the board that we will not use. To save some some space and reduce the bulk of our final device, we removed these features.
- First we will remove the 3 antenna RP-SMA connectors on each corner of the board. This can be done by loosening the corresponding Phillips-head screw on the underside of each connector. Simply remove the screw and the connector will separate from the board.
- Next, we will remove the large serial port on the lower right side of the board. We will be using the micro usb ports to interface with the board, making this port redundant. De-Solder each pad beneath the connector and remove.
- Lastly, we will remove the 4 rubber standoffs located on the underside of the board.
- Now the breakout board is ready to accept the ST micro controller.
Step 2: Prepare the ST Dragonfly microcontroller.
- The ST microcontroller contains all of the computational hardware for this device.
- To prep this portion of the hardware, we will first need to insert the twilio SIM card.** Insert the SIM card into the card port on the underside of the ST dragonfly board**.
- Once the SIM card is inserted, place the micro controller into the appropriate receptacle on the Multi-Tech Break-Out Board.
- Once the controller is in place, place the two corner screws in place with a Phillips head screwdriver.
Step 3: Flash the ST microcontroller.
- Now we will place the necessary firmware onto the microcontroller. In order to do this, we will need to connect to two different micro USB ports: one on the breakout board and another on the ST microcontroller itself.
- The Dragonfly is an mbed supported hardware platform, which allows you to compile for it using the online mbed IDE available at developer.mbed.org.
- After creating an account, open the “Compiler” window from the menu bar at the top of the user homescreen.
- Import the mbed project into the compiler using the import button at the left of the project page, or create a new project and import the individual files into that new project. If you import the project files make sure you add the mtsas and mbed libraries to your project.
- Select the target platform in the upper right corner of the mbed compiler window.
- Add a platform and select the MTS dragonfly.
- Hit “Compile” which will generate a file for download. The initial attempt will fail because the mtsas library is missing—push the “Fix It!” button next to the error to prompt the mbed compiler to automatically locate and import the correct library.
- The next time you hit “Compile” it should succeed and will generate a file for download. Either save this to the new USB drive associated with the dragonfly device or copy from your downloads folder into this drive.
Step 4: Prep 3D-printed body for assembly.
- First, we will need to drive the three brass threaded inserts into place. Do this by orienting the knurled side of the insert down, and then lightly tap them into place. To get them properly seated, using a punch and light hammer are recommended.
Step 5: Place components into enclosure.
- We are now ready to begin placing the components into the 3D-printed housing.
- Place the GPS antenna into the slot located on the top left of the printed housing.
- Next apply the adhesive-backed wireless antenna into the slot directly below.
- Now, we will apply VHB or another 2-sided, adhesive-backed foam to the breakout board. After the foam is applied, we will orient the board as pictured and seat it into the printed housing.
Step 6: Wire and connect components.
- First, connect the rsma extensions to each antenna and route the antenna wires into their corresponding channels. You can use a small bead of cyanoacrylate or other fast curing adhesive to tack the wires into place for a cleaner look.
- The GPS antenna will be connected to the "G" terminal on the microcontroller, and the mobile wireless antenna will be connected onto the “M” terminal.
- Terminate the the Freematics OBD-II unit with two pairs of molex C-grid connectors.
- Pair the red and black wires to supply the breakout with power, and pair the white and green wires for data.
- Next we will insert the red wire into V-in and the black wire to ground. Then, insert the green wire to D0 and the white wire to D1.
- Delicately bend the pins of each connector to 90 degrees in order to save overhead clearance.
- Route the wire of the freematics unit around the ST microcontroller and then through the strain relief port on the top right of the enclosure.
Step 7: Add external GPIO connectors and Status LED.
- In addition to wiring the freematics unit to the breakout board, we will add several ports for additional GPIO function. There are three bosses at the top of the enclosure that are designed to accommodate three pin molex C-Grid connectors. The plastic housing can be glued in place for any wiring configuration of your choosing.
- The top of the enclosure also accommodates a 3mm status LED. An inline resistor will need to be soldered to the LED, which can then be connected to a variety of GPIO pins. We set it up as a simple on/off indicator.
Step 8: Place cover on enclosure.
- Place the acrylic faceplate over the device, and then tighten all three thumb screws.