Interfacing Bluetooth Module HC-06 with PIC Microcontroller
In this tutorial we will learn How to make out PIC projects wireless by interfacing a Bluetooth Module (HC-06). In our previous tutorial we have already learnt How to use USART module in our PIC Microcontroller and established communication between PIC and Computer. If you are an absolute beginner then check here for our all the PIC Tutorials, where we have started from the scratch, like learning MPLAB and XC8, interfacing LED, LCD, using Timers, ADC, PWM etc.
Here, we have used the popular Bluetooth module HC-06. Using this module we can receive and send information wirelessly from our PIC MCU to a mobile application or a computer. Communication between PIC and HC-06 is established using the USART module present in the PIC Microcontroller. You can also use the HC-05. We again operate on the same Asynchronous 8-bit mode, but this time we will modify our code a bit so that it works with the Bluetooth module. Hence learning UART tutorial beforehand is an added advantage for this project.
In this tutorial, we will toggle a LED by sending on or off command from our Smart phone. We will use an Android application called Bluetooth Terminal which can send and receive data over Bluetooth. If we send a char ‘1’ from the app the light will be turned ON in the PIC board and we will get an acknowledgment back to the phone that the light has been turned on. Similarly we can send ‘0’ from phone to turn it off. This way we can control the LED light on our PIC board, similar to the UART tutorial but now wirelessly. Complete Program and the Detailed Video is given at the end of this tutorial.
The basic block diagram for the setup is shown below.
- PIC16F877A Perf Board
- HC-05 or HC-06 Bluetooth Module
- Computer (for programming )
- Mobile Phone
- PICkit 3 Programmer
Bluetooth Module HC-06:
Bluetooth can operate in the following two modes:
- Command Mode
- Operating Mode
In Command Mode we will be able to configure the Bluetooth properties like the name of the Bluetooth signal, its password, the operating baud rate etc. The Operating Mode is the one in which we will be able to send and receive data between the PIC Microcontroller and the Bluetooth module. Hence in this tutorial we will be toying only with the Operating Mode. The Command mode will be left to the default settings. The Device name will be HC-05 (I am using HC-06) and the password will be 0000 or 1234 and most importantly the default baud rate for all Bluetooth modules will be 9600.
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
JLCPCB Prototype: Only $2 for 10pcs 10×10cm, 24 hours Quick Turn, DHL Delivery in 3 days
Current Project / Post can also be found using:
- hc-06 pic16f
- Hc06 with pic16F877a
- interfacing bluetooth module with pic16f877a xc8 compiler
- interfacing pic16f877a with Bluetooth module