【问题标题】:How do I read/connect BLE beacon on ESP32 with Arduino IDE?如何使用 Arduino IDE 读取/连接 ESP32 上的 BLE 信标?
【发布时间】:2019-10-29 10:46:12
【问题描述】:

我希望将我的 ESP32 连接到与 Arduino 配对的 JDY-08 以用于一些智能传感器应用。我想读取在 iBeacon 模式下设置的 JDY-08 发送的整数。我尝试了库 ESP32 附带的示例,在 ESP32_BLE_Arduino 中名为 BLE_CLient。该代码可以找到我正在使用的设备,它是 JDY-08 与 Arduino UNO 的结合。我使用我的 nRF 应用程序检查服务和字符 UUID。谁能告诉我哪里错了?

JDY-08 代码:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);

void setup(){
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop(){
  float temperature = 0.0;
  int sample;
  float ten_samples = 0.0;

  for (sample = 0; sample < 10; sample++) {
      temperature = ((float)analogRead(A0) * 5.0 / 1024.0) - 0.5;
      temperature = temperature / 0.01;
      delay(100);
      ten_samples = ten_samples + temperature;
  }

  temperature = ten_samples / 10.0;
  int temperature_translate = (int)temperature;
  mySerial.print(temperature_translate);
  Serial.print(temperature_translate);
  ten_samples = 0.0;

  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

【问题讨论】:

    标签: iot arduino-ide esp32


    【解决方案1】:

    使用 WEB 蓝牙 API 做一些检查,使用它你可以接收你从你的 ESP32 发送的数据通知。

    所以,首先,看看您是否可以使用此 Web 界面接收来自 ESP32 的数据: https://googlechrome.github.io/samples/web-bluetooth/notifications.html

    确保正确设置 UUID,我发现对于 JDY-08 之类的设备,短 UUID 标识为 0x35655 可能不够,您需要获取它们的长版本,它们看起来更像 0000180a-0000- 1000-8000-00805f9b34fb,这也可能发生在您的 ESP32 UUID 上,因此请使用以下工具检查:

    https://googlechrome.github.io/samples/web-bluetooth/

    在简历中:

    • 使用 WEB 蓝牙 API 获取信息并连接到设备

    • 仔细检查 UUID 的服务和特征

    如果这可行,但您仍然无法使用 JDY-08 接收:

    • 检查 TX 和 RX 位置,它们可能颠倒了

    问题不在发布的代码上。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-21
      • 2021-11-01
      • 2022-12-24
      • 1970-01-01
      相关资源
      最近更新 更多