In daily cases we come across situations where we have to deal with any third person driving our vehicles or we may be the owner of some renting company, renting 4-wheelers. In these situations, we may have to monitor our vehicles remotely for understanding the driving conditions of the vehicle and as well as understand the vehicle performance. In a worst-case scenario, if our vehicle meets with an accident, we may need to have a look at exactly what went wrong.

Some months back, I was driving my car and going to a quick fuel recharge and the windshield kept on fogging thus reducing my visibility. While taking a small turn, I accidently hit the divider and the car overturned. Fortunately, no one was hurt. I till date don’t have much of an idea what went wrong. Obviously, the fog was responsible but what was the speed, rpm of the vehicle is still unknown to me. At such times, it’s very important to know the telemetry parameter to understand the reason behind such mishaps and also create Thus, we came up with VAMS. Vehicle advanced monitoring system provides an all in one solution where we can monitor our vehicle’s data remotely and at the same time the stored data can be used to assess driving conditions, terrain conditions and in case of a mishap, be used to understand what went wrong. The use-case discussed here are only the tip of the ice-berg and more can be used for further analysis.

What it does

It uses the OBD-2 port to interact with the vehicle’s ECU. The ELM327 IC HANDLES all the communication between the Raspberry Pi and the OBD-2. Through a python script which is running in the Raspberry Pi, we stream in all the incoming data to the Azure IoT Hub. At this stage we are interested in three primary parameters namely speed, engine rpm and coolant temperature. These telemetry data along with the vehicle details like registration number are streamed to the IoT Hub.
Our system uses the combination of Azure IoT Hub, Azure function, Azure Cosmos DB and Microsoft Power BI to save and visualise the data live as well as save it to a Cosmos DB using Mongo DB API. The only necessary parameter as of now for our system to work is the availability of Internet. Once the vehicle is started, the Raspberry Pi starts streaming the data after connecting itself to the OBD-2 scanner via bluetooth.

How I built it

Edge Device

It includes the OBD-2 interface which interacts with the vehicle’s ECU. Additionally, it also includes the Raspberry Pi which interacts with the scanner to get the data. The Raspberry Pi is model zero w which has Wi-Fi and bluetooth capability. All the data (speed, rpm and temperature in this case), are then routed to the Azure IoT hub for further processing. The Raspberry Pi can be powered by the 12V power outlet from the vehicle and the OBD-2 adapter receives power from the port.

Cloud connectors

The edge device streams all the data to the Azure IoT hub using device ID and the respected connection string. The IoT hub is triggering an azure function which is the main component of the entire system. The Azure function app gets triggered whenever there is an incoming message in the Azure IoT hub. The function then handles the message and routes it to other areas like Cosmos DB and Power Bi. The function is coded in C#. The data flow is shown below.

Data storage and visualisation

We are using Azure cosmos DB with Mongo DB API and power Bi for visualisation. The power bi uses streaming data-set and a Power BI dashboard for visualisation. A screenshot is shown in the attached image.

The Dashboard

The dashboard in the video is the power bi dashboard in the power bi app for ios as displayed in an ipad. The dashboard was designed using the web app for power bi.

Challenges I ran into

The major challenge for us was that since, we didn't had any simulator for OBD-2. Each time we tried out some features, or developed something new, we ended up coding inside the car. Getting a synchronised data from the port was also a challenge and getting a stable internet connectivity travelling was kind of challenging.

Accomplishments that I'm proud of

We are proud of attaining synchronous communication flow from edge to dashboard using the entire Azure stack. From ECU to IoT hub and from Function to Power BI dashboard.

What I learned

We learnt a lot of stuffs including the way how Azure IoT hub works using mqtt, the triggering of an azure function and ultimately the storage capability of cosmos DB and live power bi dashboard. We also learnt that how ECU functions, the CAN BUS and ultimately details of several Parameter ID(s) and Error code DTC in a car.

What's next for VAMS

The future of VAMS is to deploy it as a single embedded device which will require minimum configuration and will come up with a flash memory which will act as a local DB. This DB will update the global DB when internet connectivity will be established. Additionally this will include more parameters depending on the class of the vehicle. We will be able to analyse the different driving patterns and also include maps which will give us a strong conclusion about the driving patterns and conditions in different terrain(s). Also more sensors like the IMU will be integrated.

Additional resources and testing

Setting up Azure IoT stack including IoT Hub, Cosmos DB and Azure function may be referred to this link Article here

For device side we are using a real device rather than a simulated one. We used the following devices for testing OBD-2 Raspberry Pi

An active power bi account may be required for testing

Please feel free to contact us in case of queries.

Built With

  • azure-function
  • azure-iot-hub
  • c#
  • obd-2
  • power-bi
  • python
Share this project: