Cov txheej txheem:

OldMan thiab Bluetooth2: 4 Cov Kauj Ruam
OldMan thiab Bluetooth2: 4 Cov Kauj Ruam

Video: OldMan thiab Bluetooth2: 4 Cov Kauj Ruam

Video: OldMan thiab Bluetooth2: 4 Cov Kauj Ruam
Video: 20 MOMENTS YOU WOULDN'T BELIEVE IF NOT FILMED 2024, Kaum ib hlis
Anonim
OldMan thiab Bluetooth2
OldMan thiab Bluetooth2

Yog li qhov Lazy Old Geek (L. O. G.) thaum kawg tau txais Bluetooth HC05 module los ntawm AliExpress.com. Kuv xaj ib qho tom qab sau Cov Lus Qhia no:

www.instructables.com/id/OldMan-and-Blueto…

Zoo, Kuv tau siv sijhawm ntau teev los ua qhov haujlwm no hauv kev hais kom ua tsis tiav. Kuv txawm rhuav tshem HC05 tus qauv (tej zaum siv qhov tsis ncaj ncees lawm) yog li yuav tsum tau yuav lwm qhov.

TSWV YIM: Hom hais kom ua tham nrog HC05 lossis HC06 tus qauv nws tus kheej. Hom kev sib txuas lus yog tham nrog lwm lub cuab yeej Bluetooth.

Qhov kuv pom yog qhov sib txawv ntau ntawm HC05 thiab HC06. HC05 tuaj yeem yog tus tswv lossis qhev, HC06 tsuas yog qhev xwb. Qhov tseeb, tus tswv tuaj yeem tham nrog tus qhev, ob tug qhev tsis tuaj yeem tham ib leeg. HC05 thiab HC06 muaj cov lus txib sib txawv. HC05 yuav tsum tau kho vajtse teeb tsa kom mus rau hauv hom lus txib, nws tuaj yeem muaj tus nqi sib txawv rau kev sib txuas lus thiab kev hais kom ua hom.

HC06 ib txwm nyob hauv kev sib txuas lus thiab hais kom ua hom. Teeb tsa tus nqi baud rau ib qho yuav hloov pauv mus rau lwm qhov.

TSWV YIM: Ua raws li qhov kuv tsis tau ua thiab muaj teeb meem.

TSWV YIM: Txawv HC05s thiab HC06s yuav txawv ntawm qhov kuv tau txais.

HCO6 yuav ua cov lus txib, tab sis tsis tas li qhia qhov hloov pauv tau, piv txwv. hloov npe.

Kauj Ruam 1: Ntsuam xyuas/hloov kho

Ntsuam xyuas/hloov kho
Ntsuam xyuas/hloov kho
Ntsuam xyuas/hloov kho
Ntsuam xyuas/hloov kho
Ntsuam xyuas/hloov kho
Ntsuam xyuas/hloov kho

Txuas nrog yog HC05 cov phiaj xwm zoo ib yam li kuv. Ob qhov sib txawv kuv paub, yog tias muaj 2.2K resistor ntawm PIO11 (34) thiab EN tus pin thiab 3.3v tus tswj hwm yog pob 3 pin thiab tsis muaj tus pin CE. Cov duab txuas nrog yog cov cim qhia txog qhov kuv xav tias kuv muaj.

Rau lub hom phiaj phiaj xwm, dab tsi tseem ceeb yog tus pin 34 Tus lej tau txuas nrog EN tus pin los ntawm 2.2K tus tiv thaiv. (Nws tseem txuas nrog lub laub khawm, lwm sab txuas nrog 3.3V)

Tshuag HC05 xav tau 5V lub zog txawm tias nws ua haujlwm nrog 3.3V cov cim yog li kuv hloov kho kuv HCO5 kom siv 3.3V hloov. Kuv tshem tawm 3.3V tus tswj hwm thiab khiav lub jumper los ntawm VCC tus pin ncaj qha rau 3.3V. Qhov no tau qhia ntawm qhov hloov pauv schematic thiab kuv hloov kho HC05 daim duab.

Los ntawm txoj kev, txuas HC05 Command Set.pdf muaj qee cov ntaub ntawv muaj txiaj ntsig ntawm kev siv HC05, Hmoov tsis zoo, nws tsis zoo rau cov neeg siv.

Kauj ruam 2: Programming HC05

