I am making project and I want to make ble scan of ESP8266. Also I want to get RSSI value But I only want to get the RSSI values of the devices of the mac addresses I want.
I wrote ESP8266 code but It is not working. Please.Can you help me?
Code link : https://we.tl/t-oVfeozM7YX
@ercntrn28, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project.
Please post your code using code tags as described in How to get the best out of this forum.
It was might be useful for helpers to help you.
Thank you very much. I needn't make anything.Anymore Can I get answer to my ask Right?
Not going to download code. Post it here, inside code tags.
Read the forum guidelines.
The ESP8266 doesn't have BLE as far as I know.
The ESP32 does.
I hope you're not going to use RSSI for distance measurements.
Leo..
"I hope you're not fantasising to use RSSI for distance measurements."
I have to make because There is a Master degree project. I will use trileteration method. I don't get RSSI value. Please Can you examine code?
Code drive link: sketch_may29c.ino - Google Drive
Whatever that is, it sounds as if you are imagining that you could use RSSI to indicate distance.
It does not indicate distance.
Not to any usable degree.
But I have to, actually, it doesn't need to be very determined.There are friends who wrote a master's thesis on this subject.
Is there a suggestion about code? Always I don't make distance calculator. I will take RSSI value over serial port. I will calcuator at Pyhton .
In addition, the ESP8266 can only scan 1-2 meters. How can we increase this scanning distance?
/*
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
Ported to Arduino ESP32 by Evandro Copercini
*/
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
//UUIDs of what server we want to filtering.
static BLEUUID serviceUUID_A("0000fdee-0000-1000-8000-00805f9b34fb");
static BLEUUID serviceUUID_B("4fafc201-1fb5-459e-8fcc-c5c9c331914b");
static BLEUUID serviceUUID_C("407fc20d-d5f5-4176-bb4d-cc9c1968f9f6");
static BLEUUID serviceUUID_D("14fb4533-1997-4bbe-a567-554d2da89738");
//Set "Scan_x" for condition statement.
static BLEAdvertisedDevice* Scan_A ;
static BLEAdvertisedDevice* Scan_B ;
static BLEAdvertisedDevice* Scan_C ;
static BLEAdvertisedDevice* Scan_D ;
//Set "Found_x" for condition statement.
static bool Found_A = false;
static bool Found_B = false;
static bool Found_C = false;
static bool Found_D = false;
//Set scanTime to forever "scanTime = 0".
int scanTime = 1; //In seconds
//Function when found device and can use in void loop(); for do other things.
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) {
if (advertisedDevice.isAdvertisingService(serviceUUID_A)){
if(Scan_A == nullptr){
Found_A = true;
Scan_A = new BLEAdvertisedDevice(advertisedDevice);
}
}
if (advertisedDevice.isAdvertisingService(serviceUUID_B)){
if(Scan_B == nullptr){
Found_B = true;
Scan_B = new BLEAdvertisedDevice(advertisedDevice);
}
}
}
};
void setup() {
Serial.begin(115200);
Serial.println("Scanning...");
BLEDevice::init("");
BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
pBLEScan->start(scanTime);
pBLEScan->setInterval(100); // set Scan interval
pBLEScan->setWindow(99); // less or equal setInterval value
}
void loop() {
if(Found_A){
int Rssi_A = Scan_A->getRSSI();
Serial.printf("RSSI A: %d \t", Rssi_A);
delete Scan_A;
Scan_A = nullptr;
Found_A = false;
delay(500);
}
if(Found_B){
int Rssi_B = Scan_B->getRSSI();
Serial.printf("RSSI B: %d \t", Rssi_B);
delete Scan_B;
Scan_B = nullptr;
Found_B = false;
delay(500);
}
Serial.print("\n");
}
I found such a code, but I can't get the RSSI values.Normally I need to find the RSSI values of the devices with the UUID.
WiFi range of the ESP8266 is about 10-20m. More if you use ESP-NOW.
BLE range of the ESP8266 = zero, because it doesn't have Bluetooth.
So did you already switch to the ESP32.
Leo..
Can you help me about this code? Because I don't appear anything issue.
I am using ESP32-WROOM device .
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.