Bluetooth module HC - 06 on Raspberry Pi

in technology •  6 years ago 

On my last blog I published an easy way to use your smartphone as a GPS module using a Bluetoth module to communicate with different boards, but I realize that some people doesn´t know how to configure and connect the Raspberry Pi to the HC - 06 module. So, in this blog that´s what we are going to do.

Materials:
*Raspberry Pi
*HC - 06 Bluetooth module
*Wires
*Computer with ssh connection program.

Process:

First we are going to configure our UART port on our Rasberry Pi, this is because by default raspbian has configured its baud rate to 115200 bps and our module use 9600 bps.

Following some instructions from Miguel Bringerg and his very useful blogs I did it in this way:

NOTE: The instruction to open and edit files is: sudo nano -file direction-
First, we are going to open the file /boot/cmdline.txt , and change the options console and kgbdoc from 115200 bps to 9600 bps.
Now we go to a second file /etc/inittab and also change the property of the port that has 115200 bps to 9600 bps.
All we have to do next is to write some example code, I use the pyserial library from python, you can install it using the next instruction:

sudo pip install pyserial

You can find more information about this library in:
https://pythonhosted.org/pyserial/

In this example I configured my serial port and then I read some data that came with letters to detect the variable that is receiving the module:

NOTE: Your device might be called ACM0 intead of AMA0, to check the devices connected to you board use ls /dev/tty*

The right connection of the module is shown next:

Comment and share if you find this useful.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!