ESP32/Bluetooth/63. Classic Bluetooth serial
Your chip
Your language
Not on your chip
The ESP32-S3 cannot do this.

Nothing on this page will run on a bare S3. The page below is unchanged — read it if you are planning ahead or using a different board.

Bluetooth · 63 of 81

Classic Bluetooth serial

Four lines of code and a phone terminal app, which is why it is still in every tutorial. Also - only the original ESP32 has it, no iPhone can see it, and it eats a megabyte of flash. Know that before you design around it.

/esp32/classic-bluetooth-serial · arduino · S3

Three ways to get text to a phone

Bluetooth Serial (SPP)
ESP32 only
Works on iPhone
no
Chips
ESP32 only
While connected
32 mA
Four lines of code, an Android terminal app, and no iPhone will ever see it. Apple does not expose SPP to apps. Neither does any ESP32 after the original — the S3, C3, C6 and P4 have BLE only, so a design built on this cannot follow the chip you can actually buy. Fine for a bench tool you use yourself; a trap in anything you hand to someone else.

When it is still the right answer

A bench tool you use yourself, on an Android phone, on a board you already own. It takes four lines and it works. There is no shame in that.

When it is not

Anything you hand to somebody else. The iPhone gap alone rules it out, and the chip situation is worse: every ESP32 released since the original has BLE only, so a design built on classic Bluetooth cannot follow the parts you can actually buy. Reach for the Nordic UART service over BLE instead — it is a little more code and it has no ceiling.

On your S3
ChipXtensa LX7 · 2 × 240 MHz
Board settingESP32S3 Dev Module
Default I2CSDA 8 · SCL 9
Watch out forThe port vanishes after upload

The code

This really is the whole thing. It behaves exactly like Serial, which is the appeal and also the reason people build products on it before finding out what it costs.

bt_serial.ino
#include <BluetoothSerial.h>

BluetoothSerial SerialBT;

void setup() {
  Serial.begin(115200);
  SerialBT.begin("Robot");        // the name that shows up when pairing
}

void loop() {
  if (SerialBT.available()) {
    char c = SerialBT.read();
    Serial.write(c);              // forward to the USB console
    SerialBT.printf("got %c\n", c);
  }
}

Compiles only on the original ESP32. On an S3, C3, C6 or P4 the header does not exist, because the hardware does not.

When it does not work

BluetoothSerial.h not found

Your chip has no classic Bluetooth. Only the original ESP32 does. Use BLE with the Nordic UART service instead - it works everywhere and on both phone platforms.

The device is invisible to an iPhone

Apple does not expose classic serial profiles to apps. There is no workaround. Any project that must reach an iPhone needs BLE.

The sketch will not fit

The classic stack is over a megabyte before your code exists. Enabling both classic and BLE at once rarely fits a 4 MB board with OTA.

Pairing works once and then fails

The phone remembers the link key and the board forgot it after a reflash. Remove the device from the phone's Bluetooth settings and pair again.

Where this goes next

Both Bluetooth radios covered. Next: the Wi-Fi radio used without a network at all, two milliseconds a message.

ESP-NOW

Edit this page — content/esp32/classic-bluetooth-serial.mdx

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse ESP32 on the forum