Comments (8)
I'm also finding reconnecting after resetting the ESP32 or uploading a new program is quite unreliable, I have to press the bluetooth pair button on my OBD dongle otherwise the EML327.begin fails. I suspect either I have to close the OBD connection, or close the bluetooth connection before uploading again. I will investigate.
ok I think I solved this in two steps, and am now getting really reliable connections every time I reboot, or upload a program:
-
I had my iPhone paired with the OBD scanner. On every reboot, the iPhone was jumping in and connecting to the scanner over bluetooth and locking out the ESP32 - oops.
-
by putting in a 1 second delay between starting the ESP32 bluetooth module and the connecting with the scanner.
So this is my setup() now:
void setup() {
Serial.begin(115200);
// Start the ESP32's bluetooth classic module and advertise as "Boost"
Serial.println("Starting ESP32 bluetooth classic module");
SerialBT.begin("Boost", true);
delay(1000);
// Try and connect to the OBD scanner over bluetooth
sprintf(bt_scanner_mac, "%02X:%02X:%02X:%02X:%02X:%02X", address[0], address[1],address[2],address[3],address[4],address[5]);
Serial.printf("Trying bluetooth connection with OBD scanner %s\n", bt_scanner_mac);
bool connected = SerialBT.connect(address);
if (!connected) {
SerialBT.end();
SerialBT.unpairDevice(address);
Serial.printf("Couldn't make bluetooth connection with OBD scanner %s. "
"Disconnected from OBD scanner, and unpaired it.\n", bt_scanner_mac);
}
if (!myELM327.begin(SerialBT, '6')) {
Serial.println("Couldn't start OBD scanner CAN protocol 6");
while (1);
}
Serial.println("Connected to ELM327");
}
Also I'm not sure if it helps, but to end the program, I'm searching for a keypress on the serial monitor, and if I press 'd' it closes the bluetooth connection.
if(Serial.available()) {
char c = Serial.read();
if (c == 'd') {
// if (myELM327.sendCommand("STPC") == ELM_SUCCESS)
// Serial.printf("Closed Protocol %s\n", myELM327.payload);
Serial.println("Closing bluetooth connection");
SerialBT.end();
Serial.println("Halting program ... ");
while(1);
}
from elmduino.
2. by putting in a 1 second delay between starting the ESP32 bluetooth module and the connecting with the scanner.
PS With further testing I found 1 second delay is not needed for reliable operation during restart
from elmduino.
Can you update from master and see if it fixes the problem? Notice that I also switched around the input arguments on begin()
, so now it's: bool ELM327::begin(Stream &stream, char protocol, uint16_t payloadLen)
from elmduino.
Yep fixed now. I am calling myELM327.begin(SerialBT, '6'))
as I know my BMW uses CAN bus 11-bit at 500kbps.
When specifying protocol = '0' or default (also '0') I've had to increase the timeout to 5000ms otherwise it will connect, but times out when querying a PID. When I specify protocol 6, the 1000ms timeout is ok.
from elmduino.
I'm also finding reconnecting after resetting the ESP32 or uploading a new program is quite unreliable, I have to press the bluetooth pair button on my OBD dongle otherwise the EML327.begin fails. I suspect either I have to close the OBD connection, or close the bluetooth connection before uploading again. I will investigate.
from elmduino.
Sorry one last thing, in your code update I notice that here
Line 116 in c84c0c4
command
variable, you've hard coded SET_PROTOCOL_TO_H_SAVE
, I fixed that even though it never gets executed as the for me the function returns in the AUTO search code above.from elmduino.
Everything should be fixed in 2.2.1. Thanks!
from elmduino.
excellent, thank you!
from elmduino.
Related Issues (20)
- ELM327::isPidSupported Error
- Custom PID, how it works HOT 9
- PID 70: Boost pressure control (Service 01) HOT 1
- Problem with flashing RPM value on OLED when using latest version of ELMduino HOT 8
- ESP32 not connecting to ELM327 HOT 5
- Protocol Data Point HOT 4
- Couldn't connect to OBD scanner (stucked) HOT 18
- First time Bluetooth pairing between ESP32 and ELM327 HOT 1
- custom pid for DPF HOT 17
- BT Pairing problem between ESP-32 and ELM327 HOT 6
- How to change OBD protocol HOT 5
- Response not detected HOT 28
- Error in getting Multiple PID's HOT 9
- ESP32 s3 BLE compatibility? HOT 3
- Attempting to read non-standard PID HOT 1
- When does `queryPid` return `true`? HOT 4
- ESP32_CheckPIDs_1_20.ino HOT 1
- How to read data if I know TXD RXF RXD and MTH HOT 2
- ERROR: ELM_BUFFER_OVERFLOW on Honda Vezel 2023 HOT 4
- Problems in phase 1, can't connect with ELM327 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elmduino.