BLEDevice::init("");
pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get foundDevices faster
pBLEScan->setInterval(100);
pBLEScan->setWindow(99); // less or equal setInterval value
}
void loop() {
// put your main code here, to run repeatedly:
BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
Serial.print("Devices found: ");
Serial.println(foundDevices.getCount());
Serial.println("Scan done!");
pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
delay(2000);
}
Im new to IOT and not great on all the lingo or anything yet, but this is for a project for class and can really use any help!
I can compile, link and run the code of post # 1 on an ESP-WROOM-32
what target board have you specified?
click File>Preferences and the Show verbose output during compilation
recomple and upload the full error messages?
And it wont let me paste the whole error code but here's part of it:
BLE_scan:10:1: error: 'BLEScan' does not name a type
BLEScan* pBLEScan;
^~~~~~~
BLE_scan:12:72: error: expected class-name before '{' token
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
^
BLE_scan:13:19: error: 'BLEAdvertisedDevice' has not been declared
void onResult(BLEAdvertisedDevice advertisedDevice) {
^~~~~~~~~~~~~~~~~~~
/Users/meganiversen/Documents/Arduino/libraries/doggy-doorbell-main/BLE_scan/BLE_scan.ino: In member function 'void MyAdvertisedDeviceCallbacks::onResult(int)':
BLE_scan:14:35: error: request for member 'getRSSI' in 'advertisedDevice', which is of non-class type 'int'
int rssi = advertisedDevice.getRSSI();
^~~~~~~
BLE_scan:16:68: error: request for member 'getServiceUUID' in 'advertisedDevice', which is of non-class type 'int'
Serial.printf("Advertised Device: %s \n", advertisedDevice.getServiceUUID().toString().c_str());
^~~~~~~~~~~~~~
BLE_scan:19:41: error: request for member 'getRSSI' in 'advertisedDevice', which is of non-class type 'int'
Serial.println(advertisedDevice.getRSSI());
^~~~~~~
/Users/meganiversen/Documents/Arduino/libraries/doggy-doorbell-main/BLE_scan/BLE_scan.ino: In function 'void setup()':
BLE_scan:28:3: error: 'BLEDevice' has not been declared
BLEDevice::init("");
^~~~~~~~~
BLE_scan:29:3: error: 'pBLEScan' was not declared in this scope
pBLEScan = BLEDevice::getScan(); //create new scan
^~~~~~~~
BLE_scan:29:14: error: 'BLEDevice' has not been declared
pBLEScan = BLEDevice::getScan(); //create new scan
^~~~~~~~~
/Users/meganiversen/Documents/Arduino/libraries/doggy-doorbell-main/BLE_scan/BLE_scan.ino: In function 'void loop()':
BLE_scan:38:3: error: 'BLEScanResults' was not declared in this scope
BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
^~~~~~~~~~~~~~
BLE_scan:40:18: error: 'foundDevices' was not declared in this scope
Serial.println(foundDevices.getCount());
^~~~~~~~~~~~
BLE_scan:42:3: error: 'pBLEScan' was not declared in this scope
pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
^~~~~~~~
Multiple libraries were found for "BLEDevice.h"
Used: /Users/meganiversen/Documents/Arduino/libraries/ESP32_BLE_Arduino
Not used: /Users/meganiversen/Library/Arduino15/packages/esp32/hardware/esp32/2.0.4/libraries/BLE
Not used: /Users/meganiversen/Documents/Arduino/libraries/ESP32_BLE_Arduino-master
Using library ESP32_BLE_Arduino at version 1.0.1 in folder: /Users/meganiversen/Documents/Arduino/libraries/ESP32_BLE_Arduino
exit status 1
'BLEScan' does not name a type
the tools>Board setting when you had the original error in post # 1
if you set the Tools>Board to ESP32 dev module can you run the File>Examples>Basic>Blink
I have neither of those libraries - try deleting
/Users/meganiversen/Library/Arduino15/packages/esp32/hardware/esp32/2.0.4/libraries/BLE
The original board setting was ESP32S2 Dev and my Arduino IDE is 1.8.19
This is the error I receive when I try to run blink:
private/var/folders/89/sq266yld7_vcclszstf0ggyc0000gn/T/AppTranslocation/0CFAB70D-0C80-4C8C-99CB-16862A37917D/d/Arduino.app/Contents/Java/examples/01.Basics/Blink/Blink.ino: In function 'void setup()':
Blink:28:11: error: 'LED_BUILTIN' was not declared in this scope
pinMode(LED_BUILTIN, OUTPUT);
^~~~~~~~~~~
/private/var/folders/89/sq266yld7_vcclszstf0ggyc0000gn/T/AppTranslocation/0CFAB70D-0C80-4C8C-99CB-16862A37917D/d/Arduino.app/Contents/Java/examples/01.Basics/Blink/Blink.ino: In function 'void loop()':
Blink:33:16: error: 'LED_BUILTIN' was not declared in this scope
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
^~~~~~~~~~~
exit status 1
'LED_BUILTIN' was not declared in this scope
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
probably the reason why you had the error in post # 1 was that the ESP32S2 does not have bluetooth
however, setting the Tools>Board to ESP32 dev module should compile the BLEscan
can you post the full error message
You have an out-of-date (v1.0.1) library installed in:
/Users/meganiversen/Documents/Arduino/libraries/ESP32_BLE_Arduino
and
/Users/meganiversen/Documents/Arduino/libraries/ESP32_BLE_Arduino-master
Delete those two directories to allow the use of the version that came with the ESP32 distribution:
/Users/meganiversen/Library/Arduino15/packages/esp32/hardware/esp32/2.0.4/libraries/BLE
Navigate to your Documents/Arduino/libraries folder, click on the folder (directory) name to select it, and press Command-delete to delete the folder (directory).
I am now having trouble getting the board to load. Im using ESP-WROOM-32 and was told to use the ESP32 Dev Module board selection but am unsure what is wrong
sketch:
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
int scanTime = 10; //In seconds
int minimumDeviceThreshold = -60;
BLEScan* pBLEScan;
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) {
int rssi = advertisedDevice.getRSSI();
if(rssi > minimumDeviceThreshold){
Serial.printf("Advertised Device: %s \n", advertisedDevice.getServiceUUID().toString().c_str());
//Signal strength
Serial.print(" RSSI: ");
Serial.println(advertisedDevice.getRSSI());
}
}
};
void setup() {
Serial.begin(115200);
Serial.println("Scanning...");
BLEDevice::init("");
pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get foundDevices faster
pBLEScan->setInterval(100);
pBLEScan->setWindow(99); // less or equal setInterval value
}
void loop() {
// put your main code here, to run repeatedly:
BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
Serial.print("Devices found: ");
Serial.println(foundDevices.getCount());
Serial.println("Scan done!");
pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
delay(2000);
}
error message:
in file included from /var/folders/89/sq266yld7_vcclszstf0ggyc0000gn/T/arduino_build_786820/sketch/BLE_scan.ino.cpp:1:0:
/Users/meganiversen/Library/Arduino15/packages/esp32/hardware/esp32/2.0.5/cores/esp32/Arduino.h:184:12: error: 'std::round' has not been declared
using std::round;
^
Using library BLE at version 2.0.0 in folder: /Users/meganiversen/Library/Arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/BLE
exit status 1
Error compiling for board ESP32 Dev Module.
The sketch compiles without error for me. IDE 1.8.19 and 2.0.2. We have the same version of ESP32 support (2.0.5) so I don't know what went wrong. Have you got any other libraries installed that conflict with the built-in libraries? In the verbose compile output look for "Multiple libraries were found for". Delete any in /Users/meganiversen/Documents/Arduino/libraries that are being used in place of libraries in /Users/meganiversen/Library/Arduino15/packages/esp32/