How to connect to an ESP32 development board via Bluetooth on your Mac

When you are trying to build a ESP32 project that uses Bluetooth to receive from or send data to another device on Mac, you may want to use your Mac to connect to your ESP32 board to test Bluetooth connectivity.

In this case, you will need to first connect your Mac with the ESP32 development board via Bluetooth.

So how can you do that?

In case you need it, this is how to connect to an ESP32 development board via Bluetooth on your Mac.

Setting up your ESP32 development board to accept Bluetooth connections

Before your Mac can discover ESP32 Bluetooth, you need to get ESP32 to turn on Bluetooth. In order to do so, upload the following Arduino Sketch to your ESP32 development board:

#include "BluetoothSerial.h"
 
BluetoothSerial SerialBT;
  
void setup()
{
  SerialBT.begin("ESP32test");
  delay(1000);
}
  
void loop()
{
  String inputFromOtherSide;
  if (SerialBT.available()) {
    inputFromOtherSide = SerialBT.readString();
    SerialBT.println("You had entered: ");
    SerialBT.println(inputFromOtherSide);
  }
}

As I had mentioned in the guide on how to get your ESP32 development board to communicate with another device over Bluetooth Serial, this Arduino Sketch will echo back whatever message that it receives from the Bluetooth connection.

Connecting to your ESP32 development board via Bluetooth on your Mac

Once the ESP32 board starts to run your Arduino sketch, you are ready to connect to it.

First, go to System Preferences:

My Mac system preferences window as of 20190531

After you had clicked on Bluetooth and turned on Bluetooth of your Mac, you should find your ESP32 appearing as ESP32test:

My Mac Bluetooth window show ESP32test as an available Bluetooth device

After you click on Connect, your Mac will display your ESP32 as Connected:

My Mac Bluetooth window showing ESP32test as connected

At this point in time, you will then be able to use a program on your Mac to communicate with your ESP32 device via Bluetooth.

When no program is using that Bluetooth connection, the status will change to Not Connected.

My Mac Bluetooth window showing ESP32test as not connected

Once you start a program to use that Bluetooth connection, the status will change back to Connected.

About Clivant

Clivant a.k.a Chai Heng enjoys composing software and building systems to serve people. He owns techcoil.com and hopes that whatever he had written and built so far had benefited people. All views expressed belongs to him and are not representative of the company that he works/worked for.