Kia EV6 Telematics Dashboard [CAN Bus & UDS + DBC + Grafana]
Case Studies / CSS Electronics
CSS Electronics is a developer of CAN bus hardware incl. CAN/LIN data loggers and sensor-to-CAN modules [Note: This is an 'in-house' case study].
What problem did you solve?
I recently got my new Kia EV6 electric car. And of course, the first thing I needed to check was what data I could extract!
Specifically, I wanted to verify if I'd be able to extract more useful EV data from the Kia EV6 than my previous Nissan Leaf case study - in particular focused around driving efficiency.
Assuming this would be possible, I also wanted to create a visualization dashboard and collect data over an extended period for the purpose of creating a public 'data pack'.
Tip: Download the config, DBC and 3000+ km dataset here!
Read similar case studies for the Tesla, Enyaq and Nissan Leaf.
How did you solve it?
From previous projects involving a Hyundai Kona EV, I had some experience successfully requesting UDS (Unified Diagnostic Services) data with the CANedge2. Since the Hyundai/Kia EVs share the same platform, I assumed there might be some overlap in their UDS request/response patterns.
Luckily, this turned out to be true and I was able to 99% reuse the Hyundai Kona configuration and DBC file for my Kia EV6.
One cool implication is that the config/DBC used in this project should work across all the Kia/Hyundai EVs - incl. the Hyundai Kona, Hyundai Ioniq5 etc., Kia e-Soul etc.
Specifically, I leveraged information from an open source github project to create a CANedge2 Configuration File with a list of 'transmit messages' that would trigger certain responses from the Kia EV6. This involved using UDS multiframe requests with every request frame followed by a flow control frame. For details, see our intro to UDS and the actual Configuration File in the data pack (see below).
I configured the CANedge2 to connect to my iPhone as an access point via WiFi - and upload data to my AWS S3 bucket. This way, whenever I would enable my shared WiFi on my phone in the car, data would get uploaded by the device to the server.
To install the device, I initially just connected it to the OBD2 connector (beneath a panel near the steering wheel) using our OBD2 adapter cable. This works perfectly well, but has the downside that the device remains powered (and transmitting) when the EV is turned off. The EV6 does not provide any 'default broadcast data' via the OBD2 connector, meaning a control signal cannot be used to start/stop the transmission of data into the car - meaning that ECUs could be woken up and the battery would be drained within a few days. To solve this, I modified my installation to use a cigarette-receptacle adapter and a DB9-DC splitter. This ensures that the CANedge power supply is linked to the vehicle ignition, thus avoiding any risk of battery drainage.
In order to add GNSS/IMU data to the log files from the Kia EV6, I also connected the CANmod.gps to the 2nd port of the CANedge2. The CANmod.gps would then be installed within the vehicle via 3M velcro tape so as to ensure a stable installation during driving. As part of this, I measured the CANmod position in the car to adjust the configuration of the device. This in turn lets me leverage the sensor fusion capability of the CANmod.gps (providing precise positioning even in GNSS hostile areas), as well as adding valid data on e.g. the car's attitude (roll, pitch, yaw).
The UDS requests are added in the 'data pack' config file
Analyzing raw data and creating a DBC
Once I had some MF4 log files from the car, I used the asammdf GUI to analyze the raw data via the CAN bus trace view. I also made sure to note down physical observations on key parameters like state of charge, outdoor temperature, tire pressure etc. to allow me to validate the decoding of the data.
With this information and the online github decoding rules, I managed to create a full DBC file covering ~60 CAN signals incl. State of Charge (SoC), State of Health (SoH), cell voltages, temperatures (battery, outdoor, indoor) and more. These signals were in addition to the ~40 CAN signals from the CANmod.gps.
Below are a complete list of signals that were accessible and verified from the Kia EV6:
- TirePressureFrontLeft m4
- TirePressureFrontRight m4
- TirePressureBackLeft m4
- TirePressureBackRight m4
- TireTemperatureFrontLeft m4
- TireTemperatureFrontRight m4
- TireTemperatureBackLeft m4
- TireTemperatureBackRight m4
For an overview of the CANmod.gps signals, see the CANmod.gps product page.
Prior to this project, no public DBC file exists covering the Hyundai/Kia electric vehicles. Rather, the existing formats on github are in a CSV-style file format with extensive cleaning and reformatting required.
To adapt the UDS-style multiframe response data from the Kia EV6 into the DBC file format, I leveraged the same extended multiplexing approach used in e.g. our Nissan Leaf case study. Specifically, we assume that a software tool (our Python API) is used to reassemble all multiframe CAN frames into single CAN frames with lengths exceeding 8 bytes. The 1st byte of the reassembled CAN frames is the UDS Service Identifier (SID), while the next 2 bytes are the UDS Data Identifier (DID). Together, these serve as multiplexors in a similar way as the OBD2 PID in our OBD2 DBC file.
With that in place, it's a fairly simple matter of "translating" the data from the github CSV style to the DBC file format. As part of this, I would validate the data vs. the physical values I could identify from the car's dashbboard, resulting in some minor modifications to e.g. the tire pressure scaling factor and a few other signals.
Dashboard #1: CANedge Grafana Backend
Next, I wanted to visualize the data in a dashboard.
To do so, I deployed our new dashboard integration, the CANedge Grafana Backend.
The Python based backend app can be hosted e.g. on a PC and setup to point at a 'datasource' (e.g. local disk, AWS S3, ...). Grafana can then be configured to fetch data from the backend on-request. This way, any dashboard interaction triggers a request to the backend, which in turn prepares the relevant data from S3 in real-time (with no database inbetween).
One challenge I wanted to solve was to display 'efficiency' in the form of kWh / 100 km - see below for details.
A key signal displayed in the Kia EV6 is kWh / 100 km, serving as a measure of your ability to drive efficiently. The Kia EV6 range of ~500 km is based on an assumption of ~15 kWh / 100 km (est. 74 kWh capacity). As such, adding this parameter to my dashboard would be insightful.
One challenge, however, is that the kWh / 100 km is not an available signal from the github resource. In other words, I had to calculate it as a derived signal.
This could be done in Python, but I decided to do it within Grafana via their built-in 'transformations'. Here, the CAN signals are used within real-time calculations which can be chained.
Specifically, I used the Current and Voltage signals from the car in combination with the Speed from the CANmod.gps. The Current/Voltage signals are logged with the same timestamp, but the Speed differs. Thus I started out 'reducing' the time series to their averages. Next, I would multiply the Current and Voltage to get the power consumption in Watt. I then divided this by the Speed (in meters/second) and multipled the result by 0.027777778 to get kWh per 100 km. See also below transformation flow from within Grafana.
Dashboard #2: CANedge InfluxDB Writer
I also wanted to add the Kia EV6 data to our Grafana 'playground' dashboards. To do so, I used the CANedge InfluxDB Writer to write decoded CAN/UDS data to an InfluxDB database. I then re-created my dashboard with InfluxDB queries. The result can be seen via the playground. Both dashboard templates are available in the EV data pack below.
The CANedge Grafana Backend enables data visualization directly from S3
Example use case: Comparing driving efficiency
So we now have a cool dashboard - what can we use it for?
Well, one example use case was (of course) to battle my wife Josefine in driving-efficiency. As shown in below comparison, it backfired spectacularly. As evident from the power consumption histograms, Josefine was far more dilligent in using the e-pedal, helping her gain an efficiency rate of ~12 kWh / 100 km - while I was stuck at 20+ kWh / 100 km.
As a result, I then started using the e-pedal...
Tip: Check back later for an update in which we'll use the CANedge Python API to perform this comparison at scale.
Get the 'EV data pack'
Want to try working with real electric car data?
Download your 'EV data pack' - incl. sample data, configuration files & DBC files from popular electric cars:
- Kia EV6
- Nissan Leaf
- Tesla Model 3
- Skoda Enyaq
- and more ...
This also contains the 3000+ km Kia EV6 dataset (100+ signals)!Learn more
What benefit has this led to?
This Kia EV6 serves to showcase the versatility of the CANedge2 (and CANmod series) for collecting data from any CAN based application - incl. higher layer protocols like UDS. Further, it exemplifies the value of the new CANedge Grafana Backend in providing a simple way to visualize multiframe data with timesynced GPS plots.
Additionally, the config and DBC can be reused by others to log & decode data across all Kia and Hyundai electric vehicles. For those that simply want to 'play around' with large EV datasets, the free 3000+ km dataset offers a great platform for creating your own Grafana dashboards - or for performing Python-based big data analysis.
— Martin Falch, co-owner at CSS Electronics
Ready to log data from your EV?
Get your CAN logger today!