Bluetooth module interfacing with pic microcontrollers, in this article I explained how to interface Bluetooth module with microcontrollers, What is Bluetooth ? Types of Bluetooth? How Bluetooth communicate with other devices? and How to select most suitable Bluetooth module for your project in which you want to use Bluetooth for wireless communication. Many of you are already familiar with Bluetooth and its working. Because you use Bluetooth daily for sending and receiving data from one device to another in your mobile phones or computers. But Bluetooth have many other application in wireless audio and video controllers.
What is Bluetooth ?
Bluetooth is a type of wireless communication protocol used to send and receive date between two devices. It is free to use wireless communication protocol. Although its range it lower than other wireless communication protocols like WiFi and ZigBee. But it is still suitable for many low range applications.Bluetooth wireless protocol lies in the same range of frequency of WiFi and ZigBee. It operates on 2.41 GHz frequency.
Applications of Bluetooth :
There are many applications of Bluetooth modules but major applications of Bluetooth is given below :
- In mobiles , computers , laptops and all other smart computers.
- wireless Audio and video controllers
- wireless mouse and keyboards
- Wireless head phones and Microphones
- there are man other applications of Bluetooth, Just Google to know more about applications of Bluetooth.
Bluetooth module is work as master or slave. There are many Bluetooth modules available in market which are either master/slave or both. Master Bluetooth module can send or receive data from other Bluetooth modules. But slave Bluetooth can only listen to master Bluetooth module. It depends on your application which Bluetooth module you need for your project.
How to select Bluetooth module ?
Bluetooth module selection depends on following factors :
- Maximum power output of Bluetooth module
There are three classes of Bluetooth modules exist. Power output range of all three class are given below :
- class 1 : 100 mW
- class 2 : 2.5 mW
- class 3 : 1 mW
2. Distance between your two Bluetooth devices receiver and transmitter :
According to range of Bluetooth devices, there are also three classes of Bluetooth modules :
- class 1 : 100 meter
- class 2 : 10 meter
- class 3 : 10 centimeter
3. Mode of communication you want to use
Bluetooth modules need communication protocols to interface with other devices. For example in this article our main focus is Bluetooth module interfacing with microcontroller, microcontroller can communicate with Bluetooth device through following wired communications to send or receive data from other Bluetooth device :
It depends on you which wired communication from above three you want to use for interfacing your microcontroller with Bluetooth module. There are many Bluetooth modules available in market which support above three communication. But the name of some famous serial Bluetooth modules are given below:
All above Bluetooth modules have different range, power output and quality. Before selecting any above Bluetooth module you should make sure either you have a need of master or slave Bluetooth module.You can choose any above Bluetooth module according to your requirements. I recommend you to choose Bluetooth module which have UART communication and it is easy to write program using UART. While selecting any Bluetooth module you should check that it should have built in Bluetooth host controller. Otherwise you have to write your own software for this purpose and it need a lot of time and expertise in software programming.
In this article I have chosen RN-42 Bluetooth module to teach you how to interface it with pic microcontroller. RN-42 is a Bluetooth module product of microchip.
RN-42 Bluetooth module interfacing with pic microcontroller :
RN-42 is class 2 Bluetooth module. It have UART and USB communication interface. It can both send and receive data i.e. it can work both as Master and slave. It can also be use for audio application.
To interface RN-42 module with PIC microcontroller or any microcontroller, you need of voltage level shifting circuit with RN-42. But Microchip also provide it solution by providing complete compatible board to interface it with microcontroller. RN-42 EK board can interface with PIC microcontroller directly by connecting UART_RX pin of RN-42 Bluetooth module to Tx pin of pic microcontroller and UART_TX pin of RN-42 Bluetooth module to Rx pin of pic microcontroller. RN-42-EK board can also be connected with computer through usb cable.
To download data sheet and to buy RN-42 EK board click on the link below :
Block diagram below shows interfacing diagram of pic microcontroller and RN-42 EK board :
How to send/receive commands or data from microcontroller to/from RN-42 EK kit :
RN-42 have two modes commands mode and data mode. command mode is used to set configuration of Bluetooth module like its mode either master or slave, baud rate, serial port flow control. Bluetooth module should be configured before using data mode. Otherwise it will use default values of configuration bits and commands. Command mode is used to set device name , pin code and baud rate. One thing you should keep in mind there is a specific time for command mode, you should use command with in this time otherwise. Bluetooth module will reach into data mode after this time.
For more information regarding how to write firmware and to see example of a project watch following video :
I hope that you have gained precious or practical knowledge after reading this article and watching video. Kindly share this article with your friends, because the more you share , the more you share the more you get.
good luck 🙂