Back to Home

OBD-II diagnostic connector, as an interface for IoT

Once upon a time · around the mid-90s · during the appearance of the Pentium Pro processor · one of the founders of Intel · Gordon Moore · noted that: “If the automotive industry developed at a speed ...

OBD-II diagnostic connector, as an interface for IoT

    Once upon a time, around the mid-90s, during the appearance of the Pentium Pro processor, one of the founders of Intel, Gordon Moore, noted that: “If the automotive industry developed at the speed of evolution of the semiconductor industry, today Rolls-Royce could drive half a million miles per gallon of gas, and it would be cheaper to throw it away than pay for parking. ” But, perhaps, today the automotive industry is making a giant development step in the direction of a cardinal change in the type of fuel and the technology of driving a car. Practically recently, commercial electric cars and hydrogen-fueled cars are presented, and the autopilot becomes the desired component of the vehicle's electronic “stuffing”. Largely, just a rapid breakthrough of the automotive industry due to the emergence of reliable and safe solutions based on smart electronics for automotive onboard control systems. But where is the Internet in the car in everyday life, where is the Internet of Things technology (IoT), as well as the well-known concept of the car connected to the network (Connected Car)?


    The Rolls-Royce 103EX. Rolls-Royce unveils driverless electric car concept, complete with silk love seat - The Telegraph .

    In fact, all of the above technologies already exist and are used, however, only in sufficiently separate solutions. The reason for this is the strict security requirements that must necessarily be implemented when launching any new technology or transport solution. Therefore, it cannot be said that, getting into a car with a smartphone, you can automatically receive an IoT or Connected Car solution. In most countries, and this is very logical, there is a ban on using a smartphone or other gadgets at the wheel, and if we talk about voice assistants, in most cases they are annoying and distracting both the driver and passengers. In turn, the media center, additional video screens and excellent acoustics, of course, are very attractive components of a modern car. But I want to catch myself at my word, and note that how good it is to muffle the music and just look out the window at the passing streets or nature. Of course, there are traffic jams, but in this publication the aim is to point out not only the ethical component or to consider the problems of information glut of road users, but to consider those “invisible” components of IoT technologies that are already used in vehicles and are available for widespread use.



    Today, an interesting and very promising solution for automotive IoT is the Mojio Open Connected Car platform. This open interface platform (API) provides a cloud service for “connected” cars and commercial offers are already available. For example, the telecommunications giant T-Mobile, based on this platform, provides SyncUP DRIVE service. This is a hardware and software solution based on a portable device that is connected to the vehicle via the OBD-II diagnostic connector., and the corresponding mobile application. With this approach, you can effectively perform continuous monitoring of the parameters of your car and at any time to get its current location. The application can tell about driving styles, warn about preventive maintenance, as well as notify the owner about problems with the vehicle. In addition, SyncUP DRIVE deploys a Wi-Fi access point in the car using high-speed mobile standard LTE access.


    The Open Connected Car Platform - Mojio

    To connect to the car using the standard diagnostic connector OBD-II. Most production cars produced after 1996 are already equipped with such a connector. Although this diagnostic connector is standardized, it supports several protocols of various engine control systems at once (physically using different contacts on the connector) that the IoT communication module must know. Accordingly, in different brands of cars there can be different internal tires for obtaining diagnostic data from the engine control side (ECU - Electronic control unit). A solution based on the ZTEWelink VM6200S module is proposed for working with the SyncUP DRIVE service.

    VM6200S module supports connection via mobile LTE protocol, contains an integrated 3-axis acceleration sensor and 3-axis gyroscope, GPS receiver, OBD-II chip, supporting ISO 15765-4 (CAN), ISO 14230-4 KWP protocols (Keyword Protocol 2000), ISO 9141-2 (Chrysler, Euro, and Asian automobiles), SAE J1850 PWM (Ford vehicles), SAE J1850 VPW (GM vehicles). Thus, the module allows you to deploy a Wi-Fi access point 802.11 b / g / n /, record events while driving, perform engine diagnostics, evaluate fuel economy, etc. And since the partners of Mojio are Amazon Alexa projects, IFTTT service and others, then all prospects open up for developers and solution integrators, including the creation of a social IoT based on a “connected” car as part of such an infrastructure.


    VM6200S4G OBD Device - ZTEWelink Corporation

    But not only SyncUP DRIVE is now on the market, for example, many companies provide something similar. Of course, the newly emerged Samsung Connect auto device is one such interesting suggestion that turns a car into a connected device. Samsung's solution similarly uses the 4G LTE generation mobile network and expands the Wi-Fi access point inside the car: 802.11 a / b / g / n. Connect auto device supports Bluetooth v4.1 connectivity, contains a GPS receiver, an acceleration sensor, a gyroscope, and is based on a 4-core 1.2GHz processor and Tizen operating system. It should be noted that the Korean electronic giant Samsung speaks about the security of the system through the use of Samsung Knox - a mobile solution with enterprise-level protection.


    Samsung Connect auto

    Thus, the information obtained by means of reading OBD-II dataThe current location coordinates from the GPS receiver and the vehicle dynamics parameters obtained from the gyro sensors, at the current time and de facto, became the basis for turning any vehicle into an IoT device. Then you can consider scenarios for using aggregated information received from cars, apply various Big Data processing techniques, and at the same time, you should not forget about the prospects of combining such data with information from the infrastructure of smart roads. But before you start processing data, you must first get them, so this publication will focus on the hardware component of the implementation scenarios at the level of the diagnostic connector OBD-II.

    One way or another, all the previously reviewed solutions are more advanced industrial products, compared with the conventional diagnostic code reader on the basis of the ELM327 chip by the Canadian company Elm Electronics. The ELM327 is a universal protocol converter used in vehicle diagnostic tires to serial protocol type RS-232.


    Block diagram of the ELM327 v2.2 chip - Elm Electronics The

    interaction with the ELM327 is carried out by standard AT-commands supported by the microcircuit. You just need to organize the exchange of text messages on the RS-232 protocol, which has already become a classic (or, more correctly, UARTbecause we are talking only about data flow, not signal levels). And the very low level physical connection via USB, Bluetooth or Wi-Fi is simply implemented using serial conversion chips UART. It turns out that to turn a car into an IoT device is quite enough, without forgetting to coordinate the voltage levels, connect the ELM327 chip to the OBD-II diagnostic connector and, for example, put a serial interface converter into Bluetooth or Wi-Fi at the output of this chip. Then, you can “read” vehicle diagnostics from your smartphone. However, there are plenty of such ready-made modules or blocks on the market. And their price on AliExpress ranges from US $ 2.50 to US $ 10. Although the module does not have to consume a lot of energy, but it will be very convenient if there is already a power button on it.


    Mini ELM327 Bluetooth OBD-II Car Diagnostic Adapter V1.5

    Now you can connect the standard module Mini ELM327 Bluetooth OBD-II V1.5 (interestingly, many sources advise you to use modules with the old firmware version 1.5, and not new ones with version 2.2, t As an argument, a more stable operation of the module on the old firmware and support for more cars is expressed, but this is very subjective) and experiment with connecting the smartphone to the selected module, for example, for the Android platform you can use one of the most popular diagnostic programs Torque Lite (OBD2 & Car) or Torque Pro (OBD 2 & Car), as well as something simpler or use your work.


    The work of the Torque Pro application for Android.

    By the way, I want to note a very convenient service MockUPhonewith free mock-up of modern gadgets, which is very useful for preparing a screenshot of the program Torque. But this is a slight deviation from the topic of publication. It should be noted that in most cases, the OBD-II connector to which the diagnostic module is connected is under the steering column of the car.


    Getting Started with OBD-II - SparkFun Electronics

    It is clear that there are plenty of ready-made solutions. But if we are talking about developing a service based on IoT or more specifically, the concept of Connected Car is being implemented, then it is quite convenient to use the on-board information network emulator of the car in order not to run every time to the car. For example, Mojio to work with its API offers an online car simulator, and the example of working with the IBM Watson IoT Platform cloud service in the article: “IBM Watson IoT Platform - IBM developerWorks Recipes is proposed to send a mobile application to the cloud from a vehicle, for example, “ IBM IoT for Automotive - OBDII Fleet Management App for Android ” that interacts with the deployed cloud service. IBM IoT for Automotive (Bluemix) - Fleet Management Starter Application ", but if you do not get distracted by these projects, you can use just a data emulator:" Car Simulator". True, all these solutions, basically, emulate the data already received, as it were, and we are interested in the on-board information network emulator. The most well-known such solution is ECUsim 2000, the cost of which starts from US $ 200 and depends on the number of supported emulated protocols.


    ECUsim 2000 OBD Simulator - ScanTool

    Of course, a professional emulator cannot be replaced, but enthusiasts and geeks may well be interested in the independent implementation of a less complex project on Arduino or Raspberry Pi. For example, you can restrict yourself to only the most common CAN interface (Controller Area Network). At one time, the CAN standard, proposed by Bosch, has made notable progress in the development of systems for automotive electronics. If the car appeared on the Internet only recently, then the concept of a network inside the car has existed since the mid-80s. The idea is very simple, and as Ethernet made a breakthrough in computer networks, so CAN became the basis for reliable communications inside the car.


    An Arduino Based CAN Bus Network - Henry's Bench

    Earlier in the car, as a rule, tires and wires of various connected modules and devices “flocked” to the central engine control unit. The serial two-wire CAN bus allowed the implementation of already independent intelligent modules, for example, the central control unit became just one of those modules that “communicate” with each other in fact via a network protocol. This significantly reduces the amount of wiring inside the car.

    Unlike Ethernet, the CAN network is more reliable, which caused its use not only in the automotive industry, but also in industrial automation systems, smart home solutions, etc. At the physical layer, CAN uses a two-wire line, CAN Lo and CAN Hi, which transmit data packed in a bit-by-bit package. At the ends of the bus there are terminating resistance of 120 Ohms, and also to suppress interference, you should use the twisting of the wires. Data transfer rate can reach 1 Mbps.


    A Controller Area Network (CAN bus)

    Data transfer to the CAN bus is somewhat reminiscent of the publisher-subscriber model, where each device on the bus has a unique identifier and when one device transmits data, everyone else listens and decides on the basis of this identifier whether they specifically need these data for reception and processing or not. In general, the protocol is rather complicated, but for a microcontroller or microprocessor, it is unlikely that you have to write a CAN implementation, as well as think about the features of the physical transmission medium. To solve these problems, there are already ready bus hardware controllers, and integrated converters are often used for level matching. For example, the MCP2515 controller with an SPI interface and a transceiver (level matching chip) MCP2551. Just on the basis of these chips and the proposed project Arduino OBD2 Simulator,Instructable . To implement it, you need only the Arduino UNO and CAN-BUS Shield, for example, from Seeed Technology.


    Experiments using the Arduino OBD2 Simulator

    In principle, for the development of an OBD-II data emulator, the presence of a 12V DC power supply for the ELM327 module, as well as an OBD-II connector, will not interfere. However, the no-name DC-DC-USB-TO-12V converter can easily solve the problem, since A few 5V power supplies will probably be on hand with any developer for the Internet of Things and beyond. To connect to OBD-II, you need two information wires CAN_H and CAN_L, as well as the presence of 12 V power supply, but as noted earlier, 12 V is needed only to ensure efficiency for the ELM327 module.


    CAN-BUS Shield V1.2 - Seeed Development Limited Wiki

    On the CAN-BUS Shield expansion card it is very convenient to use not the D-SUB connector, but simply a two-pin terminal block (CAN_H, CAN_L). From the point of view of software development, it should be noted that the prototype enthusiasts posted on GitHub . Now, the Seeed boards have changed, and in any case, for the MCP2515 controller, it is better to use all the new Seeed-Studio drivers . Of course, the original program will need to be slightly modified for new drivers, but this is a matter of a couple of minutes.


    Work with CAN-BUS in Arduino IDE based on low cost OBD2 ECU Simulator

    However, the considered example is very primitive, since all the parameters sent via the OBD-II protocol are simply generated randomly, there is no connection between the parameters of the engine operation, etc. As a continuation of the project, the development of an application similar to Freematics OBD-II Emulator GUI is obvious. This is an open source graphical shell that is used in the Freematics OBD-II Emulator hardware solution .


    Freematics OBD-II Emulator GUI - Freematics

    Thus, having assembled a module on the basis of Arduino that allows to work with CAN, it is quite possible to create an OBD-II emulator, since the diagnostic protocol is well described and easy to implement. It should be noted that the implementation of the interaction between the microcontroller and the on-board CAN bus is a completely different task and you need to understand that the internal high-level protocols of this bus are not documented by the automakers, and on the other hand, they should not be embedded in the internal structure of automotive electronics in order reduce the safety of vehicle operation. If we talk about CAN in general, then it is possible to use the high-level open CANopen protocol to develop your devices based on this bus.

    It remains to be easy - a little free time and a pleasure to develop your own code. True, where is the time found at the end of the year? But let's be optimistic. But if we talk about the use of such an OBD-II emulator, the most direct direction is the development of its own module for the diagnostic connector. For example, you can take the Carloop open project as a starting point, which aims to create a module for connecting a car to the cloud using 3G, Wi-Fi or Bluetooth technology.


    Carloop bluetooth

    The Carloop project is based on the use of boards: Particle Photon (based on the Cypress BCM43362 Wi-Fi module that supports the 802.11b / g / n standard; ARM Cortex M3 controller family — STM32F205 at 120Mhz; 1MB of flash memory; 128KB of RAM) and Electron (boards supporting 3G / 2G mobile network connectivity). Particle platform itself is very interesting, because it is based on the cloud connection service of IoT devices, a cloud IDE for development, for example, based on Photon boards, which uses a language similar to C / C ++ for Arduino. In fact, Particle is a separate topic for publication, and the Carloop project definitely deserves special attention from the enthusiasts of the car, as a connected IoT device.

    By connecting the car to the Internet and IoT services, you can implement a variety of scenarios that will undoubtedly contribute to the ease of use of vehicles, increase comfort and, simply, effective solutions to everyday tasks, of course, including the solution to transportation. For example, data on driving style, reliability of the engine and car units, it is possible and already now are taken into account by insurance companies. The current location of the car will be relevant for taxi services and car rental. The interaction of road users becomes more convenient when using IoT, as well as the problem of parking, searching for free parking spaces, and much more.



    We hope that the idea of ​​this publication has been achieved - materials on working with the OBD-II diagnostic connector are collected in one place, both at the level of simple reading of fault codes and emulation of the physical connection to the car. We also hope for the comments of readers. In conclusion, we would like to note that only some issues of the development of the Connected Car devices were considered, but many technologies remained “behind the scenes” that, one way or another, turn the modern car into an IoT device and make riding more comfortable and safe. Of course, we will return to these topics in our future publications.

    Interesting resources and links:


    - Car Hacking: Are car safety systems safe? - Habrahabr
    - Microprocessor - 25 years! - Computerworld
    - T ‑ Mobile SyncUP DRIVE - T-MOBILE
    - ZTE and Mojio will make almost any car part of the Internet of Things - ZTE Corporation
    - Samsung Knox - SAMSUNG
    - CAN protocol capabilities - STA Magazine
    - Internet of Things in your home - connect to home your car - IBM developerWorks
    - Vehicle telematics analytics using Watson IoT Platform Cloud Analytics - IBM developerWorks Recipes
    - Using CAN network and CANopen stack - Habrahabr
    -CANopen High Level Protocol - RADIOLOZMAN Magazine - Do-it
    - yourself on - board computer for Arduino - Geektimes
    - Wiring the CAN Controller - 14CORE
    - Arduino OBD2 ELM327 I2C-LCD HC05 Bluetooth - Instructables
    - Android Application Development for Working with the OBDII Protocol - Habrahabr

    Read Next