Showing posts with label Bluetooth Module. Show all posts
Showing posts with label Bluetooth Module. Show all posts

Thursday, April 14, 2016

Config HC-05(s) as paired Master and Slave

This post show how to set a HC-05 as Master, and bind to another Slave HC-05. By default, HC-05 is set as Slave (ROLE=0), UART=9600,0,0 and PSWD="1,2,3,4", what we have to do on Slave is to copy the ADDR used to bind in Master. In Master side, what we have to do is set as Master (ROLE=1), make sure same UART and PSWD,  BIND to Slave's ADDR, and set CMODE=0, such that the Master will connect the assigned Slave only. Once set, the Master/Slave pair will auto-connect when power-up in range.



In my setup, a FTDI USB-to-Serial adapter is used to check/set the HC-05(s), Arduino Software's Serial Monitor is used to enter AT command to HC-05, all FTDI adapter, both HC-05 are set working on 3.3V.



Check the config of Slave HC-05:

Connection:
FTDI Tx - Slave HC-05 Rx
FTDI Rx - Slave HC-05 Tx
FTDI GND - Slave HC-05 GND

Conenct USB to FTDI, and open  Arduino Serial Monitor, set baud rate to 38400, "Both NL & CR".

Press the on-board button of Slave HC-05 and apply power to Slave HC-05.


Make sure ROLE=0, UART=9600,0,0, PSWD="1234" by entering AT Commands:
AT+ROLE?
AT+UART?
AT+PSWD?

Copy the ADDR:
AT+ADDR?

In my case, ADDR is 2014:12:20016

Power-off and disconnect the Slave HC-05.


Set the config of Master HC-05:

Connection:
FTDI Tx - Master HC-05 Rx
FTDI Rx - Master HC-05 Tx
FTDI GND - Master HC-05 GND

Press the on-board button of  Master HC-05 and apply power to Master HC-05.



Make suew UART and PSWD match with Slave side:
AT+UART?
AT+PSWD?

Change ROLE to Master
AT+ROLE=1

Bind to the ADDR of Slave. In my case Slave's ADDR is 2014:12:20016, replace ':' by ',', enter:
AT+BIND=2014,12,20016

And set CMODE=0:
AT+CMODE=0

Power-off the Master HC-05.


Auto connect:

Keep FTDI connect to Master HC-05. Connect TXD and RXD of Slave HC-05 together, to echo the received data back to sender.

Power-up both Master and Slave HC-05, don't press the on-board button.

Change baud rate of Arduino Serial Monitor to 9600 (match with the UART in HC-05), keep using "Both NL & CR".


Notice the blinking pattern of the on-board LED of HC-05(s), they will auto-connect once power-up.

Enter anything in Arduino Serial Monitor, it will be send to Master HC-05, and send to paired Slave HC-05 and echo back via Bluetooth,


Reference:
Elastic Sheep - Serial Bluetooth module – Master/Slave connection
iteadstudio - Serial Port Bluetooth Module (Master/Slave) : HC-05
AT Command mode of HC-05

Monday, April 11, 2016

Android BluetoothChat connect to Arduino Uno + HC-05

Last example show "Android BluetoothChat example link with HC-05 Bluetooth", to connect to PC via FTDI adapter. Here is another example - Arduino UNO + HC-05 to echo received data back to the sender.

For my on-hand HC-05 sample, it set as slave role and 9600, 0, 0, PIN="1234" by default. So it can be used in this example without any extra setting.


Connection between UNO and HC-05
HC-05 Rx - Uno Tx (1)
HC-05 Tx - Uno Rx (0)
HC-05 GND - Uno GND
HC-05 VCC - Uno 5V
(My HC-05 marked "Power: 3.6V-6V", refer here, make sure your HC-05 can work on 5V.)

