我正在研究ESP 32-Wroom-32D微控制器,并使用内置的经典蓝牙连接到android设备。目前,微控制器的范围约为70 m,我希望将其减小到5-6米左右。有什么可能的方法来减小蓝牙范围。请找到代码段。
#include "DHT.h"
#include "BluetoothSerial.h"
#include "BLEDevice.h"
#include <esp_bt.h>
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
#define DHTPIN 23
#define DHTTYPE DHT22 // DHT 22
DHT dht(DHTPIN, DHTTYPE);
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
dht.begin();
//esp_power_level_t(ESP_PWR_LVL_N12);
}
void loop() {
if (SerialBT.available() == 0);
esp_power_level_t(ESP_PWR_LVL_N12);
Serial.println(ESP_PWR_LVL_N12);
delay(2000);
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
SerialBT.print(f);
//Serial.println(f);
delay(2000);
}