Introduction: DIY Telematics Box
Telematics boxes (aka Black Boxes) are used to record and log various attributes of a moving vehicle. They have been primarily used in airplanes to log various attributes of an aircraft, for example, air speed, heading, fuel levels, radio chatter etc. It is the first reference point for any aircraft incident, as it holds all the aircraft data leading up to the incident. This method of monitoring vehicle performance, condition, and movement has since been transferred to cars, allowing insurance companies to obtain a better estimation of driving styles in order to present the correct premiums to their customers.
Some companies ask for an additional fee for installing one, others will do it for a reduced insurance price. This instructable is designed to give a step-by-step instruction on how to build a custom Telematics box for driving vehicles.
DISCLAIMER: This custom-made black box may not always be valid evidence in a court of law. Some countries/states/local laws may not allow installation of custom monitoring units into moving vehicles unless authorised by an approved installation team. For these reasons, and any other associated to tampering with the OBD port, the author(s) of this article and website hold no responsibility over the outcome of your driving, your car, your car's electronics (including on board computer), and any other incidents occurred with a custom-made monitoring unit fitted.
UPDATE/WARNING: I went away for a week, but left all the electronics plugged in. What I didn't realise was that the OBD port is always powered. Because the OBD port uses a Bluetooth port and Bluetooth consumes a fair amount of power, the car battery will drain...
Step 1: Acquire Materials!
For this project, you will need:
- 1x ELM327 OBDII Bluetooth adapter - Ebay
- 1x Arduino Mega* - Ebay
- 1x HC-05 Bluetooth module** - Ebay
- 1x SD card reader module - Ebay
- 1x Neo-6M GPS module - Ebay
- 1x GPS antenna (with SMA connector) - Ebay
- 20x Male-Female 10cm jumper wires - Ebay
- 1x UFL Mini adapter - Ebay
- 1x 3D printed case - (design) SketchUp, (print) 3D Hubs
- 6x 5mm spacers - Ebay
- 4x M3 10mm nuts and bolts - Ebay
- 6x M3 12-16mm nuts and bolts - Ebay
- 1x SD 8GB card - Ebay
- 1x Car USB adapter - Ebay
Thank goodness for Ebay! More information on some of the modules will be detailed in the next steps.
* There is an argument to use the Uno, but because I needed multiple serial ports, and program space was limited, I opted out of the Uno. There is also an argument to use the Due, as it is more powerful. The Due uses 3V3 for its IO pins, which may be damaged by other 5V components. Hence, use the Mega.
** Don't mistake the HC-05 for the HC-06! The HC-06 is a slave-only module, and cannot be configured to be a master. Get the HC-05! IMPORTANT: make sure the HC-05 module has a Key pin to be able to switch into AT mode, otherwise this whole project won't work!
Step 2: How Does It Work?
How are we going to read data from the car? Most cars (if not all cars) after 2003 must have and OBD port to talk to the engine (check before buying!). OBD stands for On Board Diagnostics, and is used mainly to determine any faults with the car. For example, when your engine light switches on, a fault code is logged. When you take it to the garage, the mechanics will have an OBD reader which will read the fault code, so they will know what to fix.
From the OBD port, you can also read live data. The live data available depends from car to car, but most car should allow you to read the basic stuff like speed, rev-count, distance traveled etc. For the purposes of this project, I chose to read the vehicle speed, the engine's RPM, and the throttle depression.
When you get your ELM327, find your OBD port. This will different for every car make. For my Ford Fiesta, it was between the steering wheel and the driver's door. If you can't find it, look up [car brand] [car model] obd port on Google, where there should be a number of videos/pictures showing where your OBD port is. Once located, plug your ELM327 in.
You can test the OBD port easily if you have an Android phone. Go to the Play Store, and download an app called Torque. There is a paid version and a free version. The free version will suffice for demo purposes. Simply connect to your ELM327 by Bluetooth, select the desired PIDs you want to read, and turn your car on. You should instantly see the readings on your screen.
Step 3: Make a Box!
- a model of a box
Result: a 3D printed box and base
Before starting on the electronics, I recommend 3D printing a box (or making your own!) with its own mounting holes. It will be much easier to fix the Arduino in place without all the components in the way!
I designed a simple case (*.skp files) to hold everything in place. The model is made in SketchUp, and the design was 3D printed using the 3D printing services of 3D Hubs, where they will print your models at pretty good quality for relatively cheap.
Print this box out, so that you can place your electronics inside.
Step 4: Assemble the Base
- Arduino Mega
- 3D printed base
- 3x spacers
- 3x M3 nuts
- 3x M3 washers
- 3x M3 12mm bolts
Result: assembled base
Starting with mounting hole number 1 (mounting hole between the 6-pin ICSP header and the Comms pins, see image), place a washer on the top side of the board, and a spacer between the board and the base. Put the screw through the washer, board mounting hole, spacer, and out through the base. There are hexagonal ut-outs under the base to fit the nuts in. Tighten up, but leave enough space for placing the other spacers.
Repeat for each mounting hole.
When all three mounting holes are done, tighten up the screws so that the board is firmly in place with the base. The other mounting holes are not necessary. I could not fit other screws, as they would clash with pin/component placements. These three should be enough to keep the board in place.
Step 5: Wire Up!
Materials for this step:
- Assembled base
- UFL mini adapter
- SD card reader
- 16x jumper wires
Result: base electronics assembly
The first step is to connect everything to the Arduino Mega. You will find the basic connection diagram in one of the pictures attached. We will be making use of the Serial ports, the SPI bus, and some of the IO pins.
If you're curious to know how each module works, you can connect each module individually to test them out. Otherwise if you're confident everything will be OK, just connect everything up.
SD Card Reader
Connect the following:
- CS - pin 53
- SCK - pin 52
- MOSI - pin 51
- MISO - pin 50
- Vcc - 5V pin near pin 22
- Gnd - ground pin near pin 52
Connect the following:
- GPS TX - pin 15
- GPS RX - pin 14
- GPS Gnd - ground pin closest to power socket
- GPS Vcc - 5V pin closest to power socket
- Connect the UFL mini adapter to antenna pin of the module
- (Optional) GPS PPS - pin 2
Connect the following:
- Bluetooth TX - pin 17
- Bluetooth RX - pin 16
- Bluetooth Key - pin 3
- Bluetooth Vcc - pin 19
- Bluetooth Gnd - pin 18
Step 6: Compress It Down!
- Base electronics assembly
Now that everything has been wired up, twist the modules so that they all fit inside the boundary of the Mega, but without disconnecting the wires. You may want to cover exposed pins and electrical components with electrical tape to avoid short-circuiting. Be careful!
Twist the wires until the top of the GPS module is facing the communication pins of the Mega.
SD Card Reader
Basically, bend/fold the wires over so that the top of the SD card reader module is facing down over the Reset button.
The Bluetooth module will "wrap" itself around the GPS module, and end up on the other side of the board, by the analogue pins.
Step 7: Assemble the Box
- Assembled electronics base
- 3D printed box
- 4x M3 nuts
- 4x M3 washers
- 4x M3 10mm bolts
Result: Fully assembled box
Get the other end of the UFL mini adapter and plug through the hole in the box, securing it in place with the nut. Make sure it is tight, as we don't want the antenna to twist it off!
Merge the two assemblies together, making sure none of the wires have disconnected. Align the four corner holes and fit the M3 nuts into the hexagonal holes beneath the base. Place the M3 nuts through the holes and screw the box together.
Step 8: ELM327
- Full assembly
- ELM327 Bluetooth OBD adapter
- Portable computer
On GitHub, you will find a short program (BluetoothScanner) that will scan for some of the closest Bluetooth devices. It will display the MAC address and the SSID (name) of each device. It will also allow you to manually send commands to your car.
For the HC-05 to automatically connect to the ELM327, you will need to find the adapter's MAC address. This is usually different for every module. This is to avoid connecting to the wrong device!
Simply upload the code to the Mega, turn your car on, and run the code. On the terminal output, you should see the results. The code attempts to automatically bind the module to the MAC address selected, but sometimes this does not work. Simply make sure you get the correct MAC address. The address should look like 1D,A5,68988B. Your MAC address may be different, but should be in the same format. Save this for the next step!
You will also need to determine the resulting format of the data that is coming out of the OBDII adapter. Using the code you've just uploaded (in this step), send down the characters 0100. The is the command to determine what data your car can send back to you. The full list of commands is found on Wikipedia.
You will need to check the format of the returned data. In my Ford Fiesta (2012) the command was echoed before the results:
- Command Sent: 0100
- Response Received: 0100BE1FA813
However, in a Renault Clio (2006), the command was not echoed:
- Command Sent: 0100
- Response Received: BE1FA813
The response may be different depending on the car. You will need to remove any preceding characters from the response. Ideally, your response should look like the Clio example above. If you have other characters, remember the number of characters preceding the response. You will need this in the next step!
Step 9: Upload the Code
- Source code
- Assembled box
Result: completed box.
The full source code can be found on GitHub (project name: SimpleArduinoObd), where you will see numerous header (*.h) files. Download the files, and open them in the Arduino IDE.
Remember the MAC address you saved earlier? Open ObdHelper.h and at around line 34 (variable name obdMacAddress) change the MAC address there for the one you saved in Step 4. The address should be comma-separated and in the same format as 1D,A5,68988B.
Remember the response offset you saved in Step 4? Open ObdHelper.h and at around line 23 (definition RESPONSE_PREFIX_OFFSET) change the offset to whatever it should be.
Step 10: Hide the Box
- Completed box
- Arduino USB cable
- GPS Antenna
- Car USB adapter
Result: finished project
Now that the box is complete, we can put it in the car!
- Find a location to put your box. Ideally it should be hidden away somewhere. I put it under my passenger seat. Remember: it must be close enough so that the USB cable can reach the car lighter socket!
- Unravel your GPS antenna and tuck it in the gap between the out body and the inner body, under the rubber sealing. The trailing antenna cable can be tucked under the passenger seat, or under the carpet.
- Place the GPS antenna "head" in a location that can easily see the sky. I put it under the front windscreen.
- Plug the USB cable into the box, then plug the cable into the car USB adapter.
- Plug the car USB adapter into the lighter socket.
You're now ready to take it for a test drive!
Step 11: Results
Unfortunately, to see the contents of the SD card, you have to open the box and manually plug your SD card into your computer to read it. Nevertheless, the files will be stored on it. The file name is in the format [year][month][day][hour]. The file data is in the format [date],[time],[latitude],[longitude],[RPM],[speed],[accelerator].
Below is a sample of what is stored:
- the speed is likely to be in KPH (kilometres/hour), depending on your vehicle.
- the accelerator depression is in percentage (%) and may start at a value higher than 0%.
- the time is in UTC.
Step 12: FAQs
How long for the GPS to acquire a GPS signal?
Usually, about 30 seconds. This depends on location.
How long until the SD card is full?
An 8GB SD card has about 7.67 GB of memory space. Each entry to a file is 55 bytes long. Each entry is made every second of GPS activity. Assuming an average of 2 hours of driving per day, you have the following formula:
([Available Memory Space] / ([bytes per entry] * [number of entries per day]) ) / 365 = time (years) until memory card is full.
Assuming the following:
- Memory space is 7GB (7,000,000,000 bytes)
- bytes per entry is 55 bytes
- number of entries is 60 seconds * 60 minutes * 2 hours = 396,000
(7,000,000,000 / (55 * 396,000) ) / 365 = 48.4 years
In short, a very long time!
Can it send to a server?
To send to a server, you'll need a modem. I have experimented with a SIM808, which has GPS, GSM, and Bluetooth in one chipset (and is slightly cheaper than the hardware used in this project). The SIM808 relies on a 2G network, that is slowly being phased out around the world. I might have to find another solution for this.
Participated in the