1. 安装ESP32开发板蓝牙库
2. 打开示例文件:
3.代码就这么简单,这才是Arduino的风格
#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("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
Serial.write(SerialBT.read());
}
delay(20);.
4.开发板加载复位:
调试打印启动
5. 手机端打开蓝牙调试串口
点击连接ESP32TEST(当然,可以在程序里改成你想要的名字)然后就可以畅快的透传了!
要嵌入其他应用,请随意。