Cov txheej txheem:
- Kauj ruam 1: Daim duab
- Kauj ruam 2: Kho vajtse
- Kauj ruam 3: Software
- Kauj ruam 4: XCTU
- Kauj Ruam 5: Arduino IDE
- Kauj ruam 6: Circuit Court
- Kauj Ruam 7: Teeb Kho Vajtse
- Kauj ruam 8: PyCharm
- Kauj Ruam 9: Tsim Python Script hauv PyCharm
- Kauj ruam 10: Khiav Koj Txoj Haujlwm
Video: Kev Ua Si Ib Leeg Yooj Yim - Python + XBees + Arduino: 10 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Nov yog qhov kev ua si ua haujlwm li cas: Koj muaj 4 sim kwv yees ib tsab ntawv ntawm 'a'-'h'-> Kwv yees tsab ntawv raug: Koj yeej! ?-> Kwv yees tsab ntawv tsis raug: Ua si dhau los?-> Kwv yees lwm tus yam ntxwv sab nraud ntawm 'a'-'h': Game tas? Koj Arduino yuav qhia rau koj paub cov lus teb los ntawm kev tso tawm ntawm 16 × 2 LCD. LEDs tig rau hauv cov xim sib txawv yog qhov kwv yees siab dua/qis dua lossis raug lossis tsis raug.
Kauj ruam 1: Daim duab
Kauj ruam 2: Kho vajtse
Dab tsi koj yuav xav tau Arduino board (Mega), 16 × 2 LCD zaub, 10K ohm potentiometer, XBee S2 xov tooj cua (2), Pawg thawj coj tawg rau XBee module, XBee Explorer USB, LEDs (3), jumper xov hlau, USB cable (A- rau-B), 9V roj teeb + txuas thiab lub thawv ntawv.
Kauj ruam 3: Software
Arduino ID Download tau: https://www.arduino.cc/en/Main/Software PyCharmDownload: https://www.jetbrains.com/pycharm/download/#section=windowsXCTUDownload: https://www.digi.com/products /embedded-systems/digi-xbee/digi-xbee-tools/xctu
Kauj ruam 4: XCTU
X1. Txuas ib qho ntawm koj lub XBee xov tooj cua rau hauv Explorer module thiab txuas cov qauv rau koj lub khoos phis tawj USB chaw nres nkoj. Tua tawm XCTU program. X2. Nyem "Tshawb nrhiav cov cuab yeej" thiab xaiv qhov chaw nres nkoj kom raug tshuaj xyuas. Nyem “Tom ntej”. X3. Xaiv qhov chaw nres nkoj tsis tau teeb tsa thiab nyem "Ua tiav". X4. Koj lub xov tooj cua yuav tsum tau tshawb pom hauv qab "Cov cuab yeej pom" cov npe. Nyem "Ntxiv cov cuab yeej xaiv". X5. Nyem rau ntawm "Nyeem" hauv Modem Configuration screen kom pom cov firmware nyob hauv lub xov tooj cua ntawd. Txhua lub xov tooj cua XBee yuav tsum tau khiav lub khoos phis tawj tshiab tshaj plaws ntawm ZigBee Tus Saib Xyuas AT lossis ZigBee Router AT. Hloov kho xov tooj cua firmware module los ntawm txhaj "Hloov Kho". X6. Kom tau txais xov tooj cua tham, muaj 3 yam tseem ceeb uas peb yuav tsum tau tshuaj xyuas. Thawj qhov yog "PAN ID". PAN ID yog tus lej network uas cov xov tooj cua no yuav tham. Peb yuav teeb tsa qhov no rau tus nqi tshwj xeeb = 2019 (Koj tuaj yeem xaiv tus nqi nruab nrab ntawm 0 thiab 0xFFFF). X7. Txhua lub xov tooj cua XBee muaj qhov chaw nyob 64-ntsis luam tawm tom qab. Qhov pib (SH) lossis "siab" ib feem ntawm qhov chaw nyob yuav yog 13A200. Qhov kawg lossis "qis" (SL) ib feem ntawm qhov chaw nyob yuav txawv rau txhua lub xov tooj cua. X8. Txhawm rau ua XBee xov tooj cua sib tham nrog, chaw nyob ntawm Router thiab Tus Saib Xyuas tau hloov pauv. X9. Nyem rau ntawm lub pob "Sau" txhawm rau teeb tsa koj lub xov tooj cua. Thaum koj tau teeb tsa koj thawj lub xov tooj cua nrog qhov yuav tsum tau teeb tsa software, maj mam tshem lub xov tooj cua ntawd los ntawm tus kws tshawb fawb module thiab ua tib zoo zaum lub xov tooj cua thib ob hauv tib lub qauv thiab rov ua cov kauj ruam saum toj no.
Kauj Ruam 5: Arduino IDE
A1. Txuas Arduino board (Mega) mus rau ib qho ntawm koj lub computer USB chaw nres nkoj thiab qhib Arduino IDE. A2. Xaiv qhov tseeb chaw nres nkoj thiab pawg thawj coj saib. A3. Upload cov duab kos mus rau Arduino board los ntawm txhaj rau pob Upload. NOTE: Cov duab kos tuaj yeem rub tawm los ntawm no.
Kauj ruam 6: Circuit Court
Txuas XBee lub xov tooj cua teeb tsa ua Tus Kws Saib Xyuas rau hauv koj lub XBee Breakout board thiab txuas nws mus rau Arduino los ntawm kev ua raws cov txheej txheem.
Kauj Ruam 7: Teeb Kho Vajtse
H1. Arduino board (Mega) tau siv lub roj teeb 9V. H2. Txuas XBee lub xov tooj cua teeb tsa ua Router rau hauv koj li XBee Explorer module thiab txuas nws mus rau ib qho ntawm koj lub computer USB chaw nres nkoj.
Kauj ruam 8: PyCharm
Koj tuaj yeem siv ib qho Python IDE, hauv qhov no kuv siv PyCharm. Ua ntej koj pib, nco ntsoov tias cov hauv qab no tau ua tiav:-> Koj tau teeb tsa Python. Koj tuaj yeem tau txais los ntawm: https://www.python.org/downloads/-> Koj tab tom ua haujlwm nrog PyCharm Zej Zog.
Kauj Ruam 9: Tsim Python Script hauv PyCharm
P1. Cia peb pib peb txoj haujlwm: yog tias koj nyob ntawm Lub Vev Xaib Zoo Siab, nyem Tsim Qhov Haujlwm Tshiab. Yog tias koj twb tau txais txoj haujlwm qhib, xaiv Cov Ntaub Ntawv -> Txoj Haujlwm Tshiab. P2. Xaiv Ntshiab Python -> Qhov Chaw (Qhia kom meej cov npe) -> Tus Neeg txhais lus Project: Tshiab Virtualenv ib puag ncig -> Virtualenv cuab yeej -> Tsim. P3. Xaiv lub hauv paus qhov project hauv qhov Project tool window, tom qab ntawv xaiv File -> New -> Python file -> Type the new filename. P4. PyCharm tsim cov ntawv Python tshiab thiab qhib nws rau kho. P5. Txhim kho cov pob hauv qab no: PySerial (lub tsev qiv ntawv Python uas muab kev txhawb nqa rau kev sib txuas txuas nrog ntau yam khoom siv sib txawv) Txhawm rau nruab ib lub pob hauv PyCharm: P6. Cov Ntaub Ntawv -> Chaw. P7. Hauv Txoj Haujlwm, xaiv Txoj Haujlwm Txhais Lus thiab nyem rau ntawm "+" icon. P8. Hauv qhov tshawb nrhiav, ntaus pob uas koj xav tau los nruab thiab nyem rau ntawm Install Package. NETE: Nco ntsoov tias COM tus lej chaw nres nkoj uas tau siv hauv Python code yog qhov ntawm XBee Explorer module txuas nrog lub PC. Tus lej chaw nres nkoj COM tuaj yeem pom hauv Tus Thawj Tswj Ntaus Ntawv -> Chaw Nres Nkoj (COM#)
Kauj ruam 10: Khiav Koj Txoj Haujlwm
ReferencesLiquidCrystal - “Nyob Zoo Ntiaj Teb!” Https://www.arduino.cc/en/Tutorial/HelloWorldPySerialhttps://pyserial.readthedocs.io/en/latest/shortintro.htmlFritzinghttps://fritzing.org/home/Arduino Megahttps://store.arduino.cc/usa/mega-2560-r3Building Wireless Sensor Networks los ntawm Robert Faludihttps://shop.oreilly.com/product/9780596807740.do