I am trying to make a Bluetooth proximity sensor that turns on a GPIO pin on my ESP32 dev board when a bluetooth device is in range of my set cutoff, and if that device's name matches my specified name
I had a look at this youtube video and am trying to adapt the code to work for my needs, but I'm not having much luck
That seems to be a problem as well, if I try to print the name, nothing comes up in the serial monitor, I've checked for correct baud rates and everything, but no serial output
My thoughts exactly, however, refering to the code that I adapted from, the original code (on the YouTube video) works just fine, and lights up my led when brought close to my Bluetooth device
So as you can see, i set it up to print the number of devices that it picks up, it returns 1 but i have 3 active bluetooth devices around me, my laptop, my phone, and a bluetooth controller
You could try to see if that changes anything, but I doubt. Usually you would be able to see the name of the devices before you pair / connect them.
EDIT1: Earlier you said, that some other code you've tried works, please post that code or a link to it.
EDIT2: If the code you used is from the video, then there is no identification by name, it just checks if there is any device within a certain range. You may have luck identifying a device by its device- or service-UUID, but make sure that it is unique to the device.
I just had a look and it seems that the address gets assigned by the server and thus changes on every reboot. It looks like i have use the getName function
I did some more tests and i used:
device.toString();
That seems to dump all the data from the found devices, however, the very first thing listed by this method is the name, and guess what, both devices show nothing on the name.
Honestly I dont know why, I am using nRF Connect for my phone and my laptop as my second device, they seem to find each other perfectly with names and everything but the ESP32 wont seem to find the names