Bluetooth on Your ESP32

Bluetooth Terminal Application

Execute The Project on Android

Exchange Data Using Bluetooth Serial

// Load libraries
#include "BluetoothSerial.h"
// Check if Bluetooth configs are enabled
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
// Bluetooth Serial object
BluetoothSerial SerialBT;
// GPIO where LED is connected to
const int ledPin = 23;
// Handle received and sent messages
String message = "";
void setup() {
pinMode(ledPin, OUTPUT);
// Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
void loop() {
// Read received messages (LED control command)
if (SerialBT.available()){
char incomingChar =;
if (incomingChar != '\n'){
message += String(incomingChar);
message = "";
// Check received message and control output accordingly
if (message =="led_on"){
digitalWrite(ledPin, HIGH);
else if (message =="led_off"){
digitalWrite(ledPin, LOW);

Bluetooth Low Energy

pCharacteristic->setValue(“Hello, back again with ESP32 tutorial!”);

Feel free to contact me at for any questions or advice about this tutorial. Thank You!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store