Tuesday, April 18, 2017

HC-06 Bluetooth Module

Based on http://www.martyncurrey.com/arduino-with-hc-05-bluetooth-module-at-mode/

Default mode

Note, use 'software serial' mode on Arduino, as regular uart (pins 0, 1) are also used for USB communication (needed by the IDE).

In the example use pins 2, 3 for RX/TX.
Use voltage divider to get 5v output from Arduino to 3.3v safe for RX on HC-05.

On power up, 2 blinks per second = disconnected
Connect using android device, with 'Serial Bluetooth Terminal' app
Pair device, then connect.
Now should have a steady led
Use code from - https://github.com/bugwhine/arduino/blob/master/bluetooth/bluetooth.ino
Default baud rate for bluetooth side is 9600
From arduino IDE, run program, and open serial monitor
Should be possible to communicate between arduino serial monitor and bluetooth serial app on phone


[steve Arduino]$ hcitool scan
Scanning ...
98:D3:32:20:87:15 HC-06
[steve Arduino]$ sudo rfcomm bind 0 98:D3:32:20:87:15 1
[steve Arduino]$ sudo minicom -s
Serial Port Setup
A -    Serial Device      : /dev/rfcomm0
E  -    Bps/Par/Bits       
C:   9600

Serial comms should now work between minicom, and the arduino serial monitor.

nodejs

sudo dnf install bluez-libs-devel
sudo npm -g install bluetooth-serial-port


node btserial.js
connected
Received: Size of data buf = 1
h
Received: Size of data buf = 6
ello

No comments: