UART is a Universal Asynchronous Receiver/Transmitter, The main purpose is to transmit and receive serial data. The serial communication stands for sequential transmission or reception of data of one bit at a time through the bus or communication channel. And in ESP32 microcontroller, there are some UART controllers are exist and which are compatible with different UART devices. The UART controllers are UART0, UART1, and UART2. In this tutorial, the rxValue is the data received and txValue is the data to be sent. In this example, just a byte is incremented in every second.

BLE UART on ESP32 Controller

The ESP32 controller has features such as WiFi, Bluetooth, and BLE. BLE ie Bluetooth Low Energy which mainly used for short distance communication of low width small amount of data and its make very less power.BLE on ESP32 has a serial communication property so this  UART feature can be used to exchange sequence of data between the ESP32 controller and connected device.
The libraries used here are,

Define service UUID and characteristics UUID for Tx and Rx.

The transmitted data on one end is the received data on the other end and the RX UUID characteristics in the app are the TX UUID characteristics of the ESP32 and vice versa. Next, let’s look at the callback function that handles the Bluetooth connection status:

To do all these set the “deviceConnected” flag as true or false when you connect or disconnect from the ESP32. Similarly, there is a callback function that handles the receiving data sent by the client (phone)

Initialize the ESP32 as a BLE device and set its name and create BLE server.

Create BLE service using the service UUID.

Add characteristics.PROPERTY_WRITE, PROPERTY_NOTIFY are the properties of the characteristics.

Start BLE service

Start advertising

Sent the txValue in every second after the device connected.

BLE UART on ESP32 Controller(1)

BLE UART on ESP32 Controller(2)

Spread the love, share this