【发布时间】:2021-05-30 11:44:03
【问题描述】:
现在制作一个通过经典蓝牙与 ESP32 交互的应用。我正在读取霍尔传感器并在其值高于 0 时发送 0,在低于 0 时发送 1。现在,当我在 ai2 中注册该 1 并且因此在应用程序中发生一些事情时,ESP32 发生故障或其他什么。我停止从串行监视器中的传感器获取读数,并且蓝牙连接停止。似乎整个 esp 都停在了原地。我也没有向 ESP32 发送任何数据,只是从中接收数据。 esp代码超级小,但app代码不多。 解决此问题的唯一方法是重置 esp,这在我的用例中并不可行。有什么办法解决这个问题?
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("Sport Spel"); //Bluetooth device name
}
void loop() {
Serial.println(hallRead());
if (SerialBT.available)
{
if (hallRead() < 0)
{
SerialBT.write('1');
}
else
{
SerialBT.write('0');
}
delay(20);
}
}
【问题讨论】:
-
请不要链接到 StackOverflow 问题中的图片。链接往往会停止工作,这使得问题毫无意义。代码图片也不能搜索,文字可以。而且很多人在阅读图片中的代码时有困难。
标签: android arduino bluetooth esp32