An open API service indexing awesome lists of open source software.

https://github.com/8dcc/esp32-cyd-obd2

Visualize OBD2 information about your car in an ESP32 CYD
https://github.com/8dcc/esp32-cyd-obd2

Last synced: about 2 months ago
JSON representation

Visualize OBD2 information about your car in an ESP32 CYD

Awesome Lists containing this project

README

          

#+title: ESP32 CYD OBD2
#+author: 8dcc
#+startup: showeverything

*Visualize OBD2 information about your car in an ESP32 CYD.*

This project is meant to run on an [[https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display][ESP32 Cheap Yellow Display]] (CYD) board, which
can be bought on AliExpress for about 10 dollars.

* Dependencies

This project has some external dependencies that must be installed in order for
it to be built and flashed. Namely, the Espressif [[https://idf.espressif.com/][ESP-IDF]] SDK has to be cloned
and installed.

#+begin_src bash
git clone --depth=1 https://github.com/espressif/esp-idf
cd esp-idf

./install.sh
# ...
#+end_src

Once the ESP-IDF installation is finished, it can be loaded into the shell.

#+begin_src bash
. ./export.sh
# ...

# (Espressif IDF now loaded in the current shell)
#+end_src

* Building and flashing

To build the project, simply clone the repository and build it using the =idf.py=
script. Make sure the =export.sh= script has been loaded/exported before this
step, as shown in the previous section.

#+begin_src bash
git clone https://github.com/8dcc/esp32-cyd-obd2
cd esp32-cyd-obd2
idf.py build
# ...
#+end_src

Then, once the project is built, you can connect the board's MicroUSB port to
your computer and flash it with the same =idf.py= script.

#+begin_src bash
idf.py flash
# ...
#+end_src

* Project architecture

The following diagram shows the architecture of the project.

#+begin_src mermaid
graph TD
main --> elm327
elm327 --> serial_bluetooth

main -.-> serial_uart

main --> obd2
obd2 --> elm327

main --> chart
chart -->|framebuffer| render
main -->|font| draw_text
draw_text -->|framebuffer| render
#+end_src

* Simulating a bluetooth ELM327 device

This repository ships with an ELM327 emulator script, which can be used to test
and develop the ESP32-CYD firmware without a real OBD2 adapter connected to a
car. This is intended for a Linux machine with BlueZ.

First, ensure that your computer has bluetooth enabled. Then, from =bluetoothctl=,
set the computer as discoverable and pairable.

#+begin_src
$ systemctl start bluetooth.service

$ bluetoothctl

[bluetoothctl]> discoverable on
Changing discoverable on succeeded

[bluetoothctl]> pairable on
Changing pairable on succeeded
#+end_src

Then, run the =elm327_mock.py= script.

#+begin_src
$ python3 scripts/elm327_mock.py
#+end_src

Recompile the ESP32 CYD firmware with the MAC address of your computer, which
can be obtained from:

#+begin_src
$ bluetoothctl show | grep "Controller"
Controller 11:22:33:44:55:66 (public)
#+end_src

Then, once the ESP32 tries to connect, accept the pairing request.

#+begin_src
Request authorization
[agent] Accept pairing (yes/no): yes
[CHG] Device 77:88:99:AA:BB:CC Paired: yes
[ESP32]>
#+end_src