Hey guys,
I'm doing a project that consists on tracking BLE devices, using the arduino nano 33 IOT.
My idea was to do this using the BLE module and get the information that I want from the RSSI that the arduino retrieves.
I've used this code to get me started:
#include <ArduinoBLE.h>
void setup() {
Serial.begin(9600);
while (!Serial);
// begin initialization
//int static MeasuredPower=-69; //Measured Power at 1m from the Tx in dBm
//int static N=3; //N in range 2-4, it depends on environment and 2 for low strength, 4 for high stregth of signal
//int distance;
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1);
}
BLE.setLocalName("Detect"); // Local name for the BLE Device
Serial.println("BLE Central scan callback");
// set the discovered event handle
BLE.setEventHandler(BLEDiscovered, bleCentralDiscoverHandler);
// start scanning for peripherals with duplicates
BLE.scan(true);
}
void loop() {
// poll the central for events
BLE.poll();
}
void bleCentralDiscoverHandler(BLEDevice peripheral) {
// int static MeasuredPower=-82; //Measured Power at 1m from the Tx in dBm
// int static N=3; //N in range 2-4, it depends on environment and 2 for low strength, 4 for high stregth of signal
// discovered a peripheral
Serial.println("Discovered a peripheral");
Serial.println("-----------------------");
// print address
Serial.print("Address: ");
Serial.println(peripheral.address());
// print the local name, if present
if (peripheral.hasLocalName()) {
Serial.print("Local Name: ");
Serial.println(peripheral.localName());
}
// print the advertised service UUIDs, if present
if (peripheral.hasAdvertisedServiceUuid()) {
Serial.print("Service UUIDs: ");
for (int i = 0; i < peripheral.advertisedServiceUuidCount(); i++) {
Serial.print(peripheral.advertisedServiceUuid(i));
Serial.print(" ");
}
Serial.println();
}
// print the RSSI
Serial.print("RSSI: ");
Serial.println(peripheral.rssi());
//Calculation of the distance
// int RssiP=peripheral.rssi();
// double distance=pow(10, ( abs( MeasuredPower ) - RssiP ) / (10*N) );
//Serial.print("Distance:");
//Serial.println(distance);
Serial.println();
}
I can find the peripherals (such as my Mi band 3) quite easily, but no sign of my Smartphone (which I am sure that it has BLE capabilities).
Any help would be appreciated. Thanks
manuvader:
but no sign of my Smartphone (which I am sure that it has BLE capabilities).
Well, I guess now might be a good time to gather up your courage, bight the bullet, and ascertain that that is indeed the case. The next thing to do is ensure that the app you are using is BLE compatible. Some aren't. I imagine all that are will do both and will tell you about it. An example is that by Kai Morisch. The connection is made through the app, not pair through the phone settings.
manuvader:
I'm doing a project that consists on tracking BLE devices, using the arduino nano 33 IOT.
Why do you want to track BLE devices?
manuvader:
My idea was to do this using the BLE module and get the information that I want from the RSSI that the arduino retrieves.
Take a smartphone app like BLE Scanner and look at the RSSI information. If you have one device, you can use RSSI relatively to see changes in distance. I wrote a short Geiger counter example using RSSI a long time ago. It was fun for 5 minutes but not more useful. Once you have a collection of BLE devices and a real environment e.g., with walls RSSI become useless for comparing their distance.
manuvader:
.. but no sign of my Smartphone (which I am sure that it has BLE capabilities).
Literally, because of people like you all modern smartphones have been changed to avoid tracking. You can let your sketch know what BLE MAC address your smartphone has in that moment but your smartphone will change the address on a regular basis randomly. This process is proprietary, undocumented and can change at any time.
You can create a tracking device yourself or buy one. That is your choice.
Because smartphones are everywhere and used for other purposes it is better that they make themselves hard to track.
You could write an app that uses BLE to make itself traceable by advertising a unique UUID. I am not sure whether that app would work on iOS when the app is not running in the foreground. You will need to consult the Apple terms and conditions. I guess on Android you can do what you want.
Klaus_K:
Welcome to the forum.
Why do you want to track BLE devices?
Take a smartphone app like BLE Scanner and look at the RSSI information. If you have one device, you can use RSSI relatively to see changes in distance. I wrote a short Geiger counter example using RSSI a long time ago. It was fun for 5 minutes but not more useful. Once you have a collection of BLE devices and a real environment e.g., with walls RSSI become useless for comparing their distance.
Literally, because of people like you all modern smartphones have been changed to avoid tracking. You can let your sketch know what BLE MAC address your smartphone has in that moment but your smartphone will change the address on a regular basis randomly. This process is proprietary, undocumented and can change at any time.
You can create a tracking device yourself or buy one. That is your choice.
Because smartphones are everywhere and used for other purposes it is better that they make themselves hard to track.
You could write an app that uses BLE to make itself traceable by advertising a unique UUID. I am not sure whether that app would work on iOS when the app is not running in the foreground. You will need to consult the Apple terms and conditions. I guess on Android you can do what you want.
This is a project for a subject called "Industrial Project", on which we do projects requested by companies.
This particular company asked my team for a way to track BLE devices, in a way that you can't track who is in possession of the device (complying with the GPDR norms).
I'm no hacker, I just want to do my project
However, from what I've gathered, there is no way of tracking an android phone without an App, so I'll have to tackle this problem from another angle.
Thank you for your answers !