Hello there, I am new to this world so forgive me for any nonsense I might say.
I have an Arduino Uno R4 WiFi which (as far as I understood) has Bluetooth capabilities thanks to the ESP32-S3.
I want to detect when a Bluetooth device (mainly my phone) gets close to the board.
Looking for something similar I bumped into this thread: [SOLVED] Detect specific Bluetooth MAC address and trigger relay when detected.
Which suggests to use the Bluetooth Classic connection instead of the BLE since, this way, it is easier to get the device MAC address that allows to identify it.
I also found this support page: Boards and shields with wireless connectivity; which states and I quote:
Although the communication modules on these boards can also use Bluetooth Classic, it is not currently supported by official firmware or libraries.
After some research I found that for this type of communication the BluetoothSerial.h library is used, which is part of the ESP32 board, such as the Nano ESP32.
I installed the ESP32 core but I was not able to import this library in my Arduino Uno R4 WiFi sketch.
Is there a way to make this work?
This was not my first idea, I leave the details of what I tried to do in the spoiler below.
Previous plan using BLE
At first I tried using the BLE via the ArduinoBLE library which I managed to get working thanks to this thread: Radio module firmware version 0.2.0 is now available.
The idea was to let the Arduino send an advertise and listen for connections. This approach kinda worked but it led to some problems:
-
The phone complained that
An app is needed for this device to workbut by pressingPairit manages to connect anyway. I am no expert in BLE but I think this could be fixed passing the correctBLEServiceUUID -
After the phone Bluetooth is turned off and back on the board can't be reconnected. It must be unpaired and paired from scratch (which defeats the original purpose and is not very user friendly)
-
This way any phone could see the board and connect to it. To fix this I thought that I could make the advertise last only a few seconds (just like a pairing mode in many Bluetooth devices)
I would like to add that the security issues brought by this approach are not a concern since this program will not be used in security critical applications.
If you have any idea on how to solve these issues I might consider going back to the BLE solution
Thanks in advance to whoever decides to help me
.