//This example code is in the Public Domain (or CC0 licensed, at your option.)
//By Evandro Copercini - 2018
//
//This example creates a bridge between Serial and Classical Bluetooth (SPP)
//and also demonstrate that SerialBT have the same functionalities of a normal Serial
#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
#if !defined(CONFIG_BT_SPP_ENABLED)
#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip.
#endif
BluetoothSerialSerialBT;
SerialBTを、BluetoothSerialクラスの変数として定義します。
setup()
19
20
21
22
23
24
voidsetup(){Serial.begin(115200);SerialBT.begin("ESP32test");//Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");}