Programming PIC microcontrollers with Bluetooth communication

One can transfer byte data (serial) via bluetooth with PIC microcontrollers using microchips HC-05 bluetooth module. The serial communication is done using the EUSART module found on many PIC microcontrollers. I prefer to use the simplest PIC microcontroller with this feature, the PIC16F690. To get started one can program the PIC16F690 with the following test program.

Programming the PIC microcontroller

sertestBT.asm is a simple test program for the PIC16F690 written in assembly to tryout bluetooth serial data transfer. The program sends a byte via the EUSART module to the HC-05 for serial transfer. The program delays around 1/4 second, then increments the byte by 1 and send the incremented byte. The data transfered starts at 0 and increases to 255, then cycles through again, etc. Once can also program the chip in C or another compiler for the microchip product. The microcontroller is connected to the HC-05 as shown below:
Note: In this setup, the HC-05 is in its default mode as slave.

Reading the serial data sent from the HC-05

Using a Cell Phone:
To check if the PIC microcontroller and HC-05 module are correctly sending data, one can read the data with a cell phone. Install one of the various free aps available from Google Play Store that can read Bluetooth transmission, i.e. Blue Terminal. Then, connect to the HC-05 with the default password 1234. Once connected, read the data in HEX format. You should see the HEX data increase by one number every 1/4 sec. If you can read the HEX data, then you know that the HC-05 connection is working.

Reading the data with PC in Linux:
For me, the best way to communicate via bluetooth with the HC-05 is to use serial data transfer with the driver /dev/rfcomm0. An easy way to set up the driver is to install a "Bluetooth Manager", for example blueman. Run the bluetooth manager to search which bluetooth devices are available to connect to. Then, choose the hc-05 and connect. The manager will make a serial /dev/rfcommx file available to use. The first bluetooth device connection will be /dev/rfcomm0. The next device connected will be /dev/rfcomm1, etc. As far as I can see, one can use /dev/rfcomm0 the same way as /dev/ttyUSB0 is used for usb serial port transfer. Below, are listed some examples of reading the serial data from the PIC16F690 code sertestBT.asm , after /dev/rfcomm0 is in your root directory:

Siegel's Home Page

Physics Department| College of Science