Bluetooth Module Interfacing with PIC16F877A

In this tutorial we are going to see Bluetooth Module Interfacing with PIC16F877A.

Prerequisites

Before start this tutorial we should know below topics. If you know already, please go further.

Components Required

  • PIC16F877A Development Board
  • Bluetooth Module
  • DC Motor
  • L293D (Motor Driver IC)
  • Smart Phone with Bluetooth Terminal App

Bluetooth Module (HC-05)

Introduction

HC‐05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module,designed for transparent wireless serial connection setup.The HC-05 Bluetooth Module can be used in a Master or Slave configuration, making it a great solution for wireless communication.This serial port bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and baseband. It uses CSR Bluecore 04‐External single chip Bluetooth system with CMOS technology and with AFH (Adaptive Frequency Hopping Feature).

hc05-bluetooth-module Bluetooth Module Interfacing with PIC16F877A

The Bluetooth module HC-05 is a MASTER/SLAVE module.By default the factory setting is SLAVE.The Role of the module (Master or Slave) can be configured only by AT COMMANDS.The slave modules cannot initiate a connection to another Bluetooth device, but can accept connections.Master module can initiate a connection to other devices.The user can use it simply for a serial port replacement to establish connection between MCU and GPS, PC to your embedded project, etc.

Hardware Features

  • Typical ‐80dBm sensitivity.
  • Up to +4dBm RF transmit power.
  • 3.3 to 5 V I/O.
  • PIO(Programmable Input/Output) control.
  • UART interface with programmable baud rate.
  • With integrated antenna.
  • With edge connector.

Software Features

  • Slave default Baud rate: 9600, Data bits:8, Stop bit:1,Parity:No parity.
  • Auto‐connect to the last device on power as default.
  • Permit pairing device to connect as default.
  • Auto‐pairing PINCODE:”1234” as default.

Pin Description

The HC-05 Bluetooth Module has 6pins. They are as follows:

ENABLE:

When enable is pulled LOW, the module is disabled which means the module will not turn on and it fails to communicate.When enable is left open or connected to 3.3V, the module is enabled i.e the module remains on and communication also takes place.

Vcc:

Supply Voltage 3.3V to 5V

GND:

Ground pin

TXD & RXD:

These two pins acts as an UART interface for communication

STATE:

It acts as a status indicator.When the module is not connected to / paired with any other Bluetooth device,signal goes Low.At this low state,the led flashes continuously which denotes that the module is not paired with other device.When this module is connected to/paired with any other Bluetooth device,the signal goes High.At this high state,the led blinks with a constant delay say for example 2s delay which indicates that the module is paired.

BUTTON SWITCH:

This is used to switch the module into AT command mode.To enable AT command mode,press the button switch for a second.With the help of AT commands,the user can change the parameters of this module but only when the module is not paired with any other BT device.If the module is connected to any other Bluetooth device, it starts to communicate with that device and fails to work in AT command mode.

Bluetooth Module Interfacing with PIC16F877A

Connection

Bluetooth Module

  • Rx – RC6 (Tx)
  • Tx – RC7 (Rx)

DC Motor (L293D Driver)

  • In 1 – RD0
  • In 2 – RD1
  • En 1 – Vcc
  • In 3 – RD2
  • In 4 – RD3
  • En 2 – Vcc

Bluetooth-Module-Interfacing-with-PIC16F877A Bluetooth Module Interfacing with PIC16F877A

Source Code

The program given below is the HC-05 Bluetooth Module Interfacing with PIC16F877A. This process is quite different from others since we are going to use android mobile to control and communicate with PIC16F877A. Here the Bluetooth module acts as an interface between our mobile and PIC16F877A board. Before getting into the execution process,follow the given procedure:

  • First of all,the user should install an application called Bluetooth SPP PRO from the playstore which is a free application.
  • After installation,pair the Bluetooth module to your mobile as like connecting one device to other using Bluetooth.The default pairing code is 1234.
  • Upload the given program to the PIC16F877A board.
  • The Bluetooth SPP PRO has three types of communication mode.Here Byte stream mode is used to communicate.So select that mode and give the input as below.

F – Forward

R – Reverse

L – Left

W – Right

  • So We can control the motor using Mobile by Bluetooth. We can use this set up for developing robots using Bluetooth.

Download our new Android app. You can learn all Embedded Tutorials from your Android Phone easily.

Click Here to Download App!