HC05 Kev Ua Haujlwm
HC05 Kev Ua Haujlwm
HC05 Kev Ua Haujlwm
HC05 Kev Ua Haujlwm

Kuv txiav txim siab txoj hauv kev yooj yim tshaj plaws los siv HC05 yog txuas nws mus rau ib qho ntawm kuv CP2102 3.3V cov lej hloov pauv zoo ib yam li kuv tau ua hauv Old Man Thiab Bluetooth Qhia nrog HC06. Saib daim duab thiab schematic.

TSEEM CEEB TSHUAJ TSEEB: Txhawm rau txhawb HC05 hauv kev hais kom ua hom, PIO11 tus pin (34) xav tau kom siab ua ntej 3.3V. EN tus pin ntawm kuv HC05 txuas nrog PIO11 los ntawm 2.2K tus tiv thaiv, yog li nws tsuas yog xav tau khi rau 3.3V. Cov txheej txheem qhia qhov no raws li Txoj Haujlwm pins tab sis tsuas yog tso lub jumper los ntawm 3.3V rau EN tus pin. Nco ntsoov koj ua qhov no ua ntej koj siv lub zog. Ntawm kuv tus kheej, koj tuaj yeem qhia yog tias koj nyob hauv hom lus txib vim tias HC05 LED yuav ntsais muag qeeb. Yog tias nws ntsais muag nrawm, tom qab ntawd koj nyob hauv hom kev sib txuas thiab xav tau sim dua.

TSWV YIM: HC05 hauv kev hais kom ua ib txwm tham ntawm 38400 tus nqi baud. Txhua cov lus txib yog cov peev txheej thiab xav tau ua raws CR thiab LF. (Qhov no txawv dua li HC06)

TSWV YIM: Cov lus txib yog nruj heev. Ib txwm siv lub kaus mom. Lawv txhua tus pib nrog "AT" Ua raws lawv raws nraim, koj tsis tuaj yeem ntxiv qhov chaw uas lawv tsis pom.

Pib Arduino. Mus rau "Cov Cuab Yeej" "Chaw Nres Nkoj" thiab xaiv Com chaw nres nkoj uas CP2102 txuas nrog.

Qhib Serial Monitor. Mus rau hauv qab ntawm lub qhov rais, xaiv "Ob NL thiab CR" thiab "38400 baud". (NL sawv rau Kab Tshiab uas zoo ib yam li LF uas yog Kab Pub).

Mus rau sab saum toj, muaj ib lub npov nyob ib sab ntawm Xa Ntawv, nyem rau hauv nws.

Ntawm koj lub PC qhib Caps Lock

Hom AT

Lub qhov rai loj yuav tsum tso tawm "OK".

Koj tab tom sib tham hauv hom lus txib

Qee cov lus txib uas ua haujlwm rau kuv

AT

AT+RESET

AT+VERSION?

AT+Npe?

AT+ADDR? ADDR: 98D3: 31: F5CB41

AT+Npe = BT1 Qhov no hloov lub npe rau BT1

AT+ROLE? 0 = Qhev 1 = Tswv

Kauj Ruam 3: HC06 Rov Ntsuam Xyuas

HC06 Rov Ntsuam Xyuas
HC06 Rov Ntsuam Xyuas

Ib qho ntawm qhov sib txawv tseem ceeb ntawm HC05 thiab HC06 yog tias HC05 tuaj yeem yog tus tswv lossis qhev thaum HC06 yog qhev xwb. Qhov ntawd txhais tau tias koj tuaj yeem tham ntawm HC05 thiab HC06. Txawm li cas los xij, muaj ntau qhov sib txawv.

Thaum kuv tuaj yeem siv Arduino los teeb kuv HC06, Kuv xaiv siv 3.3v CP2102. Saib Duab

Kev sib txuas

NPE 2102 HC06

Gnd nco

Vcc Vcc

TXD RXD

TXX to RXD

Qhov no zoo ib yam li HC05 tshwj tsis yog kuv HC06 tsuas muaj plaub tus pin.

Kuv CP2102 tau hloov kho kom muab 3.3V

Kuv HC06 tau hloov kho kom txais 3.3V

CP2102 USB txuas nrog kuv lub PC. Ntawm kuv lub PC Kuv siv Arduino IDE.

Xaiv qhov raug "Port" thiab qhib Serial Monitor.

