-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathBTserialcomm.ino
41 lines (33 loc) · 978 Bytes
/
BTserialcomm.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// upload this sketch to facilitate AT command communication betweeen phone and device.
///////////////////////////////////////////////////////////////////////////////////////////////////////
#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() {
Serial2.begin(9600, SERIAL_8N1, 16, 17);
Serial.begin(115200);
SerialBT.begin("ESP32MORD"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
if (Serial2.available()) {
SerialBT.write(Serial2.read());
}
if (SerialBT.available()) {
Serial2.write(SerialBT.read());
}
delay(20);
}
//#include <esp_bt.h>
//
//void setup()
//{
// btStop();
// esp_bt_controller_disable();
//
//}
//
//void loop()
//{}