├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE.md
├── README.md
├── SDCard
└── mypic.jpg
├── enclosure
├── Case.Esp32.zip
├── Va&CobGauge.3mf
├── Va&CobGauge.mtl
├── Va&CobGauge.skb
├── Va&CobGauge.skp
├── Va&CobGauge.stl
├── backcover.stl
├── enclosure.jpg
├── enclosure.zip
└── readme.md
├── hardware
├── 12-5v micro usb.jpg
├── Box.png
├── ELM327_bluetooth.png
├── ESP32 lvgl_touch.jpg
├── ESP32-2432S028-LCM001.jpeg
├── ESP32-2432S028-LCM002.jpeg
├── ESP32-WROOM-1 Pin definition.png
├── Parts list.txt
├── push_button.jpg
└── speaker.jpg
├── icon
├── about.jpg
├── arc.jpg
├── autooff.jpg
├── car-battery-t.png
├── cpu.jpg
├── engine.jpg
├── image.jpg
├── mypic.jpg
├── nofile.jpg
├── number.jpg
├── obd2gauge.jpg
├── overheat.jpg
├── pid list.xlsx
├── quit.jpg
├── sdcard.png
├── switchoff.jpg
├── switchon.jpg
├── vaandcob.jpg
├── vbar.jpg
├── warning.jpg
└── wifi.jpg
├── picture
├── config.jpg
├── cover.jpg
├── fullpart.jpg
├── gauge.jpg
└── page.jpg
└── sketch
├── VaAndCobOBD2Gauge
├── VaAndCobOBD2Gauge.ino
├── bluetooth.h
├── build
│ └── esp32.esp32.esp32
│ │ └── VaAndCobOBD2Gauge.ino.bootloader.bin
├── config.h
├── elm327.h
├── firmware
│ ├── README.md
│ ├── T5_manifest.json
│ ├── T6_manifest.json
│ ├── VaAndCobOBD2GaugeT5_nogenuine.bin
│ ├── VaAndCobOBD2Gauge_T6_nogenuine.bin
│ ├── boot_app0.bin
│ ├── bootloader.bin
│ ├── offset.png
│ └── partitions.bin
├── firmware_update.h
├── image.h
├── meter.h
├── music.h
├── nes_audio.cpp
├── nes_audio.h
└── touchscreen.h
├── arduinoSetup.png
├── gauge_factory_init
├── build
│ └── esp32.esp32.esp32
│ │ ├── gauge_factory_init.ino.bin
│ │ ├── gauge_factory_init.ino.bootloader.bin
│ │ ├── gauge_factory_init.ino.elf
│ │ ├── gauge_factory_init.ino.map
│ │ └── gauge_factory_init.ino.partitions.bin
└── gauge_factory_init.ino
└── library modified
└── TFT_eSPI
├── How to replace file.md
└── User_Setup.h
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | buy_me_a_coffee: vaandcob
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT No Commercial Use License
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
21 | Non-Commercial Use Restriction:
22 | The Software and any derivative works thereof must not be used, distributed,
23 | or otherwise exploited for commercial purposes or for any financial benefit.
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ESP32-Bluetooth-OBD2-Gauge
2 |
3 | ## This repository has been archived and is no longer maintained. (October 24th, 2025)
4 |
5 | A fully functional code-updated
6 | Last Update: September 27th, 2024
7 |
8 | This is an ESP32 OBD2 Gauge for vehicles that are compatible with OBD2
9 | (Special made for FORD vehicle)
10 | - Prototype https://youtu.be/PkQaUJbzTNM
11 | - Current Model Short Demo https://youtu.be/vvBIeim7XTE
12 |
13 | 
14 | 
15 | 
16 |
17 | ## Software:
18 | - Arduino IDE 2.3.2 + ESP32 arduino core 2.0.17
19 | - * IMPORTANT * this project won't work with ESP32 arduiino core 3.x.x
20 | - modified TFT_eSPI library 2.5.43
21 |
22 | ## Hardware
23 | - ESP32 TFT2.8 320x240 with "RESISTIVE" touch board.
24 | buy here https://s.click.aliexpress.com/e/_Ew95gMl
25 | - ELM327 Bluetooth adaptor (recommended v1.5 not v2.1)
26 | Highly recommend ELM327 Bluetooth adaptor https://s.click.aliexpress.com/e/_oo3THvG
27 | - A small speaker for mobile phone 1 Watt 8 ohm 9x28 mmm.
28 | - A push button 6x6x5 2 legs
29 | - 3d print enclosure
30 | - 12v to 5v dc micro usb power regulator module
31 | - Gauge magnetic stand
32 |
33 | ## Features:
34 | - Show vehicle data 7 pids
35 | * MAP - manifold air pressure (PSI)
36 | * PCM - pcm voltage (volt)
37 | * ENG LOAD - engine load (%)
38 | * ENG SPD - engine speed (RPM)
39 | * Coolant - coolant temperature (c)
40 | * Oil Temp - engine oil temperature (c)
41 | * TFT - Ford transmission fluid temperature (c)
42 |
43 | - 8 layout page selectable display
44 | - DTC read and clear function (Engine warning light only)
45 | - Warning when parameter reaches setting value
46 | - Adjustable warning value for each PIDs
47 | - Configurable CPU overheat protection
48 | - Configurable gauge Auto turn on/off
49 | - Auto screen brightness
50 | - Change off screen to user screen with micro SDcard
51 | - Firmware updatable (micro SDcard and WiFi)
52 | - VIN Read on the About page.
53 |
54 |
55 | ## [Flash Firmware Online](https://vaandcob.github.io/webpage/src/index.html)
56 |
57 | -------------------------------------------------------
58 | [](https://www.buymeacoffee.com/vaandcob)
59 |
60 |
61 |
--------------------------------------------------------------------------------
/SDCard/mypic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/SDCard/mypic.jpg
--------------------------------------------------------------------------------
/enclosure/Case.Esp32.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/enclosure/Case.Esp32.zip
--------------------------------------------------------------------------------
/enclosure/Va&CobGauge.3mf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/enclosure/Va&CobGauge.3mf
--------------------------------------------------------------------------------
/enclosure/Va&CobGauge.mtl:
--------------------------------------------------------------------------------
1 | #
2 | ## Alias OBJ Material File
3 | # Exported from SketchUp, (c) 2000-2012 Trimble Navigation Limited
4 |
5 | newmtl M_0134_DimGray
6 | Ka 0.000000 0.000000 0.000000
7 | Kd 0.411765 0.411765 0.411765
8 | Ks 0.330000 0.330000 0.330000
9 |
10 | newmtl FrontColor
11 | Ka 0.000000 0.000000 0.000000
12 | Kd 1.000000 1.000000 1.000000
13 | Ks 0.330000 0.330000 0.330000
14 |
15 |
--------------------------------------------------------------------------------
/enclosure/Va&CobGauge.skb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/enclosure/Va&CobGauge.skb
--------------------------------------------------------------------------------
/enclosure/Va&CobGauge.skp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/enclosure/Va&CobGauge.skp
--------------------------------------------------------------------------------
/enclosure/Va&CobGauge.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/enclosure/Va&CobGauge.stl
--------------------------------------------------------------------------------
/enclosure/enclosure.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/enclosure/enclosure.jpg
--------------------------------------------------------------------------------
/enclosure/enclosure.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/enclosure/enclosure.zip
--------------------------------------------------------------------------------
/enclosure/readme.md:
--------------------------------------------------------------------------------
1 | 3d print files
2 |
3 | 
4 |
--------------------------------------------------------------------------------
/hardware/12-5v micro usb.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/hardware/12-5v micro usb.jpg
--------------------------------------------------------------------------------
/hardware/Box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/hardware/Box.png
--------------------------------------------------------------------------------
/hardware/ELM327_bluetooth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/hardware/ELM327_bluetooth.png
--------------------------------------------------------------------------------
/hardware/ESP32 lvgl_touch.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/hardware/ESP32 lvgl_touch.jpg
--------------------------------------------------------------------------------
/hardware/ESP32-2432S028-LCM001.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/hardware/ESP32-2432S028-LCM001.jpeg
--------------------------------------------------------------------------------
/hardware/ESP32-2432S028-LCM002.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/hardware/ESP32-2432S028-LCM002.jpeg
--------------------------------------------------------------------------------
/hardware/ESP32-WROOM-1 Pin definition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/hardware/ESP32-WROOM-1 Pin definition.png
--------------------------------------------------------------------------------
/hardware/Parts list.txt:
--------------------------------------------------------------------------------
1 | ESP32 Arduino LVGL WIFI&Bluetooth Development Board 2.8" 240*320 Smart Display Screen 2.8inch LCD TFT Module With Touch WROOM
2 | https://s.click.aliexpress.com/e/_DB8Ht8N
3 |
4 | Micro USB Output 12V to 5V 3A
5 | https://shopee.co.th/%E2%98%80S%E2%98%80%E0%B8%AD%E0%B8%B8%E0%B8%9B%E0%B8%81%E0%B8%A3%E0%B8%93%E0%B9%8C%E0%B9%81%E0%B8%9B%E0%B8%A5%E0%B8%87%E0%B8%9E%E0%B8%B2%E0%B8%A7%E0%B9%80%E0%B8%A7%E0%B8%AD%E0%B8%A3%E0%B9%8C%E0%B8%8B%E0%B8%B1%E0%B8%9E%E0%B8%9E%E0%B8%A5%E0%B8%B2%E0%B8%A2-Micro-USB-Output-12V-to-5V-3A-%E0%B8%AA%E0%B9%8D%E0%B8%B2%E0%B8%AB%E0%B8%A3%E0%B8%B1%E0%B8%9A-PDA-DV-i.293684420.7945781904?sp_atk=8f247e46-d3d4-4ec1-abec-2bd83ef709de&xptdk=8f247e46-d3d4-4ec1-abec-2bd83ef709de
6 |
7 | ELM327 Bluetooth
8 | https://s.click.aliexpress.com/e/_oo3THvG
9 |
10 | Speaker 1W 8R 2809 8ohm
11 | https://shopee.co.th/(Takashitree)-%E0%B8%A5%E0%B9%8D%E0%B8%B2%E0%B9%82%E0%B8%9E%E0%B8%87%E0%B8%AE%E0%B8%AD%E0%B8%A3%E0%B9%8C%E0%B8%99%E0%B8%84%E0%B8%AD%E0%B8%A1%E0%B8%9E%E0%B8%B4%E0%B8%A7%E0%B9%80%E0%B8%95%E0%B8%AD%E0%B8%A3%E0%B9%8C-%E0%B9%82%E0%B8%99%E0%B9%89%E0%B8%95%E0%B8%9A%E0%B8%B8%E0%B9%8A%E0%B8%81-1W-8R-2809-8-%E0%B9%82%E0%B8%AD%E0%B8%AB%E0%B9%8C%E0%B8%A1-28*9-%E0%B8%A1%E0%B8%A1.-2-%E0%B8%8A%E0%B8%B4%E0%B9%89%E0%B8%99-i.131626048.22227074892
12 |
13 | Push button
14 | Push Bottom Switch 6x6x5 mm
--------------------------------------------------------------------------------
/hardware/push_button.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/hardware/push_button.jpg
--------------------------------------------------------------------------------
/hardware/speaker.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/hardware/speaker.jpg
--------------------------------------------------------------------------------
/icon/about.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/about.jpg
--------------------------------------------------------------------------------
/icon/arc.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/arc.jpg
--------------------------------------------------------------------------------
/icon/autooff.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/autooff.jpg
--------------------------------------------------------------------------------
/icon/car-battery-t.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/car-battery-t.png
--------------------------------------------------------------------------------
/icon/cpu.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/cpu.jpg
--------------------------------------------------------------------------------
/icon/engine.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/engine.jpg
--------------------------------------------------------------------------------
/icon/image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/image.jpg
--------------------------------------------------------------------------------
/icon/mypic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/mypic.jpg
--------------------------------------------------------------------------------
/icon/nofile.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/nofile.jpg
--------------------------------------------------------------------------------
/icon/number.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/number.jpg
--------------------------------------------------------------------------------
/icon/obd2gauge.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/obd2gauge.jpg
--------------------------------------------------------------------------------
/icon/overheat.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/overheat.jpg
--------------------------------------------------------------------------------
/icon/pid list.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/pid list.xlsx
--------------------------------------------------------------------------------
/icon/quit.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/quit.jpg
--------------------------------------------------------------------------------
/icon/sdcard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/sdcard.png
--------------------------------------------------------------------------------
/icon/switchoff.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/switchoff.jpg
--------------------------------------------------------------------------------
/icon/switchon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/switchon.jpg
--------------------------------------------------------------------------------
/icon/vaandcob.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/vaandcob.jpg
--------------------------------------------------------------------------------
/icon/vbar.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/vbar.jpg
--------------------------------------------------------------------------------
/icon/warning.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/warning.jpg
--------------------------------------------------------------------------------
/icon/wifi.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/icon/wifi.jpg
--------------------------------------------------------------------------------
/picture/config.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/picture/config.jpg
--------------------------------------------------------------------------------
/picture/cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/picture/cover.jpg
--------------------------------------------------------------------------------
/picture/fullpart.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/picture/fullpart.jpg
--------------------------------------------------------------------------------
/picture/gauge.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/picture/gauge.jpg
--------------------------------------------------------------------------------
/picture/page.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/picture/page.jpg
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/VaAndCobOBD2Gauge.ino:
--------------------------------------------------------------------------------
1 | /*========= Va&Cob OBD2 Gauge ==========
2 | Programmed: by Ratthanin W.
3 | Hardware:
4 | - Hardware 2.8" TFT ESP32 LVGL https://www.youtube.com/watch?v=d2OXlVcRYrU
5 | Configuration:
6 | - Partition scheme
7 | Minimal SPIFFS 1.9MB APP/ 190kB SPIFFS /OTA (for OTA ,must reduce code size)
8 |
9 | Important Note:
10 | - New device must flash "gauge_factory_init.ino" first to get it work by checking 'serialno' in pref.
11 | or you can skip genuine checking by comment out line no. 338
12 | - CPU temp read never work until Bluetooth or Wifi is connected
13 |
14 | About opening logo image and goodbye image.
15 | - you can save welcome page logo into gauge by saving file name "vaandcob.jpg" size 320x240 pixels into littleFS storage.
16 | - you can save goodbye page image into gauge by saving file name "mypic.jpg" size 320z240 pixels into littleFS storage
17 | * if you don't want to use it, you can comment out code line no. 320 - 322
18 | */
19 |
20 | //--- FLAG SETTING ----- for debugging
21 | //#define TERMINAL //temrinal mode (no gauge)
22 | //#define SERIAL_DEBUG //to show data in serial port
23 | //#define SKIP_CONNECTION //skip elm327 BT connection to view meter
24 | //#define TEST_DTC //test DTC
25 |
26 | //#define FORD_T5 // FOR FORD T5 uncomment this line
27 |
28 | //Intermal temperature sensor function declaration
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 | uint8_t temprature_sens_read();
33 | #ifdef __cplusplus
34 | }
35 | #endif
36 | uint8_t temprature_sens_read(); //declare intermal temperature sensor functio
37 |
38 | //Macro
39 | #define array_length(x) (sizeof(x) / sizeof(x[0])) //macro to calculate array length
40 |
41 | //library load
42 | #include //save permanent data
43 | Preferences pref; //create preference
44 | #include
45 | #include //Hardware-specific library
46 |
47 |
48 | //Pin configuration
49 | #define SCA_PIN 21 //not used same pin with TFT_BL
50 | #define SCL_PIN 22 //not used (avaialable) CAN_TX
51 | #define ADC_PIN 35 //not used (available) CAN_RX
52 | #define LED_RED_PIN 4
53 | #define LED_GREEN_PIN 16
54 | #define LED_BLUE_PIN 17
55 | #define LDR_PIN 34 //LDR sensor
56 | #define BUZZER_PIN 26 //speaker
57 | #define SELECTOR_PIN 27 //push button
58 | // setting PWM properties
59 | #define backlightChannel 0
60 | #define buzzerChannel 2
61 |
62 | //DISPLAY
63 | TFT_eSPI tft = TFT_eSPI();
64 | #define TFT_GREY 0x5AEB
65 |
66 |
67 | //ELM327 init https://www.elmelectronics.com/wp-content/uploads/2016/07/ELM327DS.pdf
68 | const uint8_t elm327InitCount = 8;
69 | const String elm327Init[elm327InitCount] = { "ATZ", "ATBRD23", "ATSP0", "ATAT2", "ATL0", "ATH0", "ATE0", "0100" }; //agressive wait response time from ECU
70 | //const String elm327Init[elm327InitCount] = {"ATZ","ATPP0CSV35","ATPP0CON","ATSP0","ATAT2","ATL0","ATH0","ATE0","0100"};//agressive wait response time from ECU
71 |
72 | /*------ PIDS total 7 now -------------------
73 | Array data -> { Label , unit, pid, fomula, min, max, ,skip, digit, warn }
74 | label = Pid label show on meter
75 | unit = unit for pid
76 | pid = string pid 0104
77 | formula = formula no to calculate
78 | min = lowest value
79 | max = highest value
80 | skip = delay reading 0 - 3; 3 = max delay read
81 | digit = want to show digit or not
82 | warn = default warning value
83 | */
84 | const String pidConfig[7][9] = {
85 | //[pid][data]
86 | { "ENG Load", "%", "0104", "2", "0", "100", "0", "0", "80" }, //0 = 0104
87 | { "ECT", "`C", "0105", "1", "0", "120", "3", "0", "99" }, //1 = 0105
88 | { "MAP", "psi", "010B", "0", "0", "40", "0", "1", "35" }, //2 = 010B
89 | { "ENG SPD", "rpm", "010C", "3", "0", "5000", "0", "0", "4000" }, //3 = 010C
90 | { "PCM Volt", "volt", "0142", "4", "0", "16", "1", "1", "15" }, //4 = 0142
91 | #ifdef FORD_T5
92 | { "IAT", "`C", "010F", "1", "0", "120", "3", "0", "99" }, //5 = 015C
93 | #else
94 | { "Oil Temp", "`C", "015C", "1", "0", "120", "3", "0", "99" }, //5 = 015C
95 | #endif
96 | #ifdef FORD_T5
97 | { "TFT", "`C", "221674", "6", "0", "120", "3", "0", "99" } //6 = 221674 for FORD T5
98 | #else
99 | { "Trans Temp", "`C", "221E1C", "5", "0", "120", "3", "1", "99" } //6 = 221E1C for FORD T6+
100 | #endif
101 |
102 | };
103 |
104 | //barometric pressure "0133" turbo boost = map - bp;
105 | //hold warning value
106 | String warningValue[7] = { "80", "99", "35", "4000", "15", "99", "99" };
107 |
108 | /* User configuration here to change display
109 | layout 0 layout 1 layout 2 layout 3 layout 4 layout 5
110 | █ 1 █ █ 7 █ █ 1 █ █ █ █ █ 4 █ █ █ █ █ 7 █ █ █ █ █ █ █ █ █
111 | █ 2 █ █ 8 █ █ 2 █ 3 4 1 █ 5 █ 4 1 2 █ 8 █ 1 2 3 4 1 2 3 4
112 | █ 3 █ █ 9 █ █ 3 █ █ █ █ █ 6 █ █ █ █ █ 9 █ █ █ █ █ █ █ █ █
113 |
114 | set up meter here which pid to use on each cell
115 | 0 - engine load
116 | 1 - coolant
117 | 2 - manifold Pressure
118 | 3 - engine Speed
119 | 4 - pcm volt
120 | 5 - oil Temp
121 | 6 - trans Temp
122 | */
123 | const uint8_t pidInCell[8][7] = {
124 | //[layout][cellNo]
125 | //the last cell must be 3 (engine speed) to check engine off
126 | { 0, 2, 3, 1, 5, 6, 4 }, //layout 0 -> 6 cell {load,map,engspd,coolant,oil,tft,pcmvolt
127 | { 0, 2, 3, 1, 5, 6, 4 }, //layout 1 -> 6 cell {load,map,engspd,coolant,oil,tft,pcmvolt
128 | { 0, 2, 3, 1, 5, 6, 4 }, //layout 2 -> 6 cell {load,map,engspd,coolant,oil,tft,pcmvolt
129 | { 1, 5, 6, 3, 2, 4, 4 }, //layout 3 -> 5 cell {cooland,oil,tft,map,pcmvolt,pcmvolt}
130 | { 2, 1, 5, 6, 4, 0, 4 }, //layout 4 -> 5 cell {MAP,coolant,oiltemp,tft,pcmvolt,load,pcmvolt}
131 | { 2, 0, 1, 5, 6, 4, 4 }, //layout 5 -> 5 cell {MAP,engload,coolant,oiltemp,tft,engload,rpm}
132 | { 1, 5, 6, 4, 0, 3, 4 }, //layout 6 -> 4 cell {coolant,oiltemp,tft,pcmvolt,map,endspd,pcmvolt}
133 | { 3, 2, 0, 4, 1, 5, 4 }, //layout 7 -> 4 cell {engspd,map,engload,pcmvolt,coolant,oil,pcmvolt}
134 | };
135 | // User configuration here to change display >
136 |
137 | /*---------------------------*/
138 | //if NO DATA value will set to 0 to skip reading
139 | uint8_t layout = 0; //pidInCelltype 0-4 EEPROM 0x00
140 | const uint8_t max_layout = array_length(pidInCell); //total 5 type of display page
141 | uint8_t pidIndex = 0; //point to PID List
142 | const uint8_t maxpidIndex = array_length(pidConfig); //total 7 pids in picConfig
143 | bool prompt = false; //bt elm ready flag
144 | bool skip = false; //pid skip flag
145 | uint8_t A = 0; //get A
146 | uint8_t B = 0; //get B
147 |
148 | //Global variable
149 | const uint32_t SLEEP_DURATION = 180 * 1000000; //180 sec* us = 3 min
150 | String line[12] = { "", "", "", "", "", "", "", "", "", "", "", "" }; //buffer for each line in terminal function
151 | bool dim = false; //back light dim flag
152 | const uint8_t LIGHT_LEVEL = 40; //backlight control by light level Higher = darker light
153 | long runtime = 0; //to check FPS
154 | long holdtime = 0; //hold time for button pressed check
155 | const String compile_date = __DATE__ " - " __TIME__; //get built date and time
156 | bool press = false; // button press flag
157 | bool showsystem = false; //show fps and temp EEPROM 0x01
158 | uint8_t pidRead = 0; //counter that hold number of pids been read to check pid/sec
159 | String serial_no = ""; //keep serial no.
160 |
161 | //CPU Temp
162 | const uint8_t tempOverheat = 60; //max operating cpu temp 60c
163 | const int8_t factoryTempOffset = -50; //default offset adjustment temp up to each tested esp32 max at -50
164 | float tempRead = 0.0; //current reading cpu temp
165 | int8_t tempOffset = 0; //offset adjustment temp up to each tested esp32
166 | uint8_t temp_read_delay = 0; //hold delay counter to read temp
167 | uint8_t temp_overheat_count = 0; //counter to read continuiosly overheat
168 |
169 | //BLUETOOTH
170 | String bt_message = ""; //bluetooth message buffer
171 | String se_message = ""; //serial port message buffer
172 | String deviceName[8] = { "", "", "", "", "", "", "", "" }; //discoveryBT name
173 | String deviceAddr[8] = { "", "", "", "", "", "", "", "" }; //discover BT addr
174 | uint8_t btDeviceCount = 0; //discovered bluetooth devices counter
175 | #define BT_DISCOVER_TIME 5000 //bluetooth discoery time
176 | esp_bd_addr_t client_addr = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; //obdII mac addr
177 | esp_bd_addr_t recent_client_addr = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; //keep last btaddr in RTC memory
178 | const String client_name = "OBDII"; //adaptor name to search
179 | esp_spp_sec_t sec_mask = ESP_SPP_SEC_NONE; // or ESP_SPP_SEC_ENCRYPT|ESP_SPP_SEC_AUTHENTICATE to request pincode confirmation
180 | esp_spp_role_t role = ESP_SPP_ROLE_SLAVE; // or ESP_SPP_ROLE_MASTER
181 | bool foundOBD2 = false;
182 | BluetoothSerial BTSerial; //bluetooth serial device
183 |
184 | //---- Include Header File ---
185 | #include "image.h"
186 | #include "touchscreen.h"
187 |
188 | /*----------- global function ---------*/
189 |
190 | //------------------------------------------------------------------------------------------
191 | void checkCPUTemp() { //temperature can read only when BT or Wifi Connected
192 | temp_read_delay++;
193 | if ((temp_read_delay >= 50) && (foundOBD2)) { //delay loop 50 then read temp, avoid error eading
194 | temp_read_delay = 0;
195 | uint8_t temperature = temprature_sens_read(); //read internal temp sensor
196 | tempRead = (temperature - 32) / 1.8 + tempOffset; //change unit F to C
197 | #ifdef SERIAL_DEBUG
198 | Serial.print(tempRead, 1); //print Celsius temperature and tab
199 | Serial.println("°c");
200 | #endif
201 | //read 10 times to confirm it's really overtemp.
202 | if (tempRead >= tempOverheat) temp_overheat_count++; //count overheat time
203 | else temp_overheat_count = 0; //reset
204 | if (temp_overheat_count > 10) { //overheat read more than 10 times.
205 | Serial.printf("CPU Overheat Shutdown at %d°C\n", tempOverheat);
206 | tft.fillRectVGradient(0, 0, 320, 240, TFT_RED, TFT_BLACK);
207 | tft.pushImage(127, 5, 64, 64, overheat, TFT_RED); //show sdcard icon
208 | tft.setTextColor(TFT_WHITE);
209 | tft.drawCentreString("CPU Overheat Shutdown!", 159, 75, 4);
210 | tft.setTextColor(TFT_WHITE, TFT_BLUE);
211 | tft.drawCentreString("Auto-restart within 3 minutes", 159, 140, 4);
212 | tft.drawCentreString("OR", 159, 170, 4);
213 | tft.drawCentreString("Press button to restart", 159, 200, 4);
214 | ledcWriteTone(buzzerChannel, 1500);
215 | delay(5000);
216 | ledcWriteTone(buzzerChannel, 0);
217 | BTSerial.disconnect(); //disconnect bluetooth
218 | tft.fillScreen(TFT_BLACK);
219 | tft.writecommand(0x10); //TFT sleep
220 | //enter deep sleep
221 | esp_sleep_enable_timer_wakeup(SLEEP_DURATION); //sleep timer 3 min
222 | esp_sleep_enable_ext0_wakeup(GPIO_NUM_27, LOW); //wake when button pressed
223 | esp_deep_sleep_start(); //sleep shutdown backlight auto off with esp32
224 | } //if temp_overheat_coun
225 | } //if temp_read_delay
226 | } //check CPU Temp
227 | /*------------------*/
228 | //TERMINAL terminal for debugging display text
229 | void Terminal(String texts, uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
230 | uint8_t max_line = round((h - y) / 16.0);
231 | tft.fillRect(x, y, x + w, y + h, TFT_BLACK);
232 | tft.setTextColor(TFT_WHITE);
233 | for (uint8_t i = 0; i < max_line; i++) {
234 | if (i <= max_line - 2) {
235 | line[i] = line[i + 1];
236 | } else {
237 | line[i] = texts;
238 | }
239 | tft.drawString(line[i], x, i * 20 + y, 2);
240 | } //for
241 | bt_message = ""; //reset bt message
242 | }
243 | /*------------------*/
244 |
245 | void checkGenuine() { //check if genuine obd2 gauge - must flash "gauge_factory_init.ino" first
246 | //security {serialno: "V&C-OBDII-001"}
247 | pref.begin("security", true); //read only
248 | serial_no = pref.getString("serialno", ""); //if no serial no, then empty
249 | Serial.print(F("Serial No: "));
250 | if (serial_no == "") {
251 | tft.setTextColor(TFT_WHITE, TFT_RED);
252 | tft.drawString("Not genuine Va&Cob Gauge!", 0, 115, 4);
253 | Serial.println(F("Not genuine Va&Cob Gauge!"));
254 | while (true) { //beep
255 | ledcWriteTone(buzzerChannel, 2000);
256 | digitalWrite(LED_RED_PIN, LOW); //red on
257 | delay(500);
258 | ledcWriteTone(buzzerChannel, 0);
259 | digitalWrite(LED_RED_PIN, HIGH); //red off
260 | delay(500);
261 | }
262 | } else {
263 | Serial.println(serial_no); //print serial no
264 | pref.end();
265 | }
266 | }
267 | //----------------------------------------------
268 |
269 | //---- Include Header File --------------------
270 | //#include "image.h"
271 | #include "bluetooth.h"
272 | #include "meter.h"
273 | #include "config.h"
274 |
275 | //----SET UP -----------------------------------
276 | void setup() {
277 | //pin configuration
278 | analogSetAttenuation(ADC_0db); // 0dB(1.0 ครั้ง) 0~800mV for LDR
279 | pinMode(LDR_PIN, ANALOG); //ldr analog input read brightness
280 | pinMode(BUZZER_PIN, OUTPUT); //speaker
281 | pinMode(SELECTOR_PIN, INPUT_PULLUP); //button
282 | pinMode(LED_RED_PIN, OUTPUT); //red
283 | pinMode(LED_GREEN_PIN, OUTPUT); //green
284 | pinMode(LED_BLUE_PIN, OUTPUT); //blue
285 | digitalWrite(LED_RED_PIN, LOW); //on
286 | digitalWrite(LED_GREEN_PIN, HIGH); //off
287 | digitalWrite(LED_BLUE_PIN, HIGH); //off
288 | //pwm setup
289 | ledcSetup(buzzerChannel, 1500, 10); //buzzer 10 bit
290 | ledcSetup(backlightChannel, 12000, 8); //backlight 8 bit
291 | ledcAttachPin(BUZZER_PIN, buzzerChannel); //attach buzzer
292 |
293 | //init communication
294 | Serial.begin(115200);
295 | //memory check
296 | psramInit();
297 | Serial.println(F("\n---------------------------------------\n"));
298 | Serial.printf("Free Internal Heap %d/%d\n", ESP.getFreeHeap(), ESP.getHeapSize());
299 | Serial.printf("Free SPIRam Heap %d/%d\n", ESP.getFreePsram(), ESP.getPsramSize());
300 | Serial.printf("ChipRevision %d, Cpu Freq %d, SDK Version %s\n", ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
301 | Serial.printf("Flash Size %d, Flash Speed %d\n", ESP.getFlashChipSize(), ESP.getFlashChipSpeed());
302 | Serial.println(F("\n---------------------------------------\n"));
303 | Serial.println(F("<< Va&Cob OBDII Gauge >>"));
304 | Serial.print(F("by Ratthanin W. BUILD -> "));
305 | Serial.println(compile_date);
306 |
307 |
308 |
309 | //init TFT display
310 | tft.init();
311 | tft.setRotation(1); //landcape
312 | // Start the SPI for the touchscreen and init the touchscreen
313 | touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
314 | ts.begin(touchscreenSPI);
315 | ts.setRotation(1);
316 |
317 | touch_calibrate(); //hold button at start to calibrate touch
318 | //testTouch();//test touchscreen
319 |
320 | tft.setSwapBytes(true); //to display correct image color
321 | show_spiffs_jpeg_image("/vaandcob.jpg", 0, 0);// display logo image
322 | delay(3000);
323 |
324 | //backlight ledcAttachPin must be set after tft.init()
325 | ledcAttachPin(TFT_BL, backlightChannel); //attach backlight
326 | for (uint8_t i = 255; i > 0; i--) { //fading effect
327 | ledcWrite(backlightChannel, i); //full bright
328 | delay(5);
329 | }
330 | digitalWrite(LED_RED_PIN, HIGH); //red off
331 | tft.fillScreen(TFT_BLACK); //show start page
332 | tft.fillRectVGradient(0, 0, 320, 26, TFT_YELLOW, 0x8400);
333 | tft.setTextColor(TFT_BLACK);
334 | tft.pushImage(0, 0, 320, 25, obd2gauge); //show logo
335 | ledcWrite(backlightChannel, 255); //full bright
336 | tft.setTextColor(TFT_WHITE, TFT_RED);
337 | tft.drawRightString(" Config button ->", 319, 26, 2);
338 | String txt = " BUILD : " + compile_date;
339 | tft.setTextColor(TFT_WHITE, TFT_BLUE);
340 | tft.drawString(txt, 0, 26, 2);
341 |
342 | // checkGenuine();//check guniune
343 | //init variable
344 | pref.begin("setting", false);
345 | /* Create a namespace called "setting" with read/write mode
346 | { pref.get...(key,default)
347 | layout : UShort
348 | showsystem: bool
349 | tempOffset : uint16_t
350 | warning value: uint16_t
351 | recent_client_addr : {0x00,0x00,0x00,0x00,0x00,0x00} array of bytes[6]
352 | }*/
353 | layout = pref.getUShort("layout", 0); //load layout setting from NVR
354 | if (layout > max_layout) layout = 0;
355 | showsystem = pref.getBool("showsystem", false); //load showsytem
356 | tempOffset = pref.getInt("tempOffset", factoryTempOffset); //load defaultTempoffset
357 | #ifdef SERIAL_DEBUG
358 | Serial.printf("Show System: %d\n", showsystem);
359 | Serial.printf("Temp Offset: %d\n", tempOffset);
360 | #endif
361 | for (uint8_t i = 0; i < maxpidIndex; i++) { //read warning value from pid name if not found load from default
362 | warningValue[i] = pref.getString(pidConfig[i][0].c_str(), pidConfig[i][8]);
363 | }
364 | pref.getBytes("recent_client", recent_client_addr, pref.getBytesLength("recent_client")); //read last bt address
365 | ecu_off_volt = pref.getFloat("ecu_off_volt", factoryECUOff); //read ecu 0ff voltage
366 |
367 |
368 | //start bluetooth
369 | if (!BTSerial.begin("Va&Cob OBDII Gauge", true)) {
370 | Serial.println(F("Bluetooth..error!"));
371 | Terminal("Bluetooth..error!", 0, 48, 320, 191);
372 | abort();
373 | } else {
374 | Serial.println(F("Bluetooth..OK"));
375 | Terminal("Bluetooth..OK", 0, 48, 320, 191);
376 | }
377 | runtime = millis();
378 | #ifdef SKIP_CONNECTION
379 | foundOBD2 = true;
380 | #endif
381 |
382 | //Connect to ELM327
383 | connectLastOBDII(); //try connect last BT
384 | while (!foundOBD2) { //not success try scan and connect another OBD2
385 | scanBTdevice();
386 | autoDim(); //auto backlight handle
387 | //checkCPUTemp(); //check temp never work if BT or WIFI not connected
388 | if (digitalRead(SELECTOR_PIN) == LOW) { //button pressed
389 | if (!press) {
390 | press = true; //set flag
391 | holdtime = millis(); //set timer
392 | } else if (holdtime - millis() > 500) { //press once and longer
393 | configMenu(); //open config menu
394 | press = false; //reset flag
395 | } //else if holdtimer > 30000
396 | delay(200); //delay avoid bounce
397 | }
398 | }
399 |
400 | //Initialize ELM327
401 | Terminal("Initializing...", 0, 48, 320, 191);
402 | bt_message = "";
403 | for (uint8_t initIndex = 0; initIndex < elm327InitCount; initIndex++) { //send init ELM327 AT command
404 | BTSerial.print(elm327Init[initIndex] + "\r");
405 | if (initIndex == elm327InitCount - 1) delay(2000); //wait for 0100 Searching..protocal
406 | else delay(100); //must add delay , unless will skip BTSerial.avaialble>0
407 | while (BTSerial.available() > 0) {
408 | char incomingChar = BTSerial.read();
409 | if (incomingChar == '>') { //check prompt
410 | BTSerial.flush(); //clear buffer
411 | #ifdef SERIAL_DEBUG
412 | Serial.println(bt_message);
413 | #endif
414 | #ifdef TERMINAL
415 | Terminal(bt_message, 0, 48, 320, 191);
416 | #endif
417 | if (initIndex == 1) BTSerial.print("\r"); //ATBRD23 response
418 | bt_message = "";
419 | } else {
420 | bt_message.concat(incomingChar); //keep elm327 respond
421 | }
422 | } //while
423 | } //for
424 |
425 | initScreen();
426 | beepbeep();
427 | prompt = true;
428 | //----------------------
429 | } //setup
430 |
431 | /*###################################*/
432 | void loop() {
433 | //SCAN BUTON (button press HOLD to config menu)
434 | if (digitalRead(SELECTOR_PIN) == LOW) { //button pressed
435 | if (!press) {
436 | press = true; //set flag
437 | holdtime = millis(); //set timer
438 | } else if (holdtime - millis() > 3000) { //press once and longer than 3 sec
439 | configMenu(); //open config menu
440 | press = false; //reset flag
441 | if (foundOBD2) initScreen(); //open new layout screen
442 | } //else if holdtimer > 30000
443 | delay(200); //delay avoid bounce
444 | } else { //button release
445 | if (press) { //change layout next page
446 | layout++; //change to next layout page
447 | if (layout == max_layout) layout = 0;
448 | ledcWriteTone(buzzerChannel, 5000); //play click sound
449 | delay(5);
450 | ledcWriteTone(buzzerChannel, 0);
451 | initScreen(); //open meter screen
452 | //reset variable
453 | for (uint8_t i = 0; i < maxpidIndex - 1; i++) old_data[i] = 0.0;
454 | engine_off_count = 0;
455 | BTSerial.flush(); //clear tx
456 | while (BTSerial.available() > 0) { //clear rx buffer
457 | BTSerial.read();
458 | }
459 | bt_message = "";
460 | skip = false;
461 | pidIndex = maxpidIndex - 1; //will be +1 to be 0
462 | press = false; //reset flag
463 | prompt = true; //to trig reading elm again
464 | delay(200); //delay avoid bounce
465 |
466 | } //if press
467 |
468 | } //else digitalRead
469 | //----------------------
470 | //BLUETOOTH read
471 | while (BTSerial.available() > 0) {
472 | char incomingChar = BTSerial.read();
473 | if (incomingChar == '>') { //check prompt
474 | BTSerial.flush(); //clear tx
475 | #ifdef SERIAL_DEBUG
476 | Serial.println(bt_message);
477 | #endif
478 | #ifdef TERMINAL //for degbugging
479 | getAB(bt_message);
480 | Terminal(bt_message + "->" + String(A) + "," + String(B), 0, 48, 320, 191);
481 | #endif
482 | prompt = true; //pid response ready to calculate & display
483 | } else {
484 | bt_message.concat(incomingChar); //keep elm327 respond
485 | }
486 | }
487 | //----------------------
488 | //SERIAL PORT read
489 | if (Serial.available() > 0) {
490 | char incomingChar = Serial.read();
491 | //check CR/NL
492 | if ((incomingChar != '\r') && (incomingChar != '\n')) {
493 | se_message.concat(incomingChar);
494 | //Serial.print(incomingChar,HEX);
495 | } else {
496 |
497 | if (se_message != "") {
498 | #ifdef TERMINAL
499 | Terminal(se_message, 0, 48, 320, 191); //display terminal
500 | #endif
501 | BTSerial.print(se_message + "\r");
502 | se_message = "";
503 | Serial.flush();
504 | } //if se_message
505 |
506 | } //else if incomingChar
507 | } //if Serial.available
508 |
509 | //Send another PID to elm327
510 | if (prompt) { //> ELM327 ready! -> request next PID
511 | prompt = false; //no prompt from ELM327
512 | checkCPUTemp(); //check temperature.
513 | if (!skip) {
514 | updateMeter(pidIndex, bt_message); //update meter screen
515 | pidRead++; //for calculate pid/s
516 | }
517 | pidIndex++; //point to next pid
518 | if (pidIndex >= maxpidIndex) {
519 | pidIndex = 0; //back to pid 0
520 | autoDim(); //auto backlight handle
521 | if (showsystem) {
522 | String status = String(pidRead * 1000.0 / (millis() - runtime), 0) + " p/s " + String(tempRead, 1) + "`c";
523 | tft.setTextColor(TFT_YELLOW, TFT_BLACK);
524 | tft.drawCentreString(status.c_str(), 159, 0, 2);
525 | runtime = millis();
526 | } //if showsystem
527 | pidRead = 0; //reset pid read counter
528 | }
529 | if (pidCurrentSkip[pidIndex] <= 0) { //end of skip loop , go next index
530 | pidCurrentSkip[pidIndex] = pidReadSkip[pidIndex]; //read max delay loop to current
531 | skip = false;
532 | BTSerial.print(pidList[pidIndex] + "\r"); //send PID request
533 | } else { //skip sending request
534 | pidCurrentSkip[pidIndex] = pidCurrentSkip[pidIndex] - 1; //decrese loop count
535 | prompt = true;
536 | skip = true;
537 | } //else
538 |
539 | } //if prompt
540 |
541 | /*------------------*/
542 | } // loop
543 |
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/bluetooth.h:
--------------------------------------------------------------------------------
1 | /* Bluetooth function */
2 | //----------------------------------
3 | //convert bt address to text
4 | //{0x00,0x1d,0xa5,0x00,0x12,0x92} -> 00:1d:a5:00:12:92
5 | String ByteArraytoString(esp_bd_addr_t bt_address) {
6 | String txt = "";
7 | String nib = "";
8 | for (uint8_t i=0;i(pDevice);
29 | // btDeviceList[pDevice->getAddress()] = * set;
30 | String txt = pDevice->toString().c_str();
31 | Serial.printf("Found a new device: %s\n", pDevice->toString().c_str());
32 | deviceName[btDeviceCount] = pDevice->getName().c_str();
33 | deviceAddr[btDeviceCount] = pDevice->getAddress().toString().c_str();
34 | btDeviceCount++;
35 | } )
36 | ) {
37 | delay(BT_DISCOVER_TIME);
38 | BTSerial.discoverAsyncStop();
39 | #ifdef SERIAL_DEBUG
40 | Serial.println("Discovering stopped");
41 | #endif
42 | digitalWrite(LED_BLUE_PIN,HIGH);//blue led off
43 | delay(1000);//redsicovery delay
44 |
45 | } else {
46 | #ifdef SERIAL_DEBUG
47 | Serial.println("Error on discovering bluetooth clients.");
48 | #endif
49 | }
50 |
51 | String txt = "Found "+String(btDeviceCount)+" device(s)";
52 | Terminal(txt,0,48,320,191);
53 |
54 | //matching scan obd2 and config obd2
55 | for (uint8_t i=0;i {0x00,0x1d,0xa5,0x00,0x12,0x92};
64 | //copy match bt mac address to client_name to connect
65 | String str = deviceAddr[i];
66 | uint8_t StringCount = 0;
67 | while (str.length() > 0) {
68 | int8_t index = str.indexOf(':');
69 | if (index == -1) {// No : found
70 | client_addr[StringCount] = strtol(str.c_str(), 0, 16);//convert hex string to byte
71 | str = "";//set length to 0;
72 | //exit loop while
73 | } else {
74 | client_addr[StringCount] = strtol(str.substring(0, index).c_str(),0,16);//convert hex string to byte
75 | StringCount++;
76 | str = str.substring(index+1);
77 | }
78 | }//while mac address copied to client_addr for connect below code
79 | if (ByteArraytoString(client_addr) != ByteArraytoString(recent_client_addr)) {
80 | pref.putBytes("recent_client",client_addr,sizeof(client_addr));//save new bt addr to pref.
81 | Serial.println(F("Save a new BT client address"));
82 | }
83 | } else //not match
84 | foundOBD2 = false;
85 |
86 | }//for loop list device
87 |
88 |
89 | //connect to obd2
90 | if (foundOBD2) {
91 | txt = "Connecting to " + client_name +" - " + ByteArraytoString(client_addr);
92 | Terminal(txt,0,48,320,191);
93 | Serial.println(txt);
94 | BTSerial.connect(client_addr, 0, sec_mask, role);//connect to OBDII adaptor
95 | bool blink = false;
96 | while(!BTSerial.connected(1000)) {
97 | Serial.print(F("."));
98 | blink =! blink;
99 | digitalWrite(LED_BLUE_PIN,blink);//blue led offset
100 | if (blink) tft.setTextColor(TFT_BLUE,TFT_BLACK);
101 | else tft.setTextColor(TFT_BLACK,TFT_BLACK);
102 | tft.drawRightString("$",319,210,4);
103 | }
104 |
105 | Terminal("Connected Successfully!",0,48,320,191);
106 | Serial.println(F("Connected Successfully!"));
107 | prompt = true;
108 | digitalWrite(LED_GREEN_PIN, LOW);//green led
109 |
110 | } else {
111 | Terminal("OBDII Adaptor not found!",0,48,320,191);
112 | Serial.println(F("OBDII Adaptor not found!"));
113 | } //foundOBD2
114 | }//scanBTDevice
115 |
116 | //---------------------------
117 | //connect to recent obdII for fast connection, skip scanning
118 | void connectLastOBDII() {
119 | digitalWrite(LED_BLUE_PIN,LOW);//blue led on
120 | String txt = "Connecting to " + client_name +" - " + ByteArraytoString(recent_client_addr);
121 | Terminal(txt,0,48,320,191);
122 | Serial.println(txt);
123 | BTSerial.connect(recent_client_addr, 0, sec_mask, role);//connect to OBDII adaptor
124 | uint8_t try_count = 0;
125 | bool blink = false;
126 | while(!BTSerial.connected(1000) && (try_count <3)) {
127 | Serial.print(F("."));
128 | blink =! blink;
129 | digitalWrite(LED_BLUE_PIN,blink);//blue led offset
130 | try_count++;
131 | }
132 | if (try_count == 3) {//cannot connect
133 | Terminal("OBDII Adaptor not found!",0,48,320,191);
134 | Serial.println(F("OBDII Adaptor not found!"));
135 | BTSerial.disconnect();
136 | foundOBD2 = false;
137 | } else {
138 | Terminal("Connected Successfully!",0,48,320,191);
139 | Serial.println(F("Connected Successfully!"));
140 | prompt = true;
141 | digitalWrite(LED_GREEN_PIN, LOW);//green led
142 | foundOBD2 = true;
143 | }
144 |
145 | }//connectLasbtOBDII
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/build/esp32.esp32.esp32/VaAndCobOBD2Gauge.ino.bootloader.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/sketch/VaAndCobOBD2Gauge/build/esp32.esp32.esp32/VaAndCobOBD2Gauge.ino.bootloader.bin
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/config.h:
--------------------------------------------------------------------------------
1 | /* "config.h"
2 | this header file is for configuration menu
3 | */
4 | //freeRTOS multi tasking
5 | #include
6 | #include
7 | #include
8 |
9 | #include "music.h" //songs data
10 | #include "nes_audio.h" //nes audio player
11 | #include "firmware_update.h" //firmware updater function
12 | #include "elm327.h"// read VIN function
13 |
14 | #define mypic_filename "/mypic.jpg"//mypic file
15 | #define FORMAT_SPIFFS_IF_FAILED true//format if no spiffs
16 |
17 |
18 | Cartridge player(BUZZER_PIN);//not specified 4 pin , use 1 pin at buzzer pin
19 |
20 | //configuration menu
21 | const String menuList[8] = {
22 | "Show pid/s & CPU Temp",//toggle show system
23 | "Load my pic 320x240 px",//load user own pic
24 | "Update firmware",//update new firmware
25 | "Warning setting",//setting warning parameter (warning data, offset temp)
26 | "DTCs",//dtc engine
27 | "Auto-off",//auto turn off
28 | "About",//about
29 | "Exit"
30 | };
31 | const uint8_t maxMenu = array_length(menuList);//length of menu list
32 |
33 | //menu list for warning setting
34 | const String parameterList[8][2] = {
35 | {"CPU Overheat Temperature "+String(tempOverheat)+"`c ,offset "," `c "},
36 | {"- Engine Load"," % "},
37 | {"- Coolant Temperature"," `c "},
38 | {"- Manifold Air Pressure"," psi "},
39 | {"- Engine Speed"," rpm "},
40 | {"- PCM Voltage"," volt"},
41 | {"- Engine Oil Temperature"," `c "},
42 | {"- Transmission Fluid Temperature"," `c "}
43 | };
44 |
45 | //increasement and decreasement of each PID
46 | const int pidWarnStep[8] = {1,5,1,5,500,1,1,1};
47 |
48 | //Sprites
49 | TFT_eSprite car = TFT_eSprite(&tft);
50 | TFT_eSprite bk = TFT_eSprite(&tft);
51 | TFT_eSprite pole = TFT_eSprite(&tft);
52 | TFT_eSprite fence = TFT_eSprite(&tft);
53 |
54 | //------ NES Audio play on Task0
55 | TaskHandle_t TaskHandle0 = NULL;//create taskhandle0
56 |
57 | void TaskPlayMusic(void *pvParameters) {
58 | esp_task_wdt_init(62, false);//62 sec wd timer / disable wd
59 | while(1) {
60 | // player.frame_counter_cb(danceLight);//cal back fucntion (not use)
61 | player.play_nes(song , true, 0.25); //play nes music, loop, volume 0.25,
62 |
63 | }
64 | }
65 | //----------------------------
66 | void animation() {//start field effect
67 | //sprite variable
68 | #define BK_HEIGHT 80
69 | #define BK_WIDTH 235
70 | uint8_t cur_x = 68;
71 | uint8_t cur_y = 10;
72 | uint8_t dash_x = 20;
73 | int16_t tag_x = 235;
74 | int16_t fence_x = 0;
75 | uint8_t ani_speed = 2;
76 |
77 | //create spirtes
78 | bk.createSprite(BK_WIDTH,BK_HEIGHT);
79 |
80 | car.createSprite(CAR_WIDTH,CAR_HEIGHT);//image size 114x50
81 | car.setSwapBytes(true);
82 | car.pushImage(0,0,CAR_WIDTH,CAR_HEIGHT,futurecar);//image size 114x50
83 |
84 | pole.createSprite(POLE_WIDTH,POLE_HEIGHT);
85 | pole.setSwapBytes(true);
86 | pole.pushImage(0,0,POLE_WIDTH,POLE_HEIGHT,pole1);
87 |
88 | fence.createSprite(FENCE_WIDTH,FENCE_HEIGHT);
89 | fence.setSwapBytes(true);
90 | fence.pushImage(0,0,FENCE_WIDTH,FENCE_HEIGHT,fence1);
91 | //-------------------------------
92 | tft.fillScreen(TFT_BLACK);//clear screen
93 | //draw QRCode
94 | tft.drawBitmap(0, 159, qrcode, QRCODE_WIDTH, QRCODE_HEIGHT, TFT_WHITE);
95 | //draw text
96 | tft.setTextColor(TFT_WHITE);
97 | tft.drawString(">MAP/ENG LOAD/ECT/EOT/TFT/ENG SPD/PCM Volt",0,40,2);
98 | tft.drawString(">Warning, Automatic Dim/OnOff/O็verheat Shutdown",0,60,2);
99 | tft.drawString(">Read DTC Code & Clear MIL Status",0,80,2);
100 | tft.drawString("* FW-\"VaandCobOBD2Gauge.bin\" * Image-\"mypic.jpg\"",0,100,2);
101 | tft.drawString("* Facebook : www.facebook.com/vaandcob",0,120,2);
102 | tft.setTextColor(TFT_YELLOW);
103 | tft.drawString(" [ Manual ] ----------------[ Press button to exit ]",0,140,2);
104 | tft.setTextColor(TFT_CYAN);
105 | String txt = "[ "+serial_no+" ] BUILD : "+compile_date;
106 | tft.drawString(txt,0,0,2);
107 | //get VIN
108 | getPID("ATE0");//force echo off
109 | txt = "VIN : " + getVIN(getPID("0902"));
110 | tft.setTextColor(TFT_GREENYELLOW);
111 | tft.drawString(txt,0,20,2);
112 |
113 | bk.setTextColor(TFT_BLACK,TFT_ORANGE);
114 | //loop draw Animation
115 | while (digitalRead(SELECTOR_PIN) == HIGH) {//exit if press button
116 |
117 | //draw road
118 | bk.fillSprite(0x4228);//draw road
119 | bk.fillRect(0,0,235,16,TFT_LIGHTGREY);
120 | bk.fillRect(0,16,235,3,0x8430);
121 |
122 | //draw dash line
123 | for(int16_t i = 0; i < 5; i++) {
124 | //speed //space //posY //length
125 | // bk.drawFastHLine(dash_x +(40 * i), 20,10,TFT_WHITE);//far end dash line
126 | bk.drawFastHLine((dash_x-20)*1.5+(60 * i),45,15,TFT_WHITE);//middle dash line
127 | // bk.drawFastHLine((dash_x-40)*2.0+(80 * i),79,20,TFT_WHITE);//nearest dash line
128 | }
129 | dash_x = dash_x - ani_speed;
130 | if (dash_x <= 0 ) dash_x = 40;
131 |
132 | //draw traffic
133 | tag_x = tag_x - ani_speed;
134 | if (tag_x <= -80) tag_x = 235;
135 | //bk.setTextColor(random(0xffff));
136 | bk.drawString("< Thank You >",tag_x,0,2);//draw billboard
137 |
138 | //draw car
139 | int8_t move = random(-1,2);
140 | cur_x = cur_x + move;
141 | move = random(-1,2);
142 | cur_y = cur_y + move;
143 | if (cur_x > 235-CAR_WIDTH) cur_x = 235-CAR_WIDTH;
144 | if (cur_x < 1) cur_x = 1;
145 | if (cur_y < 1) cur_y = 1;
146 | if (cur_y > 79-CAR_HEIGHT) cur_y = 79-CAR_HEIGHT;
147 | car.pushToSprite(&bk,cur_x,cur_y,TFT_BLACK);//put car into bk, white color as transparent
148 |
149 | //draw fence
150 | for(int i=0;i<8;i++)//7 sprites
151 | fence.pushToSprite(&bk,fence_x*2+(FENCE_WIDTH*i),80-FENCE_HEIGHT,TFT_BLACK);
152 | fence_x = fence_x - ani_speed;
153 | if (fence_x <= -FENCE_WIDTH + ani_speed) fence_x = 0;//loop back
154 |
155 | //draw pole
156 | pole.pushToSprite(&bk,tag_x*2,80-POLE_HEIGHT,TFT_BLACK);//draw bush
157 |
158 | //show background sprite
159 | bk.pushSprite(85,159);
160 | //led blinking effect
161 | digitalWrite(LED_RED_PIN, random(0,2));
162 | digitalWrite(LED_GREEN_PIN, random(0,2));
163 | digitalWrite(LED_BLUE_PIN, random(0,2));
164 | checkCPUTemp();
165 | autoDim();
166 | }
167 | //remove sprites
168 | car.deleteSprite();
169 | bk.deleteSprite();
170 | pole.deleteSprite();
171 | fence.deleteSprite();
172 | }//task star field
173 |
174 | /*------------------*/
175 | //highlight and change warning each menu
176 | void setWarning(int8_t index, int8_t change) {
177 | for (uint8_t i = 0;i max) tempOffset = max;
204 | }
205 | String result = String(tempOffset);
206 | switch (result.length()) {
207 | case 1: result = " " + result; break;
208 | case 2: result = " " + result; break;
209 | case 3: result = " " + result; break;
210 | }//switch
211 | tft.drawRightString(result,285,57+(index*16),2);//cpu offset
212 | } else {//other pid
213 |
214 | int min = pidConfig[index-1][4].toInt();//get min
215 | int max = pidConfig[index-1][5].toInt();//get max
216 | if (change == -1) {//decrease
217 | warningValue[index-1] = String(warningValue[index-1].toInt() - pidWarnStep[index]);
218 | if (warningValue[index-1].toInt() < min) warningValue[index-1] = String(min);
219 | }
220 | if (change == 1) {//increase
221 | warningValue[index-1] = String(warningValue[index-1].toInt() + pidWarnStep[index]);
222 | if (warningValue[index-1].toInt() > max) warningValue[index-1] = String(max);
223 | }
224 | String result = warningValue[index-1];
225 | switch (result.length()) {
226 | case 1: result = " " + result; break;
227 | case 2: result = " " + result; break;
228 | case 3: result = " " + result; break;
229 | }//switch
230 | tft.drawRightString(result,285,57+(index*16),2);//pid warning value
231 | } //if i = 0
232 | delay(300);//touch screen delay
233 | }
234 | /*--------------------*/
235 | void loadMyPic() {
236 | if(!SD.begin()) {//sdcard not attach
237 | tft.pushImage(129,44,60,60,sdcard);//show sdcard icon
238 | Serial.println(F("Micro SD Card not mounted!"));
239 | tft.setTextColor(TFT_WHITE,TFT_RED);
240 | tft.drawCentreString("Please insert Micro SD Card",159,120,4);
241 | } else {//sd card attached
242 | Serial.println(F("Micro SD Card..OK"));
243 | uint8_t cardType = SD.cardType();
244 | if (cardType == CARD_NONE) {//bad card
245 | Serial.println(F("Micro SD Card Error!"));
246 | tft.setTextColor(TFT_WHITE,TFT_RED);
247 | tft.drawCentreString("Micro SD Card Error!",159,120,4);
248 |
249 | } else {//good sd card attached
250 | if (!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)) {
251 | Serial.println(F("Error: SPIFFS failed!"));
252 | tft.setTextColor(TFT_WHITE,TFT_RED);
253 | tft.drawCentreString("Error: SPIFFS failed!",159,120,4);
254 |
255 | } else {
256 | tft.setTextColor(TFT_BLACK,TFT_GREEN);
257 | tft.drawCentreString("Copying...\"mypic.jpg\"",159,120,4);
258 | Serial.println(F("Deleting...\"mypic.jpg\""));
259 | SPIFFS.remove(mypic_filename);//remove old file first
260 | File sourceFile = SD.open(mypic_filename);
261 | if (sourceFile) {//found file
262 |
263 | File destFile = SPIFFS.open(mypic_filename, FILE_WRITE);
264 | Serial.println(F("Copying...\"mypic.jpg\""));
265 | tft.setTextColor(TFT_BLACK,TFT_GREEN);
266 | static uint8_t buf[512];
267 | while(sourceFile.read( buf, 512) ) {
268 | destFile.write( buf, 512 );//copy file from sdcard to spiffs
269 | }
270 | sourceFile.close();
271 | destFile.close();
272 | //load mypic.jpg from spiffs to show on screen
273 | show_spiffs_jpeg_image(mypic_filename, 0, 0);
274 |
275 | } else {
276 | Serial.println(F("\"mypic.jpg\" not found!"));
277 | tft.pushImage(130,44,60,60,nofile);//show fileicon
278 | tft.setTextColor(TFT_WHITE,TFT_RED);
279 | tft.drawCentreString("\"mypic.jpg\" not found!",159,120,4);
280 | }//if sourcefile
281 | }//if SPIFFS.begin
282 | }//else sccard errror
283 | }//else sdcard attach
284 | SD.end();
285 | SPIFFS.end();
286 | beep();
287 | }//loadmypic
288 | /*----------------*/
289 |
290 | void listMenu(uint8_t choice) {
291 | //draw icon
292 | if (showsystem) tft.pushImage(0,35,25,25,switchon);//switchon image
293 | else tft.pushImage(0,35,25,25,switchoff);//switchon image
294 | tft.pushImage(0,65,25,25,image);//image
295 | tft.pushImage(0,95,25,25,cpu);//firmware
296 | tft.pushImage(0,125,25,25,warning);//parameter
297 | tft.pushImage(0,155,25,25,engine);//engine
298 | tft.pushImage(159,155,25,25,autooff);//off
299 | tft.pushImage(0,185,25,25,about);//about
300 | tft.pushImage(159,185,25,25,quit);//exit
301 | for (uint8_t i=0;i Press & Release Button",0,211,2);
311 | tft.drawString("Select -> Press & Hold Button",0,227,2);
312 | }
313 |
314 | /*----------------*/
315 | void configMenu() {//control configuration menu
316 | uint8_t select = 0;
317 | bool pressed = false;
318 | long holdtimer = 0;
319 | bool currentFlag = showsystem;//keep current flag status
320 | beep();
321 | tft.fillScreen(TFT_BLACK);//clear screen
322 | tft.fillRectVGradient(0, 0, 320, 26, TFT_ORANGE, 0xfc00);
323 | tft.setTextColor(TFT_BLACK);
324 | tft.drawCentreString("[--- Configuration Menu ---]",159,0,4);
325 | listMenu(select);
326 | delay(1000);
327 | while (true) {//loop check button press
328 |
329 | if (digitalRead(SELECTOR_PIN) == LOW) {//button pressed
330 | if (!pressed) {
331 | pressed = true;//set press flag
332 | holdtimer = millis();
333 | } else if (holdtimer - millis() > 3000) {//hold 3 sec enter config menu
334 | //---------- TOGGLE SHOW SYSTEM STATUS -----------
335 | if (select == 0) {
336 | beepbeep();
337 | showsystem = !showsystem;//toggle
338 | tft.setTextColor(TFT_WHITE,TFT_BLUE);
339 | if (showsystem) tft.pushImage(0,35,25,25,switchon);//switchon image
340 | else tft.pushImage(0,35,25,25,switchoff);//switchon image
341 |
342 | }
343 | //--------- LOAD MY PIC -----------
344 | if (select == 1) {
345 | clickSound();
346 | tft.fillRect(0,30,320,239,TFT_BLACK);
347 | loadMyPic();//load pic from sdcard to spiffs
348 | tft.setTextColor(TFT_BLACK,TFT_WHITE);
349 | tft.drawCentreString("[- Press button to exit -]",159,215,4);
350 | while (digitalRead(SELECTOR_PIN) == HIGH) {
351 | //wait for button press to exit
352 | checkCPUTemp();
353 | autoDim();
354 | }//while
355 | clickSound();
356 | tft.fillScreen(TFT_BLACK);//clear screen
357 | tft.setTextColor(TFT_BLACK,TFT_ORANGE);
358 | tft.drawCentreString("[--- Configuration Menu ---]",159,0,4);
359 | listMenu(select);
360 | }
361 |
362 | //--------- UPDATE FIRMWARE -----------
363 | if (select ==2) {
364 | clickSound();
365 | tft.fillRect(0,30,320,239,TFT_BLACK);
366 | tft.pushImage(56,44,60,60,sdcard);//show sdcard icon
367 | tft.pushImage(203,44,60,60,wifi);//show wifi icon
368 | tft.setTextColor(TFT_CYAN,TFT_BLACK);
369 | tft.drawCentreString("Touch an icon to choose",159,125,4);
370 | tft.drawCentreString("firmware update method.",159,155,4);
371 | tft.setTextColor(TFT_BLACK,TFT_WHITE);
372 | tft.drawCentreString("[- Press button to exit -]",159,215,4);
373 | delay(1000);
374 | while (digitalRead(SELECTOR_PIN) == HIGH) {//wait for button press to exit
375 | autoDim();
376 | checkCPUTemp();
377 | //touching
378 | uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
379 | bool touched = getTouch(&t_x, &t_y);
380 | if (touched && (t_y > 44) && (t_y < 104)) {
381 | if ((t_x >= 56) && (t_x <116)) {
382 | clickSound();
383 | updateFirmwareSD();//update by sd card
384 | }
385 | if ((t_x >= 203) && (t_x <263)) {
386 | clickSound();
387 | updateFirmwareWIFI();//update by wifi
388 | break;
389 | }
390 | }//if touched
391 | delay(300);//touch screen delay
392 | }//while
393 |
394 | tft.fillRect(0,30,320,210,TFT_BLACK);
395 | listMenu(select);
396 | }
397 |
398 | //------------ WARNING SETTING -----------
399 | if (select ==3) {
400 | int8_t warningMenuIndex = 0;//index for warning setting
401 | int8_t inc_dec = 0;//-1=decrease,0=no change, 1=increase
402 | clickSound();
403 | tft.fillRect(0,30,320,210,TFT_BLACK);
404 | tft.setTextColor(TFT_WHITE,TFT_BLACK);
405 | tft.drawCentreString("[ Warning Parameter Setting]",159,30,2);
406 | tft.drawFastHLine(0,50,320,TFT_RED);
407 | tft.setTextColor(TFT_WHITE,TFT_RED);
408 | tft.drawCentreString("[- Press button to Save & Exit -]",159,190,2);
409 | for (uint8_t i = 0;i<5;i++) //draw buttons
410 | tft.fillRoundRect(i*64,211,60,30,5,TFT_NAVY);
411 | tft.setTextColor(TFT_WHITE);
412 | tft.drawCentreString("DEFAULT",31,217,2);//reset
413 | tft.drawCentreString("^ PREV",95,217,2);//prev
414 | tft.drawCentreString("NEXT v",159,217,2);//next
415 | tft.drawCentreString("-",223,206,6);//-
416 | tft.fillRect(286,219,3,16,TFT_WHITE);//+
417 | tft.fillRect(280,225,16,3,TFT_WHITE);//+
418 | setWarning(warningMenuIndex,inc_dec);//list menu first
419 | delay(1000);
420 | while (digitalRead(SELECTOR_PIN) == HIGH) {//wait for button press to exit
421 | autoDim();
422 | checkCPUTemp();
423 | String status = "";
424 | if (foundOBD2) {//temperature read not working if not connect to bluetooh or
425 | status = " " +String(tempRead,1)+"`c";
426 | } else {
427 | status = "--.-`c";
428 | }
429 | tft.setTextColor(TFT_YELLOW,TFT_BLACK);
430 | tft.drawRightString(status.c_str(),319,30,2); //show cpu temp on top-right corner
431 | //touching
432 | uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
433 | bool touched = getTouch(&t_x, &t_y);
434 | if (touched && (t_y > 211)) {
435 | clickSound();
436 | #ifdef SERIAL_DEBUG
437 | Serial.printf("%d - %d\n",t_x,t_y);
438 | #endif
439 | if (t_x < 64) {//DEFAULT
440 | tempOffset = factoryTempOffset;//load default
441 | //read default warning value
442 | for (uint8_t i=0;i < maxpidIndex; i++) warningValue[i] = pidConfig[i][8];
443 | }
444 | if ((t_x >= 64) && (t_x <128)) warningMenuIndex--;//prev
445 | if ((t_x >= 128) && (t_x <192)) warningMenuIndex++;//next
446 | if ((t_x >= 192) && (t_x <256)) inc_dec = -1;//decrease
447 | if ((t_x >= 256) && (t_x <320)) inc_dec = 1;//increase
448 | if (warningMenuIndex == maxpidIndex+1) warningMenuIndex = 0;
449 | if (warningMenuIndex < 0) warningMenuIndex = maxpidIndex;
450 |
451 | setWarning(warningMenuIndex,inc_dec);//update list
452 | inc_dec = 0;//reset
453 |
454 | }//if touched
455 | }//while
456 | //exit and save warning data to preference
457 | pref.putInt("tempOffset",tempOffset);//save tempoffset
458 | for (uint8_t i=0;i < maxpidIndex; i++) {//save all pid
459 | pref.putString(pidConfig[i][0].c_str(),warningValue[i]);
460 | }
461 | tft.setTextColor(TFT_BLACK,TFT_GREEN);
462 | tft.drawCentreString("Parameters Saved.",159,120,4);
463 | beep();
464 | delay(1000);
465 | tft.fillRect(0,30,320,210,TFT_BLACK);
466 | listMenu(select);
467 | }
468 |
469 | //--------------- DTC -----------
470 | if (select == 4) {//https://www.elmelectronics.com/wp-content/uploads/2016/07/ELM327DS.pdf
471 |
472 | clickSound();
473 | tft.fillRect(0,30,320,239,TFT_BLACK);
474 | tft.pushImage(0,28,25,25,engine);//about
475 | tft.setTextColor(TFT_YELLOW,TFT_BLACK);
476 | tft.drawString("Diagnostic Trouble Codes",30,28,4);
477 | delay(500);
478 | getPID("ATE0");//force echo off
479 | //#1 get number of DTC & MIL status
480 | //getAB2("41 01 86 0E 88 88 41 01 81 0C 00 00 ","41","01");//(A = 80+1,80h=MIL ON,no of dtc = A-80h)
481 | uint8_t error_cnt = 0;
482 | uint8_t no_of_dtc = 0;
483 | A = 0xFF;//supoose error read A
484 | while ((A == 0xFF) && (error_cnt <3) ) {//if A == 0xFF repeat reading again (A must be 0x80+) try 3 times
485 | Serial.print(F("MIL Status 0101->"));
486 | getAB2(getPID("0101"),"41","01");//try read MIL status
487 | //Terminal(String(A).c_str(),0,88,320,125);
488 | error_cnt++;
489 | delay(100);
490 | }
491 | #ifdef TEST_DTC
492 | A = 0x86;
493 | #endif
494 |
495 | if (A == 0xFF) {//Error reading MIL status
496 | Serial.println(F("Error Reading MIL Status!"));
497 | tft.setTextColor(TFT_WHITE,TFT_RED);
498 | tft.drawCentreString("* Error Reading MIL Status! *",159,120,4);
499 | tft.setTextColor(TFT_LIGHTGREY,TFT_BLACK);
500 | tft.drawCentreString("[ Please try again ]",159,148,4);
501 | tft.setTextColor(TFT_BLACK,TFT_WHITE);
502 | tft.drawCentreString("[- Press button to exit -]",159,215,4);
503 | beep();
504 | } else {
505 | if (A == 0x00) {//41 01 00 = Mil is OFF No DTC
506 | tft.setTextColor(TFT_GREEN,TFT_BLACK);
507 | tft.drawCentreString("MIL is OFF - No DTC",159,120,4);
508 | tft.setTextColor(TFT_BLACK,TFT_WHITE);
509 | tft.drawCentreString("[- Press button to exit -]",159,215,4);
510 | } else if (A >= 0x80) {//41 01 8x if A =>80h then MIL status ON else skip to NO MIL below
511 | Serial.print(F("A = "));Serial.println(A,HEX);
512 | // #2 get Raw Diagnostic Troulbe Code from ELM327
513 | //(for 1 dtc)43 06 00 7D
514 | //(more than 1 dtc) 00E 0: 43 06 00 7D C6 93 1: 01 08 C6 0F 02 E9 02 e: E0 CC CC CC CC CC CC 43 01 C4 01
515 | uint8_t error_cnt = 0;
516 | String dtcRead = "";
517 |
518 | //check first header 43 or 00
519 | while ((dtcRead.substring(0,2) != "43") && (dtcRead.substring(0,2) != "00") && (error_cnt < 5)) {
520 | Serial.print(F("Read DTC 03->"));
521 | dtcRead = getPID("03");//try read DTC code
522 | #ifdef TEST_DTC
523 | dtcRead = "00E 0: 43 06 00 7D C6 93 1: 01 08 C6 0F 02 E9 02 2: E0 CC CC CC CC CC CC 43 01 C4 01";
524 | #endif
525 | //Terminal(dtcRead,0,88,320,125);
526 | error_cnt++;
527 | delay(100);
528 | }
529 | if (error_cnt >= 10) {//exist by error counter
530 | Serial.println(F("Error Reading DTCs!"));
531 | tft.setTextColor(TFT_WHITE,TFT_RED);
532 | tft.drawCentreString("* Error Reading DTCs! *",159,120,4);
533 | tft.setTextColor(TFT_LIGHTGREY,TFT_BLACK);
534 | tft.drawCentreString("[ Please try again ]",159,148,4);
535 | tft.setTextColor(TFT_BLACK,TFT_WHITE);
536 | tft.drawCentreString("[- Press button to exit -]",159,215,4);
537 | beep();
538 | } else {
539 | //#3 Interpret get the real DTC code 5 digits
540 | //(for 1 dtc)43 06 00 7D
541 | // 00E 0: <43 06> /00 7D /C6 93 /1: /01 08 /C6 0F /02 E9 /02 2: E0 /CC CC /CC CC /CC CC /<43 01>/C4 01
542 | beepbeep();
543 | int byteCount = 0;//keep number of data byte
544 | String hexcode[128];//4x16
545 | uint8_t StringCount = 0;
546 | dtcRead.trim();
547 | while (dtcRead.length() > 0) {//split to hex byte
548 | int index = dtcRead.indexOf(' ');
549 | String getByte = dtcRead.substring(0, index);//get first byte
550 | if (getByte.indexOf(':') == -1 ) {//no :
551 | if (getByte.length() >= 3) {
552 | byteCount = strtol(getByte.c_str(), NULL, 16);//get byte count = 14 byte
553 | Serial.print(byteCount);
554 | Serial.print(" = ");
555 | } else {//skip ':' byte
556 | hexcode[StringCount++] = getByte;//copy strings from 0 to space to hexcode
557 | Serial.print(getByte + ",");
558 | if (StringCount == byteCount) break;//stop when byte count reach, ignore the rest
559 | //4306007DC6930108C60F02E902E0 = 14 byte
560 | }
561 | }
562 | dtcRead = dtcRead.substring(index + 1);//copy the rest behind space to elm_rs
563 | }//while
564 |
565 | Serial.println(); //debug split hex byte
566 |
567 | //interpret DTC 007D=P007D C693=U0693 0108=P0108 C60F=U060F 02E9=P02E9 02E0=P02E0
568 | String dtcList[16] = {};//to keep all DTC in list
569 | no_of_dtc = 0;
570 | for (uint8_t index = 0;index < StringCount; index++) {
571 | if (hexcode[index] == "43") {//check if first nibble is 43
572 | index = index + 2;//skip 2 byte to next pid
573 | }
574 | String dtc_1 = hexcode[index];//C6
575 | uint8_t code = strtol(dtc_1.substring(0,1).c_str(),0,16);//0x0C compare with dtcMap table
576 | dtc_1 = dtcMap[code]+dtc_1.substring(1);//U0+6 = U06 change prefix,remove 1st char get the rest
577 | index++;
578 | String dtc_2 = hexcode[index];//0F
579 | dtcList[no_of_dtc] = dtc_1+dtc_2;//U060F
580 | Serial.print(dtcList[no_of_dtc] + ",");//got real DTC code here
581 | no_of_dtc++;//keep real no of dtc in no_of_dtc
582 | }//for
583 | tft.setTextColor(TFT_RED,TFT_BLACK);
584 | String txt = "MIL is ON - No of DTCs = "+String(no_of_dtc);
585 | tft.drawCentreString(txt,159,58,4);
586 | tft.drawFastHLine(0,85,320,TFT_WHITE);
587 | Serial.printf("\nNo of DTCs = %d\n",no_of_dtc);
588 |
589 | //#4 List all DTC on screen
590 | tft.setTextColor(TFT_WHITE,TFT_BLACK);
591 | for (uint8_t i=0;i0x80
609 | }//else if error_ent>5
610 |
611 | while (digitalRead(SELECTOR_PIN) == HIGH) { //wait for button press to exit
612 | checkCPUTemp();
613 | autoDim();
614 | //CLEAR MIL
615 | if (no_of_dtc !=0) {//if there is dtc, touch checking for clear MIL
616 | uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
617 | bool touched = getTouch(&t_x, &t_y);
618 | #ifdef SERIAL_DEBUG
619 | Serial.printf("%d - %d\n",t_x,t_y);
620 | #endif
621 | if (touched && (t_y > 225) && (t_x < 127)) {//touch clear MIL button
622 | clickSound();
623 | BTSerial.print("04\r");//clear MIL 04->7F 04 78 7F 04 78
624 | tft.setTextColor(TFT_BLACK,TFT_GREEN);
625 | tft.drawCentreString("* Successful Clear MIL *",159,120,4);
626 | Serial.println(F("* Successful Clear MIL *"));
627 | beepbeep();
628 | delay(3000);
629 | break;
630 | }//if touch
631 | }//if (no_of_dtc)
632 | yield();
633 | }//while button exit
634 | tft.fillRect(0,28,320,239,TFT_BLACK);
635 | listMenu(select);
636 | }//select = 4
637 | //---------- Auto OFF Voltage -----------
638 | if (select == 5) {
639 | clickSound();
640 | tft.fillRect(0,30,320,210,TFT_BLACK);
641 | tft.pushImage(0,30,25,25,autooff);//about
642 | tft.setTextColor(TFT_WHITE,TFT_BLACK);
643 | tft.drawString("Gauge Auto-off Setting",40,30,4);
644 | tft.setTextColor(TFT_WHITE,TFT_BLACK);
645 | tft.drawString("Set detection PCM voltage to turn off gauge.",10,65,2);
646 | tft.drawString("If gauge turn off while the engnine is running",10,85,2);
647 | tft.drawString("Please lower down the voltage",10,105,2);
648 | tft.drawString("Volt",220,135,4);
649 | tft.setTextColor(TFT_BLACK,TFT_WHITE);
650 | tft.drawCentreString("[- Press button to exit -]",159,180,4);
651 | for (uint8_t i = 0;i<5;i++) //draw buttons
652 | tft.fillRoundRect(i*64,211,60,30,5,TFT_NAVY);
653 | tft.setTextColor(TFT_WHITE);
654 | tft.drawCentreString("DEFAULT",31,217,2);//reset
655 | tft.drawCentreString("-",223,206,6);//-
656 | tft.fillRect(286,219,3,16,TFT_WHITE);//+
657 | tft.fillRect(280,225,16,3,TFT_WHITE);//+
658 | tft.setTextColor(TFT_YELLOW,TFT_BLACK);
659 | String result = String(ecu_off_volt, 1);
660 | tft.drawCentreString(result.c_str(),159,135,4);
661 | delay(1000);
662 | while (digitalRead(SELECTOR_PIN) == HIGH) {//wait for button press to exit
663 | checkCPUTemp();
664 | autoDim();
665 | uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
666 | bool touched = getTouch(&t_x, &t_y);
667 | if (touched && (t_y > 211)) {
668 | clickSound();
669 | #ifdef SERIAL_DEBUG
670 | Serial.printf("%d - %d\n",t_x,t_y);
671 | #endif
672 | if (t_x < 64) {//DEFAULT
673 | ecu_off_volt = factoryECUOff;
674 | }
675 |
676 | if ((t_x >= 192) && (t_x <256)) {//decrease
677 | ecu_off_volt = ecu_off_volt - 0.1;
678 | if (ecu_off_volt <= 11.0) ecu_off_volt = 11.0;
679 | }
680 | if ((t_x >= 256) && (t_x <320)) {//increase
681 | ecu_off_volt = ecu_off_volt + 0.1;
682 | if (ecu_off_volt >= 15.0) ecu_off_volt = 15.0;
683 | }
684 | String result = String(ecu_off_volt, 1);
685 | tft.drawCentreString(result.c_str(),159,135,4);
686 | delay(300);//touch screen delay
687 | }//if touched
688 | }//while
689 | //exit and save warning data to preference
690 | pref.putFloat("ecu_off_volt",ecu_off_volt);//save ecu_off_volt
691 |
692 | tft.setTextColor(TFT_BLACK,TFT_GREEN);
693 | tft.drawCentreString("Parameters Saved.",159,120,4);
694 | beep();
695 | delay(1000);
696 | tft.fillRect(0,30,320,210,TFT_BLACK);
697 | listMenu(select);
698 | }//select = 5
699 |
700 | //---------------------ABOUT-----------
701 | if (select == 6) {
702 | clickSound();
703 | delay(500);
704 | xTaskCreatePinnedToCore(
705 | &TaskPlayMusic
706 | , "play music in core 0" // A name just for humans
707 | , 4096// This stack size can be checked & adjusted by reading the Stack Highwater
708 | , NULL// no variable passting to task
709 | , 3 //Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
710 | , &TaskHandle0
711 | , 0);//core0
712 | animation();//play star field animation
713 | vTaskDelete(TaskHandle0);//stop animation and text animation
714 | pinMode(BUZZER_PIN,OUTPUT);//set pin mode again unless speaker stop working
715 | ledcAttachPin(BUZZER_PIN, buzzerChannel);//reattach buzzer pin
716 | clickSound();
717 | tft.fillScreen(TFT_BLACK);//clear screen
718 | tft.fillRectVGradient(0, 0, 320, 26, TFT_ORANGE, 0xfc00);
719 | tft.setTextColor(TFT_BLACK);
720 | tft.drawCentreString("[--- Configuration Menu ---]",159,0,4);
721 | listMenu(select);
722 | }//if (select ==6)
723 | //---------------------EXIT-----------
724 | if (select == 7) {
725 | clickSound();
726 | if (showsystem != currentFlag) {//save to eeprom only when flag changed
727 | pref.putBool("showsystem", showsystem);//save to NVR
728 | }
729 | break;//exist main config menu loop while
730 | }//select = 7
731 | pressed = false;
732 | prompt = true;//to trig reading elm again
733 | } //if holdtimer > 3000
734 | delay(250);//delay avoid bounce
735 | //**********************
736 | } else {//button release
737 | if (pressed) {//button release
738 | select++;//next menu
739 | if (select == maxMenu) select = 0;
740 | listMenu(select);//next menu
741 | clickSound();
742 | pressed = false;
743 | delay(200);
744 | }//pressed
745 |
746 | }//if press&& digitalread
747 | checkCPUTemp();
748 | autoDim();
749 |
750 | } //while (true)
751 | tft.fillScreen(TFT_BLACK);//clear screen
752 | }//configMenu
753 |
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/elm327.h:
--------------------------------------------------------------------------------
1 | //elm327 interpreter
2 |
3 | //DTC prefex code mapping
4 | const String dtcMap[16] = {"P0","P1","P2","P3","C0","C1","C2","C3","B0","B1","B2","B3","U0","U1","U2","U3"};
5 |
6 | //get A B from response return in global A B variable
7 | void getAB2(String elm_rsp,String mode,String para) { //41 05 2A 3C 01>
8 | elm_rsp.trim();
9 | String hexcode[16];
10 | uint8_t StringCount = 0;
11 | while (elm_rsp.length() > 0) {//keep reading each char
12 | int index = elm_rsp.indexOf(' ');//check space
13 | if (index == -1) // No space found
14 | { //only data without space is now in hexcode {41,05,aa,bb}
15 | hexcode[StringCount++] = elm_rsp; //last byte
16 | //for (index=0;index0) {//clear rx buffer
32 | BTSerial.read();
33 | }
34 | String bt_response = "";
35 | BTSerial.print(pid+"\r");//get no of dtc
36 | delay(500);//wait for response
37 | while (BTSerial.available()>0) {//reading Bluetooth
38 | char incomingChar = BTSerial.read();
39 | //check CR/NL
40 | if (incomingChar == '>') {
41 | Serial.println(bt_response);
42 | BTSerial.flush();
43 | } else {
44 | bt_response.concat(incomingChar);//keep elm327 respond
45 | }
46 | } //while BTSerial
47 | return bt_response;
48 | }
49 | /*------------------*/
50 | /* VIN reading
51 | String resp = "014
52 | 0: 49 02 01 4D 50 42
53 | 1: 41 4D 46 30 36 30 4E
54 | 2: 58 34 33 37 30 39 33 "; */
55 | //convert ascii code to Charactor
56 | const char asciiTable[0x60]= " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}`";
57 | char HextoChar(uint8_t asciiCode) {
58 | if ((asciiCode > 0x20) && (asciiCode < 0x80)) {
59 | return(asciiTable[asciiCode-32]);
60 | }
61 | else return '\0';//null-terminator
62 | }
63 | //----------------------------
64 | //function get VIN Serial.println(getVIN(getPID(0902)));
65 | String getVIN(String elm_rsp) {
66 | String VIN = "";
67 | uint8_t byteCount = 0;
68 | elm_rsp.trim();
69 | while (elm_rsp.length() > 0) {//keep reading each char
70 | int index = elm_rsp.indexOf(' ');//check space
71 | String getByte = elm_rsp.substring(0, index);//get first byte
72 | if (index == -1) {//no space found
73 | byte ascii = strtol(getByte.c_str(), NULL, 16);//read ascii
74 | VIN.concat(HextoChar(ascii));//last char
75 | //check correct VIN
76 | if (VIN.length() == byteCount) {
77 | VIN = VIN.substring(3);//remove first 3 string
78 | Serial.println("VIN: " + VIN);
79 | return VIN;//return VIN number
80 | } else {
81 | return "Cannot read VIN";
82 | }
83 |
84 | } else {//found space
85 | if (getByte.indexOf(':') == -1 ) {
86 | if (getByte.length() >= 3) {
87 | byteCount = strtol(getByte.c_str(), NULL, 16);//get byte count
88 | } else {//skip ':' byte
89 | byte ascii = strtol(getByte.c_str(), NULL, 16);//read ascii
90 | VIN.concat(HextoChar(ascii));//convert to hex charactor
91 | }
92 | }
93 | elm_rsp = elm_rsp.substring(index + 1);//copy the rest behind space to elm_rsp.
94 | }//else
95 | } //while
96 | return "Cannot read VIN";
97 | }//getVIN
98 | //----------------------------
99 |
100 |
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/firmware/README.md:
--------------------------------------------------------------------------------
1 | there are 3 compiled firmware version
2 | 1. VaandcobOBD2_T6_2023.bin
3 | - this is an original firmware from that work with ford T6 up with transmission 6R80, 10R80
4 | - work very well before some libraries updated.
5 |
6 | 2. VaandcobOBD2_T5.bin
7 | - this is a new firmware for old ford T5 vehicle with old automatic transmission
8 |
9 | 3. for firmware suffix with _nogenuine.bin are the version that skip genuine board check.
10 |
11 |
12 | ----------------------------------------
13 | You can flash firmware with web flasher tool ->
14 | https://vaandcob.github.io/webpage/src/index.html
15 |
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/firmware/T5_manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Va&Cob OBDII Gauge",
3 | "version": "Ford T5",
4 | "new_install_prompt_erase": false,
5 | "new_install_improv_wait_time": 0,
6 | "builds": [
7 | {
8 | "chipFamily": "ESP32",
9 | "parts": [
10 | { "path": "bootloader.bin", "offset": 4096 },
11 | { "path": "partitions.bin", "offset": 32768},
12 | { "path": "boot_app0.bin", "offset": 57344 },
13 | { "path": "VaAndCobOBD2GaugeT5_nogenuine.bin", "offset": 65536 }
14 | ]
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/firmware/T6_manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Va&Cob OBDII Gauge",
3 | "version": "Ford T6",
4 | "new_install_prompt_erase": false,
5 | "new_install_improv_wait_time": 0,
6 | "builds": [
7 | {
8 | "chipFamily": "ESP32",
9 | "parts": [
10 | { "path": "bootloader.bin", "offset": 4096 },
11 | { "path": "partitions.bin", "offset": 32768 },
12 | { "path": "boot_app0.bin", "offset": 57344 },
13 | { "path": "VaAndCobOBD2Gauge_T6_nogenuine.bin", "offset": 65536 }
14 | ]
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/firmware/VaAndCobOBD2GaugeT5_nogenuine.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/sketch/VaAndCobOBD2Gauge/firmware/VaAndCobOBD2GaugeT5_nogenuine.bin
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/firmware/VaAndCobOBD2Gauge_T6_nogenuine.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/sketch/VaAndCobOBD2Gauge/firmware/VaAndCobOBD2Gauge_T6_nogenuine.bin
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/firmware/boot_app0.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/sketch/VaAndCobOBD2Gauge/firmware/boot_app0.bin
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/firmware/bootloader.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/sketch/VaAndCobOBD2Gauge/firmware/bootloader.bin
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/firmware/offset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/sketch/VaAndCobOBD2Gauge/firmware/offset.png
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/firmware/partitions.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VaAndCob/ESP32-Blutooth-OBD2-Gauge/d75b147ba5c306557b0c7477509e40ff5346471a/sketch/VaAndCobOBD2Gauge/firmware/partitions.bin
--------------------------------------------------------------------------------
/sketch/VaAndCobOBD2Gauge/firmware_update.h:
--------------------------------------------------------------------------------
1 | //Firmware updater library
2 | #include //ota partition boot option
3 | #include // main updater
4 | #include // File System
5 | #include // SD Card ESP32
6 | #include //safe file
7 |
8 | //Wifi updater
9 | #include //wifi
10 | #include
11 |
12 | const char* ssid = "Va&Cob OBD2 Gauge";
13 | const char* password = "12345678";//default password
14 | IPAddress local_IP(192, 168, 4,1);
15 | IPAddress gateway(192, 168, 4, 1);
16 | IPAddress subnet(255, 255, 255, 0);
17 | WebServer server(80);
18 |
19 | #define firmware_filename "/VaAndCobOBD2Gauge.bin"//firmware file
20 |
21 |
22 | /*------------ SOUND EFFECT ----------*/
23 | void beepbeep() { //2 shot beep
24 | ledcWriteTone(buzzerChannel,2000);
25 | delay(50);
26 | ledcWriteTone(buzzerChannel,0);
27 | delay(50);
28 | ledcWriteTone(buzzerChannel,2000);
29 | delay(50);
30 | ledcWriteTone(buzzerChannel,0);
31 | }
32 | void beep() {
33 | ledcWriteTone(buzzerChannel,2000);
34 | delay(500);
35 | ledcWriteTone(buzzerChannel,0);
36 | }
37 | void clickSound() {
38 | ledcWriteTone(buzzerChannel,5000);
39 | delay(5);
40 | ledcWriteTone(buzzerChannel,0);
41 | }
42 | /*-----------------------------*/
43 | //html update file
44 | static const char uploadIndex[] PROGMEM =
45 | R"(
46 |
47 |
48 |
49 |
50 |
51 |
70 | Please choose file 'vaandcobobd2gauge.bin'
71 |
74 |
75 |
76 |
0%
77 |
78 |
110 |
111 |