Showing posts with label hc. Show all posts
Showing posts with label hc. Show all posts
Sunday, August 28, 2016
Android BluetoothChat connect to Arduino Uno HC 05
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)
Saturday, August 27, 2016
AT Command mode of HC 05
AT Command mode of HC 05
HC-05 Bluetooth Module support both Master and Slave roles. We can set it in AT Command mode. There are a number of variant of HC-05, and different ways to enter AT Command mode. For my samples, there is a button on the lower-right, above EN pin. Its used to enter AT Command mode when power-on.


This video show how to connect PC to HC-05, via FTDI USB-to-Serial adapter, power-on HC-05 in AT Command mode, and enter AT Command using Arduino Serial Monitor to check setting of HC-05.
Please notice both FTDI USB-to-Serial adapter and HC-05 have to work on the same voltage, both 3.3V or both 5V.
- Connect FTDI and HC-05
FTDI Tx - HC-05 Rx
FTDI Rx - HC-05 Tx
FTDI GND - HC-05 GND
(no power apply to HC-05 now)
- Connect FTDI to PC using USB cable.
- You can check the COM port connect to FTDI in Deviec Manager.
- Start Arduino IDE, and run Tools > Serial Monitor.
- Set baud rate 38400 and select "both NL & CR".
- Press the on-board button of HC-05.
- Apply power to HC-05.
- The on-board LED of HC-05 will blink slowly.
- Now its in AT Command mode.
- You can type AT command in Arduino Serial Monitor to check or set the setting of HC-05.
Some useful command:
AT : return OK if connect correctly.
AT+NAME : get/set name of the device. Nothing return in my sample.
AT+ADDR : display default address
AT+VERSION : display firmware version
AT+UART : get/set serial communication setting; such as baud, number of stop bit, and parity.
AT+ROLE: get/see role of bt module(1=master/0=slave)
AT+RESET : Reset and exit AT mode
AT+ORGL : Restore factory settings
AT+PSWD: get/set default PIN
reference:
- iteadstudio: Serial Port Bluetooth Module (Master/Slave) : HC-05
- HC-03/05 Embedded Bluetooth Serial Communication Module
AT command set
Thursday, August 11, 2016
Connect Arduino Due with HC 06 Bluetooth Module
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(" Test Start ");
}
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, August 1, 2016
Android BluetoothChat example link with HC 05 Bluetooth
Android BluetoothChat example link with HC 05 Bluetooth
This example show to import and modify Android BluetoothChat example, to link with low-cost Bluetooth HC-05.
reference:
- First test HC-05 Bluetooth Module
- AT Command mode of HC-05
We need a FTDI USB-to-Serial adapter to connect PC/USB and HC-05 Bluetooth, and use Arduino IDEs Serial Monitor as terminal, to talk with Android running modified BluetoothChat example.
This video show how to import BluetoothChat example in Android Studio, and edit BluetoothChatService.java to change MY_UUID_SECURE to UUID.fromString("00001101-0000-1000-8000-00805F9B34FB").
~ reference http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html, If you are connecting to a Bluetooth serial board then try using the well-known SPP UUID 00001101-0000-1000-8000-00805F9B34FB.
This video show how it run on Android device, and talk to PC running Arduino IDEs Serial Monitor, via FTDI + HC-05.
In my on-hand HC-05 sample, it set as slave role and 9600, 0, 0, PIN="1234" by default, I have not change any setting.
Cross-post with Android-er
Next:
- Android BluetoothChat connect to Arduino Uno + HC-05
Sunday, July 31, 2016
Config HC 05 s as paired Master and Slave
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 Slaves 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 Softwares 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 Slaves 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, dont 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
Subscribe to:
Posts (Atom)