Uno_Serial_echo.ino
/*
Arduino Uno + HC-05 (Bluetooth) - echo bluetooth data

Serial (Tx/Rx) communicate to HC-05
HC-05 Rx - Uno Tx (1)
HC-05 Tx - Uno Rx (0)
HC-05 GND - Uno GND
HC-05 VCC - Uno 5V

*/

void setup()
{
  delay(1000);
  Serial.begin(9600);
}

void loop()
{
  while(Serial.available())
  {
    char data = Serial.read();
    Serial.write(data);
  }
}

This video show how Android BluetoothChat example link with Arduino UNO + HC-05. For the Android BluetoothChat example, refer last post.


Related:
Connect Arduino Due with HC-06 (Bluetooth Module)





Tuesday, April 5, 2016

First test HC-05 Bluetooth Module


This video show my first test of HC-05 Bluetooth Module. Connect a FTDI USB-to-Serial adapter to HC-05. And try communication between Arduino Serial Monitor > FTDI > HC-05 and PC (running Windows 10) Bluetooth (PuTTY).


By default, HC-05 work as slave, and have name and pin of "HC-05" and "1234".

Connection between FTDI and HC-05
FTDI Tx - HC-05 Rx
FTDI Rx - HC-05 Tx
FTDI GND - HC-05 GND
HC-05 VCC - separated 3.3V


Next:
AT Command mode of HC-05
Android BluetoothChat example link with HC-05 Bluetooth
Android BluetoothChat connect to Arduino Uno + HC-05
Config HC-05(s) as paired Master and Slave

Wednesday, December 9, 2015

HM-10 and AT-09 Bluetooth 4.0 BLE module




HM-10 BLE Bluetooth 4.0 Serial Wireless Module


- document of HM-10 can be downloaded from http://www.jnhuamao.cn, it provide Chinese and English version,
*please notice that the site maybe reported containing malware, so I download it in VirtualBox.



Test HM-10 Bluetooth 4.0 BLE module with FTDI adapter


AT-09 BLE Bluetooth 4.0 Uart Transceiver Module CC2541 Central Switching compatible HM-10





Sunday, July 5, 2015

Connect Arduino Due with HC-06 (Bluetooth Module)

Last post (direct to Arduino-er: Test HC-06 Bluetooth Module with Android BluetoothChat) show how to use Android Bluetooth Chat test app to talk with standalone HC-06. This post show how to connect Arduino Due to HC-06 via Serial 3, to receive data from Android and echo back to Android, and also send to Serial port for monitoring.


Connection between Arduino Due and HC-06:
Serial (Tx/Rx) communicate to PC via USB
Serial3 (Tx3/Rx3) connect to HC-06
HC-06 Rx - Due Tx3
HC-06 Tx - Due Rx3
HC-06 GND - Due GND
HC-06 VCC - Due 3.3V

DueHC06_AT.ino
/*
Arduino Due + HC-06 (Bluetooth) -echo bluetooth data

Serial (Tx/Rx) communicate to PC via USB
Serial3 (Tx3/Rx3) connect to HC-06
HC-06 Rx - Due Tx3
HC-06 Tx - Due Rx3
HC-06 GND - Due GND
HC-06 VCC - Due 3.3V

*/
#define HC06 Serial3

void setup()
{
  delay(1000);
  Serial.begin(9600);
  HC06.begin(9600);
  
  Serial.write("\nTest Start\n");
}

void loop()
{
  while(HC06.available())
  {
    char data = HC06.read();
    Serial.write(data);
    HC06.write(data);
  }
}

Related:
Android BluetoothChat connect to Arduino Uno + HC-05

Monday, December 8, 2014

HC-05 Serial Port Bluetooth Module (Master/Slave)

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup.


Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and baseband. It uses CSR Bluecore 04-External single chip Bluetooth system with CMOS technology and with AFH(Adaptive Frequency Hopping Feature). It has the footprint as small as 12.7mmx27mm. Hope it will simplify your overall design/development cycle.