Ntawm kuv tus HC06, lub teeb liab liab liab tau nrawm, uas qhia tias nws tau npaj ua khub tab sis tseem tuaj yeem tau txais lus txib.

Qee cov ntaub ntawv no los ntawm Martyn Currey:

www.martyncurrey.com/arduino-and-hc-06-zs-0…

Yog li txhua hom HC06 yuav txawv, kuv rov qab VERSION linvorV1.5

Rau kuv HC06 (thiab tej zaum txhua tus ntawm lawv), tsis muaj txheej txheem tshwj xeeb kom tau txais nws mus rau hauv hom lus txib. Thaj yog tias nws tsis ua khub, koj tuaj yeem xa cov lus txib ntawm chaw nres nkoj txuas.

TSWV YIM: koj tsis tuaj yeem xa lus txib rau ib qho qauv Bluetooth (uas kuv paub) ntawm Bluetooth.

Qhib Serial Monitor

Nyem rau ntawm thawj lub npov hauv qab ntawm Serial Monitor thiab teeb tsa rau "tsis muaj kab xaus"

Thaum xub thawj, kuv tus nqi baud yog 9600 baud

Hauv koj lub PC teeb tsa Caps Lock rau

Nyob rau sab saum toj lub thawv hom AT

Ntaus Sau lossis coj mus rhaub "Xa"

Qhov screen yuav tsum tso saib OK

TSWV YIM: Yog tias koj tsis tau txais ib qho OK, nws yuav yog vim tus nqi baud tau hloov pauv lossis txawv. Koj tuaj yeem sim ntau yam, txog thaum koj, vam tias, pom qhov raug.

NCO TSEG: Xa ntau lo lus txib, cov ntaub ntawv teb tsis hloov mus rau kab tom ntej. Mus rau hauv qab, koj tuaj yeem nyem rau ntawm Clear output.

Cov lus txib uas ua haujlwm rau kuv:

Lus Teb

AT+VERSION OKlinvorV1.5

AT+NAMEFred rov qabOKsetname

(Nws tsis qhia koj lub npe tab sis yog txuas nrog Bluetooth, nws yuav tshwm sim.)

NCO TSEG: yog tias koj hloov lub npe, lub npe qub yuav tshwm ntawm koj lub xov tooj smartphone kom txog thaum koj tsis ua khub thiab rov ua khub.

AT+PINxxx Tsis tau sim nws. Qhov kev tshem tawm yog 1234

AT+BAUD8 Hloov pauv Baud tus nqi rau 115200

Cov lus teb yog baud tus nqi, piv txwv li 115200

(Tom qab hloov tus nqi baud, koj yuav tsum hloov Serial Monitor baud tus nqi mus rau 115200 kom xa cov lus txib ntxiv.

Baud tus nqi xaiv

1 1200

2 2400

3 4800

4 9600 (lub neej ntawd)

5 19200

6 38400

7 57600

8 115200

9 230400

Ib 460800

Ib 921600

C 1382400 Nws

NCO TSEG: Kuv tsis tau sim siab dua 8 115200. Kuv tau hnov ntawm cov neeg sim siab dua nrog cov txiaj ntsig tsis zoo.

Lwm cov lus txib uas yuav tsum ua haujlwm tab sis tsis tau sim:

AT+PN tsis muaj qhov ntsuas sib npaug (lub neej ntawd)

AT+PO khib parity kos

AT+PE txawm tias qhov sib npaug

TSEEM CEEB: Thaum lub sijhawm no, kuv xav qhia koj txiav txim siab lub npe tshwj xeeb thiab muab tso rau hauv. Kuv tseem yuav qhia koj txiav txim siab tus nqi baud koj xav tham nrog, muab tso rau hauv thiab cim koj li HC06 nrog nws.

Kauj Ruam 4: Teeb HC05 txog HC06

Ok, Cov Lus Qhia no tau pab kuv tshaj plaws:

www.instructables.com/id/How-to-Configure-…

Kuv Teeb:

SLAVE nrhiav chaw nyob

HC06 nrog CP2102 (cia li nyob rau hauv hom lus txib)

Txuas lub CP2102 USB cable txuas rau HC06.

HC06 LED yuav tsum tau nrawm nrawm (Pairing hom).

Ntawm koj lub smartphone, qhib chaw

Mus rau Bluetooth

Tshawb nrhiav lub cuab yeej tshiab

Yog tias koj pom qee yam zoo li HC06 lossis lub npe koj muab rau nws, xaiv qhov no.

Koj feem ntau yuav pom txoj hlua ntawm tus lej zoo li 00: 12: 09: 27: 19: 13, uas yog nws.

Sau qhov chaw nyob no. (Tus lej yog nws qhov chaw nyob tshwj xeeb)

Xaiv nws

Thaum nug tus Pin, ntaus hauv 1234.

Lub npe yuav tsum tshwm.

Yog tias koj tseem tsis muaj qhov chaw nyob, nyob rau hauv “Cov cuab yeej txuas nrog yav dhau los” Xaiv lub npe.

Nyem rau Info, Qhov chaw nyob yuav tsum tshwm. Sau nws cia.

Yog tias nws tsis qhia, tawm ntawm kev teeb tsa thiab qhib Bluetooth Terminal HC-05 app.

Hauv Cov Khoom Siv Ua Ke, nrhiav lub npe, chaw nyob yuav tsum nyob hauv qab nws, sau nws.

Qhev Teeb

Yog tias HC06 LED tsis ntsais muag, hloov lub zog kom nws rov qab los ua khub.

Pib Arduino

Hauv qab "Cov Cuab Yeej" "Chaw Nres Nkoj" Xaiv qhov chaw Com kom raug

Qhib Serial Monitor

Hauv qab ntawm lub qhov rais no

Xaiv "Tsis muaj kab xaus" thiab "9600 baud"

MASTER

HC05 nrog CP2102 teeb tsa hauv kev hais kom ua hom (EN jumpered siab)

Txuas lub USB cable los ntawm CP2102 rau hauv PC

Kuv pom tias kuv tuaj yeem qhib ob Arduinos

Ntawm Arduino thib ob, xaiv qhov raug Com chaw nres nkoj rau HC05

Qhib Serial Monitor

Hauv qab ntawm lub qhov rais

Xaiv "Ob NL & CR" thiab "38400 baud"

Cov hauv qab no yog los ntawm Cov Lus Qhia saum toj no

Tswv Configuration

Qhov yuav tsum tau ua AT cov lus txib los teeb tsa kev teeb tsa:

COMMAND RESPONSE Nws ua dab tsi

AT+ROLE = 1 OK Teeb HC05 ua tus tswv

AT+CMODE = 1 OK Txuas mus rau qhov chaw nyob tshwj xeeb

NCO TSEG: Qhov chaw nyob HC06 tej zaum yuav muaj cov ntawv zoo li no 00: 12: 09: 27: 19: 13

Cov lus txib BIND xav kom qhov no 0012, 09, 27193 (koj tshem tawm cov pawg, siv thawj plaub tus lej, tom qab ntawd tus lej, ob tus lej tom ntej, tom qab ntawd tus lej, tom qab rau tus lej kawg)

AT+BIND = 0012, 09, 271913 OK Txuas/khi nrog HC06

(Los ntawm txoj kev AT +KHOOM? Teb nrog +KHOOM: 12: 9: 271913)

(Koj xav kom HC05 kev sib txuas lus zoo ib yam li HC06) piv txwv:

AT+UART = 115200, 0, 0 OK Baud tus nqi 115200 (1stop ntsis, tsis muaj qhov sib npaug)

Txhawm rau sim kev sib txuas lus:

Tshem tawm HC05 EN jumper, lub zog hloov pauv.

Thaum ob qho txuas nrog, HC05 LED yuav ntsais ob zaug txhua ob peb feeb, HC06 LED yuav nyob tas li.

Teeb ob qho chaw nres nkoj com rau tib tus nqi baud (xijpeem koj teeb tsa)

Teem ob qho rau "Ob NL & CR"

Ntaus qee yam ntawm Serial Monitor1, Serial Monitor2 yuav tsum tso saib nws.

Ntaus ib yam dab tsi ntawm Serial Monitor2, Serial Monitor1 yuav tsum tso saib nws.

Nrog koj zoo siab, koj tab tom sib tham ntawm Bluetooth

Tam sim no cov lus qhia saum toj no muaj qee qhov kev kos duab yuav ua li cas siv cov qauv nrog Arduino. Txog rau Cov Lus Qhia no, Kuv yuav tsis nkag mus rau qhov no.

Pom zoo: