ELMduino BLE Support
Hi there,
I built a small Serial wrapper for BLE connection, so now it's possible to use ELMduino with BLE 4.0 OBD dongles.
Tested with OBDLink CX, custom headers and PID are also working fine, you can take a look.
https://github.com/vdvornichenko/obd-ble-serial
Amazing, great work - well done!
This is excellent! I started on something similar but it got sidetracked for various reasons and never finished. Your implementation looks more robust than what I was working on. Nice. This could be useful for other projects as well that need a BLE to Serial library. I'm looking forward to trying this out soon.
Hello, what devices have you tried this on? I tried multiple ESP32S3 Dev Module LCD screens and they all crash when using your example.
You are a legend .... I was tired of always having to enter the MAC .... thank you thank you and a thousand thanks It connects quickly to the odb, but corrupts some data.. However the ELMduino library is able to interpret well (rpm, speed....etc), except for the voltage
es:
08:42:46.198 Clearing input serial buffer
08:42:46.198 Sending the following command/query: AT RV
08:42:46.228 [DEBUG] ELM RESPONSE > AT_RV
08:42:46.231 [DEBUG] ELM RESPONSE > \r
08:42:46.242 [DEBUG] ELM RESPONSE > 13.8V\r\r>
08:42:46.258 Received char: A
08:42:46.278 Received char: T
08:42:46.297 Received char: _
08:42:46.318 Received char: R
08:42:46.338 Received char: V
08:42:46.357 Received char: ?
08:42:46.377 Received char: \r
08:42:46.397 Received char: T
08:42:46.417 Received char: _
08:42:46.438 Received char: R
08:42:46.457 Received char: V
08:42:46.478 Received char: ?
08:42:46.497 Received char: 1
08:42:46.517 Received char: 3
08:42:46.538 Received char: .
08:42:46.558 Received char: 8
08:42:46.577 Received char: V
08:42:46.597 Received char: \r
08:42:46.617 Received char: \r
08:42:46.643 Received char: >
08:42:46.643 Delimiter found.
08:42:46.643 All chars received: ATRVTRV13.8V
08:42:46.645 Battery Voltage: 0.00
instead of (connection via MAC)
14:18:14.681 Sending the following command/query: AT RV
14:18:14.693 Received char: A
14:18:14.693 Received char: T
14:18:14.693 Received char: _
14:18:14.693 Received char: R
14:18:14.698 Received char: V
14:18:14.698 Received char: \r
14:18:14.720 Received char: 1
14:18:14.720 Received char: 3
14:18:14.720 Received char: .
14:18:14.720 Received char: 8
14:18:14.726 Received char: V
14:18:14.726 Received char: \r
14:18:14.726 Received char: \r
14:18:14.731 Received char: >
14:18:14.731 Delimiter found.
14:18:14.731 All chars received: ATRV13.8V
14:18:14.737 Battery Voltage: 13.80
and small problem: if (!ELM_PORT.connect()) { ------>if false (so with odb powered off) it resets the device
21:40:07.072 -> entry 0x400805b8
21:40:16.757 -> Forming a connection to
21:40:16.757 -> Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
21:40:16.757 ->
21:40:16.757 -> Core 1 register dump:
21:40:16.801 -> PC : 0x400915b3 PS : 0x00060730 A0 : 0x800db5e8 A1 : 0x3ffcc1d0
21:40:16.801 -> A2 : 0x3ffcc1ea A3 : 0x00000005 A4 : 0x00000006 A5 : 0x3ffcc1ea
21:40:16.801 -> A6 : 0x00000006 A7 : 0x3ffc3cf4 A8 : 0x800e101c A9 : 0x3ffcc1b0
21:40:16.801 -> A10 : 0x00000002 A11 : 0x3f403fb8 A12 : 0x00000018 A13 : 0x0000ff00
21:40:16.801 -> A14 : 0x00ff0000 A15 : 0x3ffc3cf4 SAR : 0x00000010 EXCCAUSE: 0x0000001c
21:40:16.824 -> EXCVADDR: 0x00000005 LBEG : 0x40091ca5 LEND : 0x40091cb5 LCOUNT : 0xffffffff
21:40:16.824 ->
21:40:16.824 ->
21:40:16.824 -> Backtrace: 0x400915b0:0x3ffcc1d0 0x400db5e5:0x3ffcc1e0 0x400d26b5:0x3ffcc210 0x400d5ebb:0x3ffcc250 0x400e3f9f:0x3ffcc290 0x40094bc2:0x3ffcc2b0
21:40:16.824 ->
21:40:16.824 ->
21:40:16.824 ->
21:40:16.824 ->
21:40:16.824 -> ELF file SHA256: b6d7320c9
21:40:16.824 ->
21:40:17.157 -> Rebooting...
21:40:17.157 -> ets Jun 8 2016 00:22:57
21:40:17.157 ->
21:40:17.157 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
Saluti Luca
SOLVED For the corrupted data passed to elmduino (which still manages to interpret well), I took the liberty of modifying the library "BLEClientSerial.cpp"
static void notifyCallback(
BLERemoteCharacteristic *pBLERemoteCharacteristic,
uint8_t *pData,
size_t length,
bool isNotify)
{
Serial.print("[DEBUG] ELM RESPONSE > ");
printFriendlyResponse(pData, length);
// Convertiamo i dati ricevuti in una stringa
std::string receivedData((char*)pData, length);
// Se la nuova stringa è già presente alla fine di staticBuffer, evitiamo di concatenarla
if (staticBuffer.size() < length || staticBuffer.substr(staticBuffer.size() - length) != receivedData) {
staticBuffer += receivedData;
}
//Serial.print("[DEBUG] staticBuffer after append: ");
//Serial.println(staticBuffer.c_str());
}
printout (ESP32 ELMduino 3.3.2 OBD Vlink connected via BLE )
Clearing input serial buffer
Sending the following command/query: AT RV
[DEBUG] ELM RESPONSE > A
[DEBUG] ELM RESPONSE > T_
[DEBUG] ELM RESPONSE > R
[DEBUG] ELM RESPONSE > V
[DEBUG] ELM RESPONSE > \r
[DEBUG] ELM RESPONSE > 13.9V\r\r>
Received char: A
Received char: T
Received char: _
Received char: R
Received char: V
Received char: \r
Received char: 1
Received char: 3
Received char: .
Received char: 9
Received char: V
Received char: \r
Received char: \r
Received char: >
Delimiter found.
All chars received: ATRV13.9V
Battery Voltage: 13.90
SOLVED "Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled" I added a mydevice check "BLEClientSerial.cpp"
bool BLEClientSerial::connect(void)
{
Serial.println("Forming a connection to ");
// Controllo che myDevice sia stato trovato durante la scansione BLE
if (myDevice == nullptr) {
Serial.println("Errore: Nessun dispositivo BLE trovato! Assicurati che l'OBD sia acceso.");
return false;
}
Serial.println(myDevice->getAddress().toString().c_str());
ecc
ecc
ecc
Great work! I was finally able to update my WT32-SC01 board to the WT32-SC01-Plus which doesn't handle bluetooth classic. I'm using it for a OBD2 display for my Hyundai Ioniq5. Big thank you!