Closed filmchaser1 closed 2 years ago
Note BLE is not currently supported by this library
begin()
has the timeout
parameter, which is what you're looking for: https://github.com/PowerBroker2/ELMduino/blob/fb24b93bee86b2d299dec27883f70587a1e2d01f/src/ELMduino.h#L310 The timeout is then set as a class attribute in begin()
and subsequently used throughout the class functionsFor point (2), assuming you're using bluetooth classic (not BLE), Specifying your ELM's bluetooth MAC address instead of advertised name (e.g. "OBDII") significantly reduces connection time. When you specify the advertised name, the ESP32 does a bluetooth scan then finds the one with the OBDII name and connects to that (even if you've previously paired it). You can see this if you turn on ESP32 verbose logging.
Thanks for the replies. I changed the question to say Bluetooth instead of BLE, to avoid confusion. The questions are still applicable.
I didn't realize when asking my questions that we were talking about two different example code. Thanks.
My Libraries Manager is showing v3.0.2 which is the latest. Changes from v3.0.1 to latest is here
I have 3.02 installed, however, the example file from that library install looks different than the example you have on the page here https://github.com/PowerBroker2/ELMduino also, multiple PIDS example on here is not in the arduino library version, and has a different setup and has so I wasn't sure which was the latest.
In any case, am I missing something with replacing the "OBDII" with "mac address"? It's not connecting, so I'm curious why not. I didn't see any other instructions for connecting via mac address. I'm using the colon format not dashes.
Interesting, not sure why your version doesn't have the correct updates.
I've never used the MAC address to connect - are you sure you have the correct address? Maybe this will be of some use
Not sure either. It's same on both my mac and PC, I installed the library on both last week. Thanks, I'm confident it is the right mac address, I looked at it on my laptop to see what the mac of advertised name OBDII was. I also verified that the esp32 was advertising as ArduHUD per the example sketch.
Your mac address needs to be in an array, have a look at this example in the espressif bluetooth classic library https://github.com/espressif/arduino-esp32/blob/master/libraries/BluetoothSerial/examples/SerialToSerialBTM/SerialToSerialBTM.ino
Essentially
uint8_t address[6] = {0xAA, 0xBB, 0xCC, 0x11, 0x22, 0x33}; // For mac address "AA:BB:CC:11:22:33"
and then
// connect(address) is fast (upto 10 secs max), connect(name) is slow (upto 30 secs max) as it needs
// to resolve name to address first, but it allows to connect to different devices with the same name.
// Set CoreDebugLevel to Info to view devices bluetooth address and device names
connected = SerialBT.connect(address);
Hi, Great work so far...I have and esp32 using your latest updated library, it connects to the ELM327 but takes about 14 seconds. And it blocks any other code from running. If no Bluetooth is available it blocks for almost 2 minutes before code can run.
Ideally, this would be a non blocking attempt to connect so I can run other code in the meantime. If that is not possible, then speeding up the connection time and reducing the timeout would help.
Thank you.