Page 1 of 2

Bluetooth HC05

Posted: Thu Oct 23, 2014 6:39 pm
by shell
Hi everyone,

i'm looking for some information for the hc05 bluetooth module. How to connect? How to access? But i can't find any information. Can anyone help me?

Re: Bluetooth HC05

Posted: Thu Oct 23, 2014 7:21 pm
by riklaunim
Some datasheet and you can start trying (like via http://www.micro4you.com/store/bluetoot ... hc-05.html ). In general if you connect master to pyboard and connect TX with RX on slave then when their are paired anything sent to slave should return :)

Re: Bluetooth HC05

Posted: Thu Oct 23, 2014 7:40 pm
by shell
Is there a driver for this module?

Re: Bluetooth HC05

Posted: Thu Oct 23, 2014 7:44 pm
by riklaunim
There are no drivers "needed", it's just a serial device you can talk to. And I didn't saw any code already written for it.

Re: Bluetooth HC05

Posted: Thu Oct 23, 2014 7:59 pm
by Turbinenreiter
Connect as they labels on the PCBs tell you.
The physical pins of the UART busses are:
  • UART(4) is on XA: (TX, RX) = (X1, X2) = (PA0, PA1)
    UART(1) is on XB: (TX, RX) = (X9, X10) = (PB6, PB7)
    UART(6) is on YA: (TX, RX) = (Y1, Y2) = (PC6, PC7)
    UART(3) is on YB: (TX, RX) = (Y9, Y10) = (PB10, PB11)
    UART(2) is on: (TX, RX) = (X3, X4) = (PA2, PA3)
pyb | bluetooth-module
3V3 | VCC
GND | GND
RX | TX
TX | RX

Use the UART module as described here: http://micropython.org/doc/module/pyb/UART
i.e.

Code: Select all

from pyb import UART

uart = UART(1, 9600)                         # init with given baudrate
uart.init(9600, bits=8, stop=1, parity=None) # init with given parameters
Use

Code: Select all

pyb.repl_uart(uart)
to send the REPL to the UART you created above.

On Ubuntu do:
Bluetooth - Set up new device - chose the device - Pin options '1234' - Next
Get the modules MAC address:

Code: Select all

hcitool scan
Add the serial port:

Code: Select all

sudo nano /etc/bluetooth/rfcomm.conf
add:

Code: Select all

rfcomm0 {
        bind no;
        device MAC address of your module;
        channel 1;
        comment "Serial Port";
        }
Connect:

Code: Select all

sudo rfcomm connect 0
Watch with:

Code: Select all

screen /dev/rfcomm0

Re: Bluetooth HC05

Posted: Thu Oct 23, 2014 8:12 pm
by shell
That looks easy. Thanks for help

Re: Bluetooth HC05

Posted: Fri Oct 24, 2014 7:32 am
by dhylands
I didn't see this mentioned, so I figured its worth being explicit.

You'll want to connect the TX pin from the HC05 to the RX pin on the pyboard, and the RX pin from the HC05 to the TX pin on the pyboard.

You'll also need to connect GND from the HC05 to ground on the pyboard. And if you're plugged into USB, then VIN will be just under 5V (around 4.75v) and can be used to power the HC05.

Re: Bluetooth HC05

Posted: Thu Nov 13, 2014 11:07 pm
by christian.prosser
I found the info in Turbinenreiter's post really useful so I've added it to the wiki: http://wiki.micropython.org/official-ac ... odule-HC05

I think the wiki should be the source of reference material for new starters rather than trawling through the forum so I've added a section to the wiki to gather information about the official accessories: http://wiki.micropython.org/pages/official-accessories/

Re: Bluetooth HC05

Posted: Fri Dec 05, 2014 10:12 pm
by rankor
I did:
from pyb import UART
uart=UART(3,9600) # Using Y9,Y10.

What do I do once I have the:
pyb.repl_uart(uart)

I tried to send:
AT+PINxxxx like this: uart.send("AT+PIN3478") but when I tried to pair it was still the old password.
I also tried to change the name with no luck.

The module is blinking red. Do I need to use the state or key pin to modify it?

since uart.send does not give you a response it is hard to debug...

Re: Bluetooth HC05

Posted: Fri Dec 05, 2014 11:36 pm
by rankor
>>> uart.send('AT+PIN2345')
>>> pyb.repl_uart(uart)
>>> uart.send('AT+PIN2345')
>>> ERO:0
File "<stdin>", line 1, column 4
SyntaxError: invalid syntax
>>> EERO:0
File "<stdin>", line 1, column 5
SyntaxError: invalid syntax
>>> ERO:()ERO:()