Bluetooth hc 06 slaver
- 1. Bluetooth-UART Module breakout (HC-06)
Giábán: + tạihttp://hocarm.com: 300k (ở TpHCM, khôngrõxuấtxứ)
+ tạihttp://banlinhkien.vn 240k (ở HàNội, cóthểđặthàng online, sảnphẩmhàng TQ)
Bluetooth module SLAVE chophépviđiềukhiểnkếtnốivớicácthiếtbịngoại vi: smartphone, laptop,
usbbluetooth... thông qua giaotiếp Serial gửivànhậntínhiệu 2 chiều.
Module bluetoothđượctíchhợptrên board chophépbạnsửdụngnguồntừ 3.5V đến 6V cungcấpcho
board màkhôngcần lo lắngvềchênhlệchđiệnáp 3V - 5V gâyhỏng board.
Bluetooth module gồm 6 chântheothứtự: KEY, VCC, GND, TX, RX, STATE.
Đâylà module bluetooth SLAVE nghĩalàbạnkhôngthểchủđộngkếtnốibằngviđiềukhiển,
màcầnsửdụng smartphone, laptop, bluetoothusb... đểdòtínhiệuvàkếtnối (pair) từ smartphone,
laptop, bluetoothusb... Saukhi pair thànhcông,
bạncóthểgửivànhậntínhiệutừviđiềukhiểnđếncácthiếtbịnày.
Hướngdẫnnốidây (cho board Arduino):
- 2. Bluetooth module
Arduino
VCC
5V
GND
GND
TX
RX
RX
TX
Lưu ý: khôngđượcgắnlộndâyVccvàGndvìsẽgâyhỏng module bluetoothngaylậptức.
Tầnsốlàmviệc: 2.4GHz. Kíchthước module: 44mm x 16mm x 7mm. Cósẵn 1 dâynốidài 4 bus
18cm.
Saukhi pair vànốidâycho module bluetooth, bạnsẽnhậndữliệunhư 1 cổng Serial thôngthường.
void setup()
{
Serial.begin (9600);
........
}
void loop()
{
.....
if (Serial.available() > 0)
{
byte c = Serial.read();
..........
}
}
- 3. Mặcđịnh, module bluetooth SLAVE sửdụng baud rate là 9600, PIN là 1234.Cóthểtùychỉnh baud
rate bằngtậplệnh AT (bêndưới).
Bluetooth module SLAVE cóthểdễdàngkếtnốivớicácdòng smartphone Androidthông qua
thưviệnamarino.
Trướchết, cầntảivềthưviệnMeetAndroiddànhchoArduino. Sauđó, càiđặt APIamarinocho Android.
Trong file thưviệnMeetAndroidđãcósẵncácvídụ, giảinénvàothưmục libraries củaArduino,
khờiđộngvàchọn examples.
Tấtcảcác file cầnthiếtcótrong link này: http://www.amarino-toolkit.net/index.php/download.html
Datasheet của Module này: http://www.micro4you.com/files/ElecFreaks/Bluetooth%20HC-06.pdf
AT command
1. Communications Test
Sent : AT
Receive : OK 2.
2.Change baud rate
Sent : AT+BAUD*
Receive : OK**
* làmộtsốtừ 1 -> 8, tượngtrưngchocácmức baud rate tăngdần 1200, 2400, … , 115200
** là baud rate tươngứng, nếu ta gửi AT+BAUD1 thìsẽnhậnđược OK1200.
Lưu ý: Thayđổitốcđộ baud rate cóảnhhưởngđếnđiệnnăng.
3. Change Bluetooth device name
Sent :AT+NAMEdevicename
Receive :OKname
devicenamelàtênmà ta muốnđặtcho module.
Lưu ý: việcthayđổitêncóthểảnhhưởngđếnđiệnnăng.
4. Change Pincode
Sent :AT+PINxxxx
Receive :OKsetpin
xxxxlàmã pin.
- 4. Lưu ý: Pin code cóthểgiúptiếtkiệmđiệnnăng.
Video thamkhảocách setting cho module:
http://www.youtube.com/watch?feature=player_embedded&v=OHujoNYl6ao
Giả iphápchocuộcthi VMAC
-
Cầncàiđặtcácthôngsốcho module trước, rồikếtnối module tới chip SG8V1.
Cáchkếtnốitươngtựnhưgiaotiếp Serial Port (lưu ý, cóthểsẽcầnthêm MAX232).
Vì module khôngchủđộngkếtnốitớithiếtbị Android mà, nênkhilậptrìnhcầnchothiếtbị android
chủđộngdòtìmvàkếtnối.