简体   繁体   English

尝试访问 ESP32 上的 RSSI 信息以进行数据记录

[英]Trying to access RSSI information on ESP32 for datalogging

As part of a project I'm comparing the effectiveness of different wireless communication methods for measuring distance.作为项目的一部分,我正在比较不同无线通信方法测量距离的有效性。 I am using RSSI for all forms (I'm aware it's imprecise but the extent of which is the point of the project).我对所有 forms 使用 RSSI(我知道它不精确,但其程度是项目的重点)。 I'm planning on comparing Bluetooth Trad, BLE, Wi-Fi and ESP-NOW.我打算比较蓝牙 Trad、BLE、Wi-Fi 和 ESP-NOW。

Currently Wi-Fi and ESP-NOW are working and I'm working on Bluetooth trad.目前 Wi-Fi 和 ESP-NOW 正在工作,我正在研究蓝牙传统。 I'm able to use the inbuilt examples to find my device and print it to the console.我可以使用内置示例找到我的设备并将其打印到控制台。 However, how can I access the data stored within BTScanResults.但是,如何访问存储在 BTScanResults 中的数据。

For example the pseudo would be:例如,伪将是:

if name == "ESP32test":
    Serial print rssi of name:
delay(1s)

The reason it needs to be in this format is the serial output is being taken directly into Microsoft Excel for data formatting and there will be thousands of data points so manual recording is not feasible.它需要采用这种格式的原因是串行 output 被直接带入 Microsoft Excel 进行数据格式化,并且将有数千个数据点,因此手动记录是不可行的。

Thanks for any help, Matt感谢您的帮助,马特

控制台输出

I had made a little program to log all Blutooth devices advertised in the vicinity.我做了一个小程序来记录附近所有广告的蓝牙设备。 To find the name and the RSSI I used:要查找我使用的名称和 RSSI:

String(advertisedDevice.getName().c_str());字符串(advertisedDevice.getName().c_str()); to get the name得到名字

and

advertisedDevice.getRSSI();广告设备.getRSSI(); to get the RSSI.获取RSSI。

Below is how it looks in the actual code, with only the essentials left in for brevity.下面是它在实际代码中的样子,为简洁起见,只留下了要点。 BleLog[] is just a struct array that holds a table of results. BleLog[] 只是一个包含结果表的结构数组。

It works in general but for some reason the RSSI is reported most of the time but not always.它通常可以工作,但由于某种原因,大多数时间都会报告 RSSI,但并非总是如此。

class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks
{
    void onResult(BLEAdvertisedDevice advertisedDevice)
    {
      printResult(advertisedDevice);                                
      parseResult(advertisedDevice);                                  
        
        
        .............
    }
};


void parseResult(BLEAdvertisedDevice advertisedDevice)
{
  ......................
  
  // Fill in the data for the log entry
  BleLog[foundAddress].occurences      = oldBleLog[foundAddress].occurences+1;
  BleLog[foundAddress].lastRssi        = advertisedDevice.getRSSI();
  BleLog[foundAddress].lastSeen        = millis();
  BleLog[foundAddress].deviceName      = String(advertisedDevice.getName().c_str());
  BleLog[foundAddress].addressType     = advertisedDevice.getAddressType();
  
  ...................
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM