RF-BT0417C HC-05

bt0417c.jpg

btload.jpg

bt0417c-rev.jpg

This is a low cost bluetooth module that may or may not come on a base board. There are a number of variations and here we have the one known as the HC-05. This can be configured as a bluetooth master or slave and appears to be the most popular and versatile.

The module is comprised of a CSR BC417 radio which supports BT 2.0+EDR and an MX29LV800 flash chip.

This module has been verified to work with the RPi 400 and its internal BT 5.0 BLE interface using the legacy mode rfcomm interface.

Pinout

My module came on a board with the following layout. There are at least two other board variations which don't apply here.

A      BUTTON    EN x POWER ENABLE
N               VCC x 7V MAX
T        3V3    GND x GND
E       VREG    TXD x TX 3V3
N               RXD x RX 3V3
N        LED  STATE x SERIAL STATUS
A

The button has two functions.

  1. When power is applied, AT configuration mode is entered if pressed.
  2. If paired, pressing the button terminates the pairing.

I have not tested EN, but it is advertised as putting the device into sleep mode when grounded. It's pulled high to VCC and is directly connected to the voltage regulator enable input.

The STATE pin is raised during serial communication with a paired device.

The module itself has this pin arrangement.

PIO11 PIO10 PIO9 PIO8 PIO7 PIO6 PIO5 PIO4 PIO3 PIO2 PIO1  PIO0 GND
34    33    32   31   30   29   28   27   26   25   24    23   22   21 GND
                           HC-05                                    20 USB D+
                                                                    19 CLK
                                                                    18 MISO
                                                                    17 MOSI
1     2     3    4    5    6    7    8    9    10   11    12   13   16 CSB
UART  UART            PCM  PCM  PCM  PCM                            15 USB D-
TXD   RXD   CTS  RTS  CLK  OUT  IN   SYNC AIO0 AIO1 RESET 3V3  GND  14 NC   

The LED on the base board connects to PIO8, the button to PIO11 and PIO9 is the status.

Power

Power on the base board enters on VCC which passes through a diode to the 3V3 VREG.

The diode is marked B2 which may indicate that it's an MBR0520.

The VREG is marked A239 and it would appear to be compatible with the Micrel MIC5219-3.3.

Configuration

Power up the module with the button pressed.

Now, using picocom we can query the module and adjust a few parameters.

picocom -b 38400 --omap crcrlf --echo /dev/ttyCP2102
AT+VERSION
+VERSION:2.0-20100601
OK
AT+ADDR
+ADDR:98d3:31:50199c
OK
AT+PSWD=6666
OK                                                                                               
AT+UART=9600,0,0                                                                                 
OK                                                                                               
AT+NAME=KEWL                                                                                     
OK 

The parameters set above are preserved within the device.

For the UART setting, standard rates are available plus the higher rates of 230400, 460800, 921600 and 1382400 baud. The second parameter is the number of stop bits (less one) and the last parameter is parity.

After configuration, power cycle the unit without pressing the button to enter pairing mode.

Android

The following application communicated with the module over a virtual serial port.
Bluetooth Terminal

Linux

In separate terminals:

dbus

mkdir -p /var/run/dbus
dbus-daemon --nofork --config-file=/usr/share/dbus-1/system.conf

bluetooth

/usr/sbin/bluetoothd -n

btattach

For built-in BT on Pi3/4, you may also need to attach the device.

btattach -B /dev/ttyAMA0 -P bcm -S 3000000

btkrn

Alternatively to the above, BT can be enabled in /boot/config.txt so btattach is not needed.

dtparam=krnbt=on

Pair with the module

Pairing occurs between devices and not directly between the module and the Linux host computer. What this means is, if the Linux bluetooth adapter is changed a new pairing must be made.

Bluez 4

hciconfig

hciconfig hci0 up
hcitool scan
Scanning ...
        98:D3:31:50:19:9C       KEWL
bluez-simple-agent hci0 98:D3:31:50:19:9C
RequestPinCode (/org/bluez/9566/hci0/dev_98_D3_31_50_19_9C)
Enter PIN Code: 6666
Release
New device (/org/bluez/9566/hci0/dev_98_D3_31_50_19_9C)
Bluez 5

bluetoothctl

[NEW] Controller 00:11:67:5A:96:F3 BlueZ 5.27 [default]
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# scan on
Discovery started
[CHG] Controller 00:11:67:5A:96:F3 Discovering: yes
[CHG] Device 98:D3:31:50:19:9C LegacyPairing: yes
[bluetooth]# scan off
Discovery stopped
[CHG] Controller 00:11:67:5A:96:F3 Discovering: no
[bluetooth]# pair 98:D3:31:50:19:9C
Attempting to pair with 98:D3:31:50:19:9C
[CHG] Device 98:D3:31:50:19:9C Connected: yes
Request PIN code
[agent] Enter PIN code: 6666
[CHG] Device 98:D3:31:50:19:9C Paired: yes
Pairing successful
[CHG] Device 98:D3:31:50:19:9C Connected: no
[bluetooth]# quit 
Agent unregistered
[DEL] Controller 00:11:67:5A:96:F3 BlueZ 5.27 [default]
RFCOMM

Talk to module via virtual serial port.

hciconfig hci0 up
sdptool add --channel=666 SP
rfcomm bind rfcomm0 98:D3:31:50:19:9C
picocom /dev/rfcomm0

Windows

Intel BT 5.2

In Windows 10 scan for BT devices, click connect and enter the pass code.

A COM port will be added for the module which acts just like a regular hardware com port.

This test was performed using an Intel BT 5.2 motherboard adapter.

Resources

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies