Car datta logger Using OBD II protocol (atmega 2560+ SD card + lcd 16×2), lcd

Summary of Car datta logger Using OBD II protocol (atmega 2560+ SD card + lcd 16×2), lcd


Summary: This final microprocessor project implements an embedded car data logger that communicates with a vehicle ECU via OBD-II (ISO 15765-4 CAN), using an ELM327 interface hacked to expose its TTL UART lines to an ATmega2560. The system reads OBD PIDs (mode 01) over UART at 38400 baud and logs or displays vehicle parameters (example: vehicle speed PID 010D). Firmware is written in C with Atmel Studio and uploaded via ICSP.

Parts used in the Car datta logger Using OBD II protocol (atmega 2560+ SD card + lcd 16x2):

  • ELM327 OBD-II cable/module (USB version, hacked for TTL Rx/Tx)
  • ATmega2560 (Arduino Mega hardware used)
  • USB cable (for ELM327, cut/soldered to access data wires)
  • Wires/soldering supplies (to connect ELM327 Rx/Tx to ATmega Tx/Rx)
  • SD card (for data logging)
  • LCD 16x2 display
  • Power supply for embedded system/car power interface
  • ICSP programmer (for uploading firmware via Atmel Studio)

Ok first of all this was a final project for my microprocessor course in my University, and its intended to clarify and guide to someone has a similar project or just want to do it and learn , since when i was doing this project it wasn’t so easy to find the information and examples to do it i think this could be helpful to someones out there.First i will explained how is the system going to work, this embedded system has three main components which satisfy three main functions or services, the first part is the communication part.
Car datta logger Using OBD II protocol

Step 1: Communication with the ECU (Engine Control Unit)

Since 1996 every car has a diagnostic system or On Board diagnostics (OBD) whic means that every car since then has an ECU and therefore has a communication protocol running on it, this is to communicate all the sensors that the car has.So our goal for this part is to be able to communicate or system whit the ECU of the car to obtained the desire information.When i did the research i found out that there are several embedded systems that can fulfill this requirement so first you need to know which protoclo is actually on your car as i was working on a Mazda 3 2005 the protocol was ISO 15765-4 (CAN 11bits/500kbps) , you can check the protocol by cheking the present pins on the OBD connector of your car.
So after this i decided to use a ELM327 cable which totally support this protocol
this cable provides communication from usb to the ECU this is actually a PIC microcontroller whit a lot of protocol transceivers for each supported protocol, you should download the datasheet in this link , there you can get detailed info about the ELM327 , the good thing is that as the ELM327 is a microcontroller it provides direct TTL or Uart communication this means that you can easily communicate your embedded system to the ELM327 through a Uart communication , the only problem was that the cable that i bought and probably the same cable you will find, it provides USB communication so i had to do a “hack” to bypass the usb interpreter and get only TTL communication .
The “hack” is to solder wire directly to the Rx and Tx pins of the PIC controller so i dolder the data cables of the usb cable directly to the Rx and Tx pins (worth to mention that once you do this you can not use it in the PC via usb).
So once this is done we have our communication hardware ready , so we can connect now the data cables of the usb directly to our atmega 2560 Tx and Rx pins.
I used an arduino MEGA but all the programming its done in C in atmel studio so is not arduino dependent i upload the program into the arduino using ICSP . So im not going to dig into details about the code , i just started a uart communication by wrtiting some registers and i used a 38400 baud rate which is the one present in this ELM327 .
Car datta logger Using OBD II protocol Schemeticr dattta
If you read the ELM327 datasheet you will find that we can send some PIDS (Parameters IDs) to it to obtained a desire parameter ad for example if we want to know the actual speed of the card we should send trough Uart communication the next PID ‘010D’ once we send this sequence to the ELM327 it will answer to us whit the actual speed of the car.
Here you can find all the PIDs avaliable keep in mind we will use mode 01.

For more detail: Car datta logger Using OBD II protocol (atmega 2560+ SD card + lcd 16×2)

Quick Solutions to Questions related to Car datta logger Using OBD II protocol (atmega 2560+ SD card + lcd 16x2):

  • What protocol did the project use to communicate with the car ECU?
    The project used ISO 15765-4 (CAN 11bits/500kbps) as present on the Mazda 3 2005.
  • Which interface module was used to talk to the ECU?
    An ELM327 OBD-II cable/module was used to provide communication between the ECU and the embedded system.
  • How was the ELM327 USB cable adapted for TTL UART communication?
    The USB cable was hacked by soldering wires directly to the PIC controller Rx and Tx pins to bypass the USB interpreter and obtain TTL Tx/Rx lines.
  • Can the hacked ELM327 still be used on a PC via USB?
    No, after soldering to the Rx and Tx pins and bypassing the USB interface it cannot be used via USB on a PC.
  • What microcontroller hosted the project firmware?
    An ATmega2560 (Arduino Mega board used) ran the firmware, programmed in C using Atmel Studio and uploaded via ICSP.
  • What UART settings were used to communicate with the ELM327?
    The UART communication used a baud rate of 38400 as specified for the ELM327.
  • How do you request the vehicle speed from the ECU?
    Send the PID sequence 010D over UART to the ELM327 to request the actual vehicle speed (mode 01 PIDs).
  • Which OBD mode was used for reading parameters?
    Mode 01 was used to read parameter IDs (PIDs).

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top