Page 1 of 1

OBD2 data for Mazda MX-5 NC Clubsport

Posted: Thu Apr 01, 2021 11:24 am
by Bjo3rn
Prologue:
About a year ago I started my journey of building something in between a perfect sport-roadster and a track tool for trackdays on club- and GP-racetracks in Germany. For a bigger project (which in this case is called Master Thesis :roll:) I need to get access to some data from the OBD2 port. That's why I've chosen the UART V2.1 adaptor for Arduino. As it turns out I struggled a little bit setting it up with an Arduino Mega 2560. That's why I'd like to share my thoughts and experience in this project so you as the reader of this blog-like thread don't need to do the same mistakes. I will keep you updated every time I got a little bit further with this project. Unfortunately, I will not tell you the exact purpose of this particular project for different reasons that I won't tell you either.

The hardware:
My car is a Mazda MX-5 NC 2.0 born in 2006. I've bought it in summer 2019 completely unmodified with round about 170k km. If you'd like to buy one for yourself: 170k is the time for the engine to get a high oil consumption. So, don't go for a car with more than 120k. An engine revision costs you round about 5k and is better performed with a compressor/turbo upgrade which I don't have by now... So, this car got an engine revision and the first modifications in summer 2020: 2x Recaro Pole Position, rollover bar, four-point safety belts, spring-damping system 'Performance' by SPS Motorsport, Rota Titan rims and 235mm Nangkang AR1 semi slicks - all performed by SPS Motorsport. I've built a provisionally brake cooling system that performed quite good at the Bilster Berg. Just a few weeks ago SPS upgraded the braking system to a big brake kit at the front and the RX-8 braking upgrade at the rear axle.

For accessing the OBD2 data, I've chosen an Arduino Mega, a 3.5" TFT LCD Shield and the Freematics OBD2 UART adaptor. Since I don't like the Arduino to run when I'm not using it, I also bought a simple ON-OFF switch that will be located in the 5V power supply from the OBD2 adaptor to the Arduino. For designing a case I will use my moderate modified Ender 3 printer (silent Board, OctoPrint via OctoPi and the Noctua cooling fan for the hotend cooling are the important ones) and probably this lovely GreenTEC Pro Carbon filament.

Chapter One - Setting it up:
The question of tonight was how to get any data from my OBD2 port. I'm not a great programmer and I don't have that much experience with Arduino boards. So, my first challenge was basically to make the example 'obd_uart_test' work as expected. First mistake was not to read the product page carefully. I plugged the TX cable to TX1 and RX cable to RX1. Guess what? It's not working. After reading the description I changed this and since I've read that I should plug it into D0/RX0 and D1/TX0 I also switched to these pins. That was my second mistake. In the serial port (take care of the baud rate which has to be 115200) just showed me the message "Freematics OBD-II Adapter not detected". After a while of no success, I got frustrated and decided to go back to my desk. There I tried just this one last thing: Switching back to TX1 and RX1 and well - that worked. With my frustration blown away I went back into my car and tested it. The connection was successfull and I got my first data.
Some things I've read in other threads that might be interesting for troubleshooting:
1. Check all 4 cables. Even if you don't like to connect the power cables, connect the ground pin. This seems to be important.
2. If your car is older than 2006 you might run into trouble with the protocol. Since my car doesn't use the concerning protocol, I didn't dig deeper into details. But there are some threads where this problem is addressed.
3. If you're using an Arduino Nano or Uno, you won't be able to get something useful out of the serial port to your computer. If I got this right, the data line is the same as the data line from the adaptor to the Arduino so they will interfere with each other. Please correct me if I'm wrong...

Short preview:
My next challenge is to get specific data from my car respectively the OBD2 adaptor. For my project I will need the brake pressure, throttle position, the accelerations and the angles of the 9DOF sensor as well as the vehicle speed.
Any questions or suggestions? Just comment down below so we can discuss them. :)

P.S.: If you've found any typos: Feel free to keep them :D