Cov txheej txheem:

Yuav Hloov Li Cas Bluetooth Lub Npe Yooj Yim Nrog Arduino: 4 Cov Kauj Ruam
Yuav Hloov Li Cas Bluetooth Lub Npe Yooj Yim Nrog Arduino: 4 Cov Kauj Ruam

Video: Yuav Hloov Li Cas Bluetooth Lub Npe Yooj Yim Nrog Arduino: 4 Cov Kauj Ruam

Video: Yuav Hloov Li Cas Bluetooth Lub Npe Yooj Yim Nrog Arduino: 4 Cov Kauj Ruam
Video: yuav coj li cas kom luag nyiam 2024, Lub Xya hli ntuj
Anonim
Yuav Hloov Li Cas Bluetooth Lub Npe Yooj Yim Nrog Arduino
Yuav Hloov Li Cas Bluetooth Lub Npe Yooj Yim Nrog Arduino

Hauv txoj haujlwm no koj yuav kawm paub npe koj li Bluetooth Module thiab kuaj pom qhov ua tsis tiav hauv kev ua haujlwm ntawm koj lub bluetooth.

Rau qhov haujlwm no koj yuav siv cov khoom siv hauv qab no qhia hauv qab no.

Khoom siv

PCBWay Custom PCB

HC -06 Bluetooth Module - UTSOURCE

Jumper Wires - UTSOURCE

Breadboard - UTSOURCE

Arduino UNO - UTSOURCE

Kauj Ruam 1: Kuv Yuav Hloov Li Cas Lub Npe Ntawm Kuv Tus Qauv Bluetooth?

Koj puas tau pom tias nws txaus nyiam npaum li cas thaum peb yuav lub cuab yeej nrog Bluetooth thiab lub teeb liab muaj npe nrog lub npe ntawm lub npe lossis khoom siv?

Kuv hais txog qhov no, zoo li kuv ib txwm xav paub nkag siab tias nws ua haujlwm li cas thiab rau npe lub module nrog lub npe ntawm kuv tus kheej txoj haujlwm. Nws yooj yim, tab sis nws ua qhov sib txawv hauv ob lub ntsiab lus: txheeb xyuas tus qauv thaum ua khub thiab kho koj tus qauv nrog lub npe ntaus ntawv.

Kuv xav tias koj muaj teeb meem no lossis tsawg kawg, xav paub paub yuav ua li cas siv lub luag haujlwm no hauv koj tus qauv qauv. Txawm hais tias nws yog qhov yooj yim heev, Kuv xav qhia koj yuav ua li cas koj li thiab tsis muaj teeb meem ntxiv.

Txhawm rau nkag siab qhov teeb tsa no, koj yuav kawm cov ntsiab lus hauv qab no hauv kev nyeem no:

  • Yuav ua li cas txuas Bluetooth module ntawm Arduino;
  • Lawv yog dab tsi thiab yuav siv AT cov lus txib li cas hauv kev teeb tsa ntawm Bluetooth Module;
  • Yuav ntsuas li cas yog tias kev sib txuas lus ntawm Bluetooth module thiab Arduino ua haujlwm;
  • Yuav ua li cas kho qhov nrawm;
  • Yuav hloov lub npe ntawm lub cuab yeej bluetooth li cas;
  • Yuav ua li cas teeb tsa tus lej nkag mus nkag rau peb lub bluetoooth module.

Wow! Cov ntaub ntawv ntau npaum li cas kuv txaus siab muab rau koj. Txaus siab tias txhua yam tau teeb tsa thiab kuv yuav xa txhua yam yooj yim li sai tau.

Kauj Ruam 2: Bluetooth Module Nrog Arduino

Bluetooth Module Nrog Arduino
Bluetooth Module Nrog Arduino

Kuv xav pib los ntawm kev qhia koj txog qhov tseem ceeb ntawm kev paub Bluetooth module thiab nws cov txheej txheem sib txuas nrog Arduino. Thaum yuav khoom, koj yuav pom cov qauv HC-05 thiab HC-06.

Nov yog ob qho qauv siv dav los ntawm Arduino zej zog. Qhov sib txawv tseem ceeb ntawm cov qauv no yog HC-05 tus qauv tuaj yeem ua haujlwm ua tus tswv lossis qhev.

Yog li, hom qhev tso cai rau nws kom muaj kev sib txuas lus pib los ntawm lwm lub cuab yeej thiab tus tswv hom tso cai rau Bluetooth module pib kev sib txuas lus nrog lwm lub cuab yeej Bluetooth.

Thaum kawg, HC-06 Bluetooth module ua haujlwm tsuas yog ua qhev hom.

Tam sim no, Kuv xav qhia koj txog cov qauv yooj yim uas koj tuaj yeem siv los sib txuas lus koj Bluetooth module nrog koj Arduino.

Muaj tiag ob txoj hauv kev, tab sis kuv yuav piav qhia vim li cas txoj kev ntawd muaj txiaj ntsig zoo rau koj cov phiaj xwm.

Kuv tau xaiv los nthuav qhia koj nrog tus qauv no hauv daim duab hauv qab no, raws li peb yuav siv tus pin TX thiab RX rau kev sib txuas lus txuas. Yog li ntawd, lawv yuav tsis khoom thiab peb yuav tsis tuaj yeem qhia tib tus pin nrog Bluetooth kev sib txuas lus.

Txhawm rau zam qhov teeb meem no, peb yuav siv SoftwareSerial lub tsev qiv ntawv, txhawm rau sim lwm tus lej txuas ntawm cov chaw nres nkoj 10 thiab 11 ntawm Arduino, raws li qhia hauv daim duab hauv qab no.

Los ntawm daim duab sib dhos saum toj no, peb yuav pom yuav teeb tsa peb tus kheej li cas.

Kauj Ruam 3: Txheej Txheem Txheej Txheem Siv AT Commands

Txheej txheem teeb tsa Siv AT Commands
Txheej txheem teeb tsa Siv AT Commands
Txheej txheem teeb tsa Siv AT Commands
Txheej txheem teeb tsa Siv AT Commands
Txheej txheem teeb tsa Siv AT Commands
Txheej txheem teeb tsa Siv AT Commands

Lub sij hawm AT los ntawm lo lus ATtention. Cov lus txib no yog cov lus qhia siv los ua haujlwm ntawm Bluetooth module. Hauv cov lus txib no, ib qho thiab tag nrho cov lus qhia yuav tsum pib nrog ua ntej AT, xws li AT + COMMAND.

Yog li, nws yuav dhau los ntawm cov lus txib no uas peb yuav teeb tsa peb lub Bluetooth Module. Txhawm rau paub cov lus txib twg los siv, nws yog ib qho tseem ceeb uas koj nkag mus rau cov ntaub ntawv ntawm koj tus qauv Bluetooth.

Muaj koj yuav pom txhua cov lus qhia muaj rau teeb tsa tus qauv.

Tam sim no, Kuv yuav pib teeb tsa ntawm HC-06 module thiab muab cov kev txuas nkag mus rau Bluetooth phau ntawv qhia HC-05 thiab HC-06.

Tam sim no, txhawm rau teeb tsa Bluetooth module, peb xav tau tus lej xa AT cov lus txib. Txoj cai xa AT cov lus txib rau Bluetooth module Tus lej hauv qab no yog siv los xa AT cov lus qhia ntawm Arduino cov lej thiab xa lawv mus rau Bluetooth module.

Txoj cai xa AT cov lus txib rau Bluetooth module

Cov cai hauv qab no yog siv los xa AT cov lus qhia ntawm Arduino cov lej thiab xa lawv mus rau Bluetooth module.

#suav nrog SoftwareSerial mySerial (10, 11); // RX, TX String command = ""; // Khaws cov lus teb ntawm bluetooth ntaus ntawv // uas yooj yim tso cai / n ntawm txhua qhov // teb. teeb tsa tsis muaj dab tsi () {// Qhib cov kev sib txuas lus thiab tos rau qhov chaw nres nkoj qhib: Serial.begin (115200); Serial.println ("Ntaus AT cov lus txib!"); // SoftwareSerial "com chaw nres nkoj" cov ntaub ntawv tus nqi. JY-MCU v1.03 defaults rau 9600. mySerial.begin (9600); } void loop () {// Nyeem ntawv ntaus ntawv tawm yog tias muaj. yog tias (mySerial.available ()) {thaum (mySerial.available ()) {// Thaum muaj ntau yam yuav tau nyeem, nyeem ntxiv. hais kom ua += (char) mySerial.read (); } Serial.println (hais kom ua); hais kom ua = ""; // Tsis rov ua dua} // Nyeem cov neeg siv tswv yim yog tias muaj. yog (Serial.available ()) {ncua (10); // DEEV! mySerial.write (Serial.read ()); }}

Cov cai saum toj no yog siv los txais AT cov lus txib, uas tau xa los ntawm Arduino IDE. Los ntawm cov lus txib tau txais los ntawm IDE, lawv yuav raug xa mus rau Bluetooth module txhawm rau teeb tsa nws txoj haujlwm.

Tom qab tag nrho, yuav ua li cas thiaj paub tias tus qauv ua haujlwm thiab teb rau cov lus txib xa los ntawm Arduino?

Nov yog ib nqe lus nug uas ntau tus neeg nug thaum muaj teeb meem hauv kev xa lossis txais cov ntaub ntawv. Coob leej xav tias tus qauv raug puas tsuaj thiab tsis nkag siab yuav txheeb xyuas cov teeb meem no li cas.

Tias yog vim li cas kuv ib txwm hais lus thiab rov hais dua, kom paub tus qauv kev tswj hwm thiab teeb tsa kev ua haujlwm. Lawv yuav pab koj txhais cov kev coj ua tsis raug cai hauv koj daim ntawv thov

Kuv hais txog qhov no vim kuv xav qhia koj txog AT muaj nuj nqi, raws li qhia hauv daim duab hauv qab no.

Lub luag haujlwm no yog lub luag haujlwm ntsuas kev sib txuas lus ntawm koj Arduino thiab koj tus qauv. Yog li, txhua lub sijhawm koj ua tiav AT cov lus txib, tus qauv yuav tsum xa cov lus OK mus rau tus saib xyuas ntawm Arduino IDE.

Cov lus pom zoo no pab peb txiav txim siab tias peb cov qauv ua haujlwm thiab sib txuas lus raug nrog Arduino. Tom qab cov lus txib no, peb yuav tsum npaj cov qauv ua haujlwm ntawm tib qho kev sib txuas lus ceev ib yam li Arduino

Peb yuav teeb tsa kev sib txuas lus nrawm ntawm Bluetooth Module li cas?

Kuv nquag hais tias qhov no yog ib qho ntawm cov ntsiab lus uas ntau tus neeg nco. Lawv xaiv qhov kev sib txuas lus nrawm ntawm Arduino, txawm li cas los xij, kev xa xov nrawm ntawm Bluetooth module tau teeb tsa mus rau lwm qhov txiaj ntsig. raws li lawv tsis nkag siab yuav teeb tsa tus qauv siv AT cov lus txib li cas.

Qhov txiaj ntsig ntawm qhov no yog cov neeg siv qhia teeb meem nrog tus qauv ua haujlwm, txawm li cas los xij, qhov tseeb yog qhov module tau teeb tsa hauv txoj hauv kev tsis txaus rau daim ntawv thov.

Txhawm rau zam qhov teeb meem no, ua qhov ntsuas los ntawm AT cov lus txib thiab siv AT + BAUDX teeb tsa kev teeb tsa, txhawm rau teeb tsa tus nqi ntawm Bluetooth module.

Tus nqi X sawv cev rau qhov teeb tsa nrawm ntsuas, raws li qhia hauv cov khoom hauv qab no

1 1200

2 2400

3 4800

4 9600 (lub neej ntawd) 5 19200

6 38400

7 57600

8 115200

9 230400

Ua ntej, txheeb xyuas qhov nrawm siv rau koj kev sib txuas lus txuas thiab kho qhov nrawm ntawm koj tus qauv rau tib qho kev sib kis. Yog li, yog tias koj siv kab hais kom ua AT + BAUD8, koj lub Bluetooth module yuav teeb tsa nrog tus nqi baud ntawm 115200bps.

Txoj kev ntawd, koj muaj kev tswj hwm kev sib txuas lus nrawm thiab zam kev sib txuas lus tsis raug ntawm koj tus qauv thiab Arduino.

Ntxiv rau qhov nrawm, peb yuav tsum teeb tsa ob qhov tsis tseem ceeb: lub npe module thiab nws tus lej nkag. Cov ntsuas no yog qhov tseem ceeb los tsim kev sib txuas lus ntawm cov cuab yeej thiab Bluetooth module.

Tom qab tag nrho, yuav teeb tsa ob qhov ntsuas no li cas?

Ua ntej, muab lub npe rau koj tus qauv yog qhov tseem ceeb los ntawm ob lub ntsiab lus: kev txheeb xyuas koj lub cuab yeej hauv cov npe thiab thib ob, ntxig lub npe ntawm koj lub cuab yeej/hom khoom hauv tus qauv nws tus kheej.

Txhawm rau ua cov txheej txheem no, siv cov lus hauv qab no AT + NAME. Los ntawm qhov ntawd, siv cov lus qhia hauv qab no: AT + NAMEsilicioslab raws li qhia hauv daim duab saum toj no.

Tom qab ua tiav cov lus txib no, tus qauv yuav raug hu ua silicioslab.

Daim duab 5 - Lub xov tooj ntawm tes txuas hauv bluetooth module npe hu ua silicioslab.

Ntxiv rau kev hloov lub npe, nws yog ib qho tseem ceeb los teeb tus password rau cov neeg siv. Lo lus zais tau txhais los ntawm cov lus qhia hauv qab no AT + PINXXXX.

Los ntawm cov lus qhia no, koj yuav tsum xaiv tus lej 4 tus lej thiab ua raws cov lus txib hauv qab no, piv txwv li: AT + PIN4444. Thaum cov lus txib no ua tiav, tus lej tshiab nkag mus rau tus qauv yuav yog 4444.

Yog li ntawd, los ntawm cov theem tau hais los saum toj no nws tuaj yeem teeb tsa tag nrho Bluetooth module thiab xyuas kom meej tias koj kev sib txuas lus nrog Arduino yuav ua tiav yam nyab xeeb.

Kauj Ruam 4: Kev Nyab Xeeb Hauv Kev Ua Haujlwm Kev Sib Txuas Lus hauv Txoj Haujlwm

Cov ntaub ntawv no tau lees paub vim tias los ntawm AT cov lus qhia teeb tsa nws tuaj yeem:

  • Kuaj kev sib txuas lus ntawm Arduino thiab Bluetooth;
  • Kuaj qhov ua yuam kev hauv kev ua haujlwm ntawm Bluetooth module, vim tias thaum ua tsis tiav nws yuav tsis teb;
  • Kev teeb tsa ntawm kev hloov pauv nrawm ntawm tus qauv, vim tias qee qhov kev nrawm sib txawv los ntawm qhov nrawm programmed rau Arduino. Thiaj li, kev sib kis yuav ua tsis tiav thiab tus neeg siv yuav xav tias muaj teeb meem nrog tus qauv. Txawm li cas los xij, qhov no yog kev teeb tsa tsis ua tiav thiab paub txog AT cov lus qhia teeb tsa;
  • Lub npe txhawb nqa kev txheeb xyuas thiab ua ke ntawm tus qauv hauv cov npe khoom siv;
  • Thaum kawg, tus password txiav txim siab kev nyab xeeb ntawm cov ntaub ntawv xa mus ntawm cov khoom siv.

Hauv txoj kev no, nws muaj peev xwm nkag siab tias nws tseem ceeb npaum li cas rau kev qhia cov ntaub ntawv thiab cov ntaub ntawv ntawm cov khoom siv.

Yog li, kawm paub tus yam ntxwv thiab tsim cov ntawv thov ruaj ntseg hauv koj cov phiaj xwm nrog Bluetooth module.

Kev lees paub

Kom ua tiav, peb ua tsaug rau koj kev nyeem ntawv thiab kev txhawb nqa ntawm PCBWAY. COM rau kev txhawb nqa Silício Lab hauv kev tsim cov kab lus no rau koj.

Ua tsaug dhau ntawm UTSOURCE los muab cov khoom siv hluav taws xob los tsim txoj haujlwm no.

Pom zoo: