Modern embedded systems now require wireless communication as a basic feature because it enables smooth data exchange between devices over short distances. Because of its high availability, low power consumption, and simplicity of integration, Bluetooth in particular is a popular option for wireless communication. Based on the ARM Cortex-M3 core, the LPC1768 microcontroller has a wide range of connectivity options, such as UART (Universal Asynchronous Receiver/Transmitter) interfaces, which facilitate Bluetooth module interface.
We will demonstrate how to integrate Bluetooth with the LPC1768 microcontroller for wireless communication in this document. We’ll make use of a popular Bluetooth module that allows serial communication via UART, like the HC-05.
Bluetooth is a short-range wireless communication technology that operates in the 2.4 GHz ISM band. It is perfect for applications like data transfer, sensor networks, and remote control systems because it enables device communication without the need for physical cables. Because it supports both master and slave modes and communicates via UART, the HC-05 Bluetooth module is among the most widely used Bluetooth modules for embedded systems. Using UART, the module can be easily interfaced with microcontrollers such as the LPC1768.
The LPC1768 microcontroller needs the following parts in order to integrate Bluetooth:
Development Board for LPC1768 (like NXP board)
Connecting Wires: To join the LPC1768 board and the HC-05 Bluetooth module.
Source of Power: Make sure the Bluetooth module and the LPC1768 board are powered on correctly. Bluetooth-enabled PC or
Smartphones: This one Connect to the LPC1768 microcontroller through the HC-05 module.
Through the UART interface, the HC-05 Bluetooth module and the LPC1768 exchange data. The HC-05 and LPC1768 are connected by the following crucial pins:
VCC: Attach to either 3.3V or 5V, depending on the module’s operating voltage.
GND: Attach to the earth.
TX: Send information to the LPC1768 RX pin from the HC-05 module.
RX: Get information from the LPC1768 TX pin and send it to the HC-05 module.
For instance:
LPC1768 RX → HC-05 TX (P0.3)
LPC1768 TX → HC-05 RX (P0.2)
VCC HC-05 → either 3.3V or 5V
HC-05 Ground → GND.
The two UART interfaces (UART0 and UART1) on the LPC1768 microcontroller are perfect for serial communication with the HC-05 module.
UART0 will be used for communication in this example.
The following are the steps in UART configuration: determining the baud rate, which is normally 9600 bps for the HC-05.
Configuration of the data, stop, and parity bits to allow UART transferring and recevieing.
The setup code to connect UART0 to the HC-05 is as follows:
The Line Control Register, or U0LCR, is used to set up parity, stop bits, and data bits.
The FIFO Control Register, or U0FCR, is used to set up FIFO buffers for improved efficiency.
The Transmit Holding Register, or U0THR, is used for UART data transmission. The Receive Buffer Register, or U0RBR, is used to read incoming UART data.
The next step is to use the UART interface to implement the logic for Bluetooth data transmission and reception. The HC-05 module receives data from the LPC1768 and wirelessly sends it to a paired device, like a smartphone. Likewise, data transmitted by the paired device via the HC-05 can be received by the LPC1768.
With the UART interface, data transmission and reception are simple processes. The HC-05 Bluetooth module receives data from the LPC1768 via the UART0 interface. UART0 receives the data from the Bluetooth module and can process it or send it to the smartphone or PC that is connected. The code to implement the data communication logic is continued here:
Bluetooth_Communication (): This function continuously monitors whether any data is received via UART0 from the HC-05 module. Data is received and echoed back to the PC or smartphone via UART if it is available. If necessary, the code can also transmit commands or sensor data to the Bluetooth module.
You can test the system after the LPC1768 has been programmed and the Bluetooth communication logic has been put into place:
Connect to the HC-05 module by installing a Bluetooth terminal app (for example, Bluetooth Serial Controller on Android). Data can be sent from the terminal to the LPC1768 and vice versa once connected.
Once basic Bluetooth communication has been established, you can experiment with a number of more sophisticated features:
Control Devices Remotely: By sending commands from the paired smartphone or PC, you can use the Bluetooth connection to remotely control devices like relays, motors, and LEDs.
Data Logging: For monitoring or logging purposes, use Bluetooth to transfer sensor data from the LPC1768 to a mobile app, such as temperature, humidity, or accelerometer data.
Low Power Mode: Many Bluetooth modules, including the HC-05, can function in power-saving mode because Bluetooth communication is built for low power.
The LPC1768 microcontroller’s integration of Bluetooth offers a straightforward yet effective way to enable wireless communication in embedded systems. The HC-05 Bluetooth module makes it simple to transfer data between the LPC1768 and other Bluetooth-capable devices, such as PCs or smartphones. Applications for this method are numerous and include wireless data logging and remote control systems. The LPC1768 can effectively manage wireless communication with the help of the HC-05 module and the UART interface, allowing developers to create networked systems that function over short distances without the use of physical cables.
Must Read: STM32 ADC: Analog Sensor Reading
Indian Institute of Embedded Systems – IIES