{"id":2559,"date":"2018-10-02T16:19:23","date_gmt":"2018-10-02T16:19:23","guid":{"rendered":"https:\/\/deepbluembedded.com\/?p=2559"},"modified":"2023-08-17T23:53:01","modified_gmt":"2023-08-17T20:53:01","slug":"bluetooth-module-hc05-interfacing-pic-microcontroller-tutorial","status":"publish","type":"post","link":"https:\/\/deepbluembedded.com\/bluetooth-module-hc05-interfacing-pic-microcontroller-tutorial\/","title":{"rendered":"Bluetooth Module HC-05 With PIC Microcontroller Tutorial"},"content":{"rendered":"\n\n\n\n\n
\"Previous<\/a><\/td>\nPrevious Tutorial<\/strong><\/a><\/td>\nTutorial 19<\/span><\/strong><\/span><\/td>\nNext Tutorial<\/strong><\/td>\n\"Next<\/td>\n<\/tr>\n
<\/td>\nBluetooth Module HC-05 With PIC Microcontroller Interfacing<\/strong><\/span><\/td>\n<\/td>\n<\/tr>\n
<\/td>\nIntroductory Level\u00a0\u2605\u2606\u2606\u2606\u2606<\/strong><\/span><\/td>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

 <\/p>\n

In this tutorial, we\u2019ll control the PIC microcontroller using a smartphone and a PC via Bluetooth. So as not to overload this tutorial, we\u2019ll postpone the communication of 2 PIC microcontrollers via Bluetooth in which the 1st<\/sup> one is a master and the 2nd<\/sup> one is a slave to be in a separate future tutorial. So, let\u2019s get started to see how to control PIC microcontrollers wirelessly with a Bluetooth module.<\/span><\/p>\n

[toc]<\/p>\n


\n

\u00a0 \u00a0Required Components\u00a0 \u00a0<\/span><\/strong><\/span><\/h3>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Qty.<\/strong><\/span><\/td>\nComponent Name<\/strong><\/span><\/td>\nBuy<\/strong> On Amazon.com<\/span><\/td>\n<\/tr>\n
1<\/td>\nPIC16F877A<\/span><\/td>\nAdd<\/a><\/td>\n<\/tr>\n
1<\/td>\nBreadBoard<\/span><\/td>\nAdd<\/a><\/td>\n<\/tr>\n
8<\/td>\nLED<\/span><\/td>\nAdd<\/a>\u00a0 \u00a0 Add<\/a><\/td>\n<\/tr>\n
1<\/td>\nResistors Kit<\/span><\/td>\nAdd<\/a>\u00a0 \u00a0 Add<\/a><\/td>\n<\/tr>\n
1<\/td>\nCapacitors Kit<\/span><\/td>\nAdd<\/a>\u00a0 \u00a0 Add<\/a><\/td>\n<\/tr>\n
1<\/td>\nJumper Wires Pack<\/span><\/td>\nAdd<\/a>\u00a0 \u00a0 Add<\/a><\/td>\n<\/tr>\n
1<\/td>\nHC-05 Bluetooth Module<\/span><\/td>\nAdd<\/a><\/td>\n<\/tr>\n
1<\/td>\nLM7805 Voltage Regulator (5v)<\/span><\/td>\nAdd<\/a><\/td>\n<\/tr>\n
1<\/td>\nCrystal Oscillator<\/span><\/td>\nAdd<\/a><\/td>\n<\/tr>\n
1<\/td>\nPICkit2 or 3 Programmer<\/span><\/td>\nAdd<\/a><\/td>\n<\/tr>\n
2<\/td>\n9v Battery or DC Power Supply<\/span><\/td>\nAdd<\/a>\u00a0 \u00a0 Add<\/a>\u00a0 \u00a0 Add<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

The Prototyping Board Setup<\/a><\/strong><\/p>\n

\"Prototyping<\/a><\/p>\n


\n

\u00a0 \u00a0Introducing The HC-05 Bluetooth Module\u00a0 \u00a0<\/span><\/strong><\/span><\/h3>\n

 <\/p>\n

The<\/span> Bluetooth<\/strong> is a wireless technology standard for exchanging data over short distances (using short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz) from fixed and mobile devices, and building personal area networks (PANs). The communication range is approximately 9 Meters (30 feet). We’ll be using the HC-05<\/strong> Bluetooth module which communicates with microcontrollers over the serial UART<\/strong> bus. Assuming that you’ve got a basic understanding of UARTs or have already completed the UART Tutorial<\/a> which was the previous one (#18).<\/span><\/p>\n

\u00a0Device Description\u00a0<\/span><\/h4>\n

\"Bluetooth<\/p>\n

This module is based on the Cambridge Silicon Radio BC417 2.4 GHz BlueTooth Radio chip. This is a complex chip in fact which uses an external 8 Mbit flash memory. You can find more information in the associated datasheet. However, it’s fairly easy to set up and interface to any microcomputer system over the serial UART.\u00a0HC-05 can be set to be either a Master or a Slave.\u00a0<\/span>These small modules run on 3.3V power with 3.3V serial signal levels, They have no <\/b>pins and is usually soldered to a larger breakout board.<\/span><\/p>\n

Breakout Boards<\/strong>\u00a0make these modules easy to use. HC-05 sub-modules are soldered on breakout boards to provide easier connectivity for users. Most of these boards support operation at 5V power and interface to 5V microcontroller signal levels with some techniques of level shifting. A typical “breakout” board is shown below.<\/span><\/p>\n

\"Bluetooth<\/p>\n

\u00a0HC-05 Pin Out\u00a0<\/span><\/h4>\n

\"Bluetooth<\/p>\n

 <\/p>\n\n\n\n\n\n\n\n\n\n
Pin<\/strong><\/span><\/td>\nName<\/strong><\/span><\/td>\nFunctionality<\/strong><\/span><\/td>\n<\/tr>\n
1<\/strong><\/td>\nEnable\/Key<\/strong><\/td>\nThis pin is used to switch between the Data Mode (set low) and AT Command Mode (set high) Before powering-up the module. By default, it’s in Data mode.<\/span><\/td>\n<\/tr>\n
2<\/strong><\/td>\nVcc<\/strong><\/td>\nPowers-up the module. Is connected to +5V Supply voltage<\/span><\/td>\n<\/tr>\n
3<\/strong><\/td>\nGround<\/strong><\/td>\nGround pin of the module. Is connected to your system’s ground.<\/span><\/td>\n<\/tr>\n
4<\/strong><\/td>\nTX<\/strong><\/td>\nTransmits Serial Data. Everything received via Bluetooth will be given out by this pin as serial data to your microcontroller UART receiver.<\/span><\/td>\n<\/tr>\n
5<\/strong><\/td>\nRX<\/strong><\/td>\nReceive Serial Data. Every serial data given to this pin will be sent via Bluetooth.<\/span><\/td>\n<\/tr>\n
6<\/strong><\/td>\nState<\/strong><\/td>\nThe state pin is connected to onboard LED, it can be used as a feedback to check if the Bluetooth is working properly.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

The Purpose Of The On-Board LED & Button is indicated as follows<\/span>:<\/p>\n

1- The On-Board LED<\/strong><\/p>\n

The way in which this LED is blinking indicates the status of Module as shown below<\/span><\/p>\n