Coursify

Microprocessor

Bluetooth Communication

1.25 hours

Learning Goals

  • Understand Bluetooth protocol overview: recognizing wireless short-range communication technology operating in 2.4 GHz ISM band, utilizing frequency hopping for robustness against interference, supporting voice and data transmission within 10-100 meter range depending on class
  • Master Bluetooth module interfacing: recognizing serial RS232/UART interface from Bluetooth module to microcontroller, utilizing standard baud rates (typically 9600, 38400 baud) for data communication, managing command mode for configuration and data mode for payload transfer
  • Analyze Bluetooth Classic vs Low Energy: understanding Classic Bluetooth for continuous communication with higher power consumption, recognizing Bluetooth Low Energy (BLE) for intermittent low-power applications, and selecting appropriate type based on power budget and application requirements
  • Understand pairing and connection: recognizing initial pairing process establishing trust between devices, managing PIN or numeric comparison for security, understanding connection establishment sequence before data transmission
  • Apply module configuration: utilizing AT commands for module setup (name, baud rate, pin code configuration), managing master/slave role selection, recognizing factory defaults and configuration persistence methods
  • Master data transmission protocols: understanding serial frame format through UART connection, managing payload size constraints from Bluetooth module buffer, implementing flow control (RTS/CTS) for reliable transmission
  • Implement 8051 Bluetooth interfacing: connecting Bluetooth module RXD/TXD to 8051 serial port (configurable modes 1-3), managing module power supply and control signals, implementing command sequences for mode switching
  • Apply practical wireless applications: implementing remote sensor monitoring through wireless link, controlling actuators via Bluetooth commands, developing Android/iOS app integration for mobile device control, and managing wireless range considerations

Bluetooth is a robust, short-range wireless communication technology operating in the 2.4 GHz Industrial, Scientific, and Medical (ISM) band . As an external communication interface, it allows microprocessors to exchange data without physical cables, facilitating Personal Area Networks (PANs).

At its core, Bluetooth utilizes Frequency Hopping Spread Spectrum (FHSS). This technique switches the carrier frequency among many distinct channels (79 for Classic Bluetooth) at a rate of 1,600 hops per second . This mechanism ensures robustness against interference from other devices operating in the same band, such as Wi-Fi routers or microwave ovens.

Footnotes

  1. Bluetooth - Wikipedia - Overview of Bluetooth technology, ISM bands, and power classes.

  2. Guide to the Radio Layer of Bluetooth Technology - Details on FHSS and the Bluetooth protocol stack.

Interfacing HC-05 Bluetooth Module with 8051 Microcontroller

Bluetooth Protocol and Physical Characteristics

Bluetooth devices are categorized into classes based on their transmission power and effective range. While Class 2 is the most common in consumer electronics (10-meter range), Class 1 is used for industrial applications requiring up to 100 meters .

The communication follows a Master-Slave architecture. A single Master can connect to up to seven active Slaves in a network called a Piconet.

Footnotes

  1. Bluetooth - Wikipedia - Overview of Bluetooth technology, ISM bands, and power classes.

Bluetooth Device Classes and Range

Maximum operating range based on transmission power

Designed for continuous data streaming (e.g., high-quality audio). It uses 79 channels and supports data rates up to 3 Mbps (EDR). It has higher power consumption compared to BLE but is essential for legacy applications and high-bandwidth tasks .

Footnotes

  1. BLE vs Bluetooth Classic Difference - Comparison of power consumption and use cases between Classic and BLE.

Interfacing with the 8051 Microcontroller

The 8051 communicates with Bluetooth modules (like the HC-05) via its Universal Asynchronous Receiver-Transmitter (UART) interface. The module typically acts as a "Serial Port Profile" (SPP) bridge, converting wireless data into serial streams .

To establish communication, the 8051 UART must be configured in Mode 1 (8-bit variable baud rate). The baud rate is determined by Timer 1 in 8-bit auto-reload mode.

The formula for the baud rate in 8051 is: BaudRate=2SMOD32×fosc12×(256TH1)Baud Rate = \frac{2^{SMOD}}{32} \times \frac{f_{osc}}{12 \times (256 - TH1)}

Footnotes

  1. Bluetooth Interfacing with 8051 - EmbeTronicX - Practical guide for connecting HC-05 to 8051 microcontrollers.

Logic Level Voltage Mismatch

Most Bluetooth modules (HC-05/HC-06) operate at 3.3V logic. While the 8051 (running at 5V) can usually read the 3.3V TX signal from the module, the 5V TX signal from the 8051 can damage the module's RX pin. Use a simple voltage divider (1kΩ and 2kΩ resistors) to step down the 5V signal to 3.3V .

Footnotes

  1. Bluetooth (HC-05) interfacing with 8051 - Implementation details and voltage logic considerations.

Configuring the HC-05 Module via AT Commands

  1. 1
    Step 1

    Pull the 'KEY' or 'EN' pin high before powering on the module. The onboard LED will flash slowly (once every 2 seconds), indicating it is in AT command mode.

  2. 2
    Step 2

    Send AT+UART=9600,0,0 to set the communication speed to 9600 baud, 1 stop bit, and no parity. Ensure your serial terminal matches this speed.

  3. 3
    Step 3

    Use AT+NAME=Coursify_Project to change the broadcast name that appears on smartphones or other masters.

  4. 4
    Step 4

    Send AT+ROLE=0 for Slave mode (standard for sensor nodes) or AT+ROLE=1 for Master mode (if the 8051 needs to initiate connections) .

    Footnotes

    1. Bluetooth Interfacing with 8051 - EmbeTronicX - Practical guide for connecting HC-05 to 8051 microcontrollers.

Default Baud Rates

By default, many HC-05 modules use 38400 baud for AT Command mode and 9600 baud for Data mode. Always verify your module's datasheet if communication fails initially.

The Pairing and Connection Sequence

  1. 1
    Step 1

    The Master device scans the 2.4 GHz spectrum to find discoverable Slave devices.

  2. 2
    Step 2

    The Master initiates a connection request. Devices exchange security keys (PIN code, typically '1234' or '0000') to establish a trusted bond .

    Footnotes

    1. Bluetooth - Wikipedia - Overview of Bluetooth technology, ISM bands, and power classes.

  3. 3
    Step 3

    Once paired, a virtual serial link is established. The module's state LED will typically double-flash or stay solid.

  4. 4
    Step 4

    The 8051 writes to its SBUF register to send data wirelessly, and the RI flag is raised when data is received from the remote device.

Advanced Transmission Concepts

Knowledge Check

Question 1 of 4
Q1Single choice

Which frequency band does Bluetooth operate in?

Bluetooth Communication | Microprocessor | Coursify