ESP32-S 보드는 wifi, BT 두 종류의 통신을 할 수 있습니다. 아래 소스는 부르투스 통신을 해봅니다.
* 컴파일이 끝나고 업로딩 시작될때 오른쪽 버튼을 터치해줍니다.
#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);
}
#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);
}
폰에서 페어링된 부르투스 장치들입니다.
ESP32test 장치명이 등록되었습니다.

시리얼 통신으로 보낸 문자들을 수신문입니다.
'코딩 놀이' 카테고리의 다른 글
CNC Shield_V4 , BT06 bluetooth, appInventor(7) (0) | 2024.11.23 |
---|---|
esp32 LED_BUILTIN OnOff(6) (0) | 2024.11.22 |
arduino substring() 함수와 배열(집합) 응용 (4) (0) | 2024.11.17 |
arduino 배열 (3) (0) | 2024.11.16 |
arduino substring() , substring(a,b)함수 (2) (0) | 2024.11.16 |