Bluetooth HC05

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
User avatar
shell
Posts: 15
Joined: Tue Aug 12, 2014 8:31 pm
Location: Germany
Contact:

Bluetooth HC05

Post by shell » Thu Oct 23, 2014 6:39 pm

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?

riklaunim
Posts: 32
Joined: Fri Aug 22, 2014 5:42 pm

Re: Bluetooth HC05

Post by riklaunim » Thu Oct 23, 2014 7:21 pm

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 :)

User avatar
shell
Posts: 15
Joined: Tue Aug 12, 2014 8:31 pm
Location: Germany
Contact:

Re: Bluetooth HC05

Post by shell » Thu Oct 23, 2014 7:40 pm

Is there a driver for this module?

riklaunim
Posts: 32
Joined: Fri Aug 22, 2014 5:42 pm

Re: Bluetooth HC05

Post by riklaunim » Thu Oct 23, 2014 7:44 pm

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.

Turbinenreiter
Posts: 288
Joined: Sun May 04, 2014 8:54 am

Re: Bluetooth HC05

Post by Turbinenreiter » Thu Oct 23, 2014 7:59 pm

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
Last edited by Turbinenreiter on Mon Nov 03, 2014 3:51 pm, edited 1 time in total.

User avatar
shell
Posts: 15
Joined: Tue Aug 12, 2014 8:31 pm
Location: Germany
Contact:

Re: Bluetooth HC05

Post by shell » Thu Oct 23, 2014 8:12 pm

That looks easy. Thanks for help

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Bluetooth HC05

Post by dhylands » Fri Oct 24, 2014 7:32 am

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.

christian.prosser
Posts: 5
Joined: Thu Nov 06, 2014 10:33 pm

Re: Bluetooth HC05

Post by christian.prosser » Thu Nov 13, 2014 11:07 pm

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/

rankor
Posts: 38
Joined: Sun Nov 30, 2014 12:38 am

Re: Bluetooth HC05

Post by rankor » Fri Dec 05, 2014 10:12 pm

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...

rankor
Posts: 38
Joined: Sun Nov 30, 2014 12:38 am

Re: Bluetooth HC05

Post by rankor » Fri Dec 05, 2014 11:36 pm

>>> 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:()

Post Reply