Cov txheej txheem:

Versatile NearBot: 11 Kauj Ruam (nrog Duab)
Versatile NearBot: 11 Kauj Ruam (nrog Duab)

Video: Versatile NearBot: 11 Kauj Ruam (nrog Duab)

Video: Versatile NearBot: 11 Kauj Ruam (nrog Duab)
Video: Muaj tsis ntshai tuag 7/1/2018 2024, Kaum ib hlis
Anonim
Image
Image

Cov lus qhia no yuav qhia koj yuav ua li cas tsim kom muaj ntau yam neeg hlau ua rau tuaj yeem txav qee yam xws li khawm, hloov, lossis hu rau ntau yam khoom siv thaum koj (nrog koj lub xov tooj lossis lub teeb ci hauv koj lub hnab ris) nyob ze. Qhov no txhais tau tias nws tuaj yeem qhib lub qhov rooj thiab rov kaw lub qhov rooj li * tsuas yog koj * hla los ntawm, kaw lub qhov dej tawm kom koj tuaj yeem hla cov dej tsis zoo ib yam li thaj tsam ntawm Mauxes, txo tus neeg hais lus qis thaum koj nyob hauv lub nkas-las. chav nyob, ua kom lub iPod ua suab nrov nkag los lossis qhia tso dag (Jaden Smith tweet?) thaum koj nyob hauv chav, lossis ncua yeeb yaj kiab thaum koj sawv los siv chav dej.

Txoj haujlwm no tsis xav tau cov cuab yeej tshwj xeeb lossis cov cuab yeej tshwj xeeb

Yog tias koj txaus siab rau cov lus qhia no txaus, thov txiav txim siab pov npav rau qhov qhia hauv Robotics 2017 kev sib tw!

Kauj Ruam 1: Tau Txais Cov Khoom Kho Vajtse

Koj yuav xav tau:

  • NodeMCU v2 lossis V3
  • Micro 9G Servo Motor txog $ 1.40 USD dawb thauj khoom ntawm eBay lossis Aliexpress
  • Arduino Jumper Wires Poj Niam rau Txiv Neej.
  • Lub casing rau NearBot - Kuv siv lub thawv yas seem uas kuv pom.
  • Micro USB cov ntaub ntawv cable (seem xov tooj)
  • USB hwj chim qhov chaw (seem xov tooj charger)

Yog tias koj tsis muaj lub xov tooj smartphone nrog lub xov tooj ntawm tes hotspot, koj tseem yuav xav tau:

  • ESP-01 module txog $ 2.50 USD dawb thauj khoom ntawm DealExtreme, GearBest, Ebay, lossis Aliexpress.
  • 1 Pair AAA roj teeb
  • dual AAA roj teeb tuav nrog hloov

Kauj ruam 2: Pib Pib

Cov kauj ruam no muaj cov lus qhia pib sai yog tias koj nyiam qhov khoom ntawd. Tus so ntawm cov lus qhia no mus ib kauj ruam zuj zus thiab ntxiv cov ntaub ntawv ntxaws ntxiv

// Cov npe khoom: // NodeMCU V3 (Lolin) ESP8266 microcontroller

// SG90 9G Servo Tsav

// USB Power Bank lossis USB phab ntsa adapter.

// Micro USB cov ntaub ntawv/them nyiaj cable

// Arduino txiv neej rau poj niam hom jumper xov hlau

Ua ntej koj pib:

// 1. Yog tias koj tseem tsis tau rub tawm Arduino IDE, tau txais nws dawb (pub dawb xaiv) ntawm:

// 2. qhib Arduino IDE (yog tias koj tsis tau nyeem qhov no hauv Arduino IDE lawm!) …

// 3. Mus rau cov ntaub ntawv thiab nyem rau ntawm qhov nyiam nyob hauv Arduino IDE …

// 4. theej cov cai hauv qab no hauv Tus Thawj Saib Xyuas Ntxiv: //https://arduino.esp8266.com/stable/package_esp8266com_index.json

// 5. nyem OK kom kaw qhov nyiam tab …

// 6. Mus rau cov cuab yeej thiab pawg thawj coj saib, thiab tom qab ntawd xaiv tus thawj tswj hwm…

// 7 ib. Nkag mus rau esp8266 los ntawm esp8266 zej zog thiab teeb tsa software rau Arduino …

// 8 ib. Koj yuav xav tau rub tawm thiab teeb tsa CH340 tus tsav tsheb yog tias koj tsis tuaj yeem tau txais NodeMCU tham nrog koj Arduino IDE:

// Thaum tag nrho cov txheej txheem saum toj no tau ua tiav peb tau nyeem rau program peb esp8266 NodeMCU microcontroller nrog Arduino IDE.

//9.select NodeMCU V1.0 ESP12E los ntawm cov ntawv qhia zaub mov board /

/10. Xaiv qhov chaw nres nkoj COM koj tab tom siv.

// 11 ib. xaiv cov cai (rub tawm los ntawm www.makersa.ga) thiab nyem rau upload. /

/12. Plug lub servo rau hauv NodeMCU siv cov xov hluav taws xob. D0 rau teeb liab, hauv av rau hauv av, +VCC rau VO lossis 3V. /

/13. Kho lub servo horn siv tus ntsia hlau.

// 14 ib. Kho qhov siab tshaj plaws thiab yam tsawg kawg nkaus ntawm kev txav mus los siv cov cai.

// 15 ib. Rov upload dua rau NodeMCU thaum twg cov cai tau hloov kho tshiab.

// Koj yuav pom nws tseem ceeb los txiav txim seb NodeMCU version twg koj muaj. Nov yog phau ntawv sib piv:

frightanic.com/iot/comparison-of-esp8266-no… // NodeMCU v1 pinout diagram: https://frightanic.com/iot/comparison-of-esp8266-no… // NodeMCU v2 pinout daim duab: https://frightanic.com/iot/comparison-of-esp8266-no… // NodeMCU v3 pinout daim duab:

// Kev piav qhia ntawm rigs:

// Ua los ntawm NodeMCU ESP8266 microcontroller, roj teeb lossis USB fais fab mov, thiab SG90 Servo

// Koj tuaj yeem siv qhov hloov pauv thib ob esp8266 ua lub teeb liab hotspot AP tsis txhob siv lub xov tooj smartphone, tsis tas yuav tsim lub program.

Kauj Ruam 3: Tau Txais Cov Khoom Siv Software

Koj yuav tsum xub rub tawm Arduino IDE dawb

Arduino Web Editor tsis ua haujlwm nrog NodeMCU thaum lub sijhawm kuv sau qhov no, yog li koj yuav tsum teeb tsa IDE rau koj lub khoos phis tawj.

Koj kuj tseem yuav tsum tuav cov ntaub ntawv NearBot los ntawm www. MakerSa.ga - Cov ntaub ntawv rub tawm txuas rau qhov haujlwm no tau teev nyob rau ntawm qhov chaw ntawd.

Kauj ruam 4: Nruab Drivers thiab Board Profiles

Qee Cov Ntaub Ntawv Pab Tau
Qee Cov Ntaub Ntawv Pab Tau

Sab hauv Zip NearBot koj rub tawm thiab unzipped yuav yog tus tsav tsheb rau NodeMCU module. Nruab cov ntawd rau koj lub computer.

Yog tias cov ntawd tsis ua haujlwm rau koj, koj yuav tuaj yeem nrhiav CH340G tsav tsheb ntawm wemos.cc/downloads

Koj NodeMCU yuav tsis siv CH340G nti, yog li koj yuav xav tawm tswv yim nrog tus tsav tsheb uas koj tab tom nrhiav, thiab kuv yuav teb nrog qhov rub tawm txuas rau tus tsav ntawd.

  1. Tom ntej no, qhib Arduino IDE thiab mus rau File PreferencesAdministrative Boards Manager hauv Arduino IDE.
  2. Paste cov cai hauv qab no muaj:
  3. Nyem OK kom kaw qhov nyiam tab.
  4. Mus rau cov cuab yeej thiab pawg thawj coj saib, thiab tom qab ntawd xaiv tus thawj tswj hwm pawg thawj coj saib.
  5. Nkag mus rau "esp8266 los ntawm esp8266 zej zog" thiab teeb tsa software rau Arduino.

Thaum tag nrho cov txheej txheem saum toj no tau ua tiav peb tau npaj rau phiaj xwm peb esp8266 NodeMCU microcontroller nrog Arduino IDE!

Kauj Ruam 5: Qee Cov Ntaub Ntawv Pab Tau

Qee Cov Ntaub Ntawv Pab Tau
Qee Cov Ntaub Ntawv Pab Tau
Qee Cov Ntaub Ntawv Pab Tau
Qee Cov Ntaub Ntawv Pab Tau

Koj tuaj yeem pom nws yooj yim los xam tawm qhov NodeMCU version uas koj muaj. Nov yog phau ntawv sib piv:

frightanic.com/iot/comparison-of-esp8266-nodemcu-development-boards/

Txhua qhov version muaj tus lej sib txawv. Kuv yuav lub v3 (Lolin) version vim tias nws muaj 5V tso tus pin rau lub zog rau Servo lub cev muaj zog. Thaum kawg kuv siv lub 3 volt lub hwj chim hloov pauv rau kev nyab xeeb (Lub NodeMCU I/O pins tsis yog 5V zam), tab sis koj yuav xav siv 5V tus pin vim tias cov cuab yeej siv hom servo motors tau teev tseg rau 4.5 txog 5 volt zog.

Kauj Ruam 6: Thauj Cov Code rau NodeMCU

Thauj cov Code rau NodeMCU
Thauj cov Code rau NodeMCU
Thauj cov Code rau NodeMCU
Thauj cov Code rau NodeMCU
  1. Txuas NodeMCU rau hauv koj lub computer siv ib qho micro USB cable.
  2. Qhib Arduino IDE, thiab hauv qab "Boards", xaiv "ESP12E", thiab COM chaw nres nkoj rau NodeMCU.
  3. Hauv IDE, mus rau FileOpen thiab xauj cov ntawv zip yav tas los rub tawm los ntawm makersa.ga kom qhib Arduino kos duab hu ua "ProximityActuator013017DonovanMagryta.ino"
  4. Tom qab ntawd, hloov kab kab ntawv uas muaj qhov no ntxiv lub npe thiab tus password ntawm koj lub teeb WiFi. Xav paub ntau ntxiv hauv qab no! Piv txwv li:

const char* ssid = "mywifi"; // Muab koj lub npe hotspot tso rau hauv kab lus

const char* password = "mywifipassword"; // Muab koj lo lus zais hotspot tso rau hauv kab lus

Tom qab ntawv nyem "upload" txhawm rau nyem qhov chaws mus rau NodeMCU pawg thawj coj.

NearBot siv lub teeb ci WiFi lub hnab nqa los txheeb xyuas koj thiab kwv yees nrug deb. Ib yam li cov yuam sij nyob ze qee lub tsheb tshiab muaj qhov qhib lub qhov rooj rau lub tsheb thaum koj mus txog.

Koj tuaj yeem siv koj lub xov tooj ntawm tes xov tooj ntawm tes hotspot ua lub teeb, lossis hloov pauv siv ESP-01 WiFi tus nqi pheej yig siv los ntawm ib lub roj teeb AAA lossis lub roj teeb lithium 3.7v me me. Tsis tas yuav tsum tau teeb tsa ESP-01, nws ua rau lub hom phiaj hotspot thaum nws tau qhib. Daim duab qhia hluav taws xob rau qhov ntawd tau qhia ntawm theem no.

Kauj Ruam 7: Txuas tus Servo rau NodeMCU

Koj yuav xav tau qee lub xov hlau jumper los ntsaws qhov servo rau hauv NodeMCU V3.

Daim duab qhia chaw yog yooj yim.

Pin D0 rau lub teeb liab hauv cov hlau lead (lub teeb xim daj tshaj plaws ntawm qhov kev pabcuam. Feem ntau yog daj lossis dawb.)

Pin 3V lossis tus pin VO rau 5V cov hlau lead nkag (thib ob lub teeb xim xim tshaj plaws ntawm qhov kev pabcuam, feem ntau yog liab lossis txiv kab ntxwv.)

Pin GND rau hauv av (cov xim dub tshaj plaws ntawm qhov kev pabcuam, feem ntau yog xim av lossis xim dub.)

Kauj Ruam 8: Txhim Kho Tus NearBot

Txoj cai hloov pauv lub teeb liab mus rau kev kwv yees deb. Nws ua haujlwm tau zoo rau cov tshuaj tiv thaiv nrug tsawg dua 2 meters lossis 6.5 ko taw. Vim tias nws yog kev hloov pauv ncaj qha, nws tsis yooj yim rau kev nyob deb dua 3 metres vim nws tuaj yeem muaj peev xwm ua tau nrog txoj hauv kev suav tau zoo dua. Ntxiv rau qhov ntawd tom qab.

Tej zaum koj yuav xav hloov kho qhov chaw servo horn (caj npab dawb me me uas txav) nyob rau qhov chaw. Qhov no yog ua tiav los ntawm kev yooj yim unscrewing lub caj npab servo nrog tus ntsia hlau, thiab rov muab tso rau nws.

Ib feem tom ntej yog txhawm rau kho qhov siab tshaj plaws thiab qib qis tshaj ntawm kev txav mus los siv cov cai.

Qhov no tuaj yeem ua tiav los ntawm kev hloov cov lej muaj nyob hauv kab uas zoo li no:

myservo.write (10); // txav servo caj npab mus rau 10 degrees kev sib hloov

Koj tseem tuaj yeem kho lub teeb liab lub zog hloov pauv los ntawm kev hloov tus lej tsis zoo hauv kab uas zoo li no:

yog (rssi> -30 && rssi <-5) {// Yog tias lub teeb liab muaj zog dua -30, thiab tsis muaj zog dua -5. tom qab ntawd ua cov hauv qab no …

Kauj Ruam 9: Nws Ua Haujlwm Li Cas

  1. NearBot xub txuas rau lub hotspot ua ntej raws li cov neeg siv mus.
  2. Nws txheeb xyuas RSSI (tau txais lub teeb liab lub zog) thiab hloov qhov ntawd mus rau kwv yees li deb.
  3. Thaum qhov kev ncua deb nyob hauv thaj tsam tshwj xeeb, nws txav lub cav servo caj npab mus rau txoj haujlwm 1.
  4. Txwv tsis pub, servo motor tau txav mus rau txoj haujlwm 2.

Thaum kuv sim qhov no, qhov RSSI tuning (-50) txav cov servo mus rau txoj haujlwm 1 thaum qhov deb yog 0 txog 1.5 meter nrog ESP-01 lub teeb lossis lub xov tooj hotspot hauv kuv lub hnab tshos.

RSSI feem ntau poob hauv qhov ntau ntawm -90 txog -20, nrog -20 yog lub zog tshaj plaws ntawm lub teeb liab.

Yog tias koj qhib Arduino IDE Serial Monitor thaum lub NearBot tau txuas rau hauv lub khoos phis tawj, nws yuav tso tawm lub teeb liab lub zog thiab ua rau cov ntsiab lus nyob rau lub sijhawm tiag tiag rau koj kom muaj txiaj ntsig zoo.

Nov yog tus lej ua tiav:

Ua ntej koj pib:

// 1. Yog tias koj tseem tsis tau rub tawm Arduino IDE, tau txais nws dawb (pub dawb xaiv) ntawm: https://www.arduino.cc/en/Main/Software // 2. qhib Arduino IDE (yog tias koj tsis tau nyeem qhov no hauv Arduino IDE lawm!)… // 3. Mus rau cov ntaub ntawv thiab nyem rau ntawm qhov nyiam nyob hauv Arduino IDE… // 4. luam qhov txuas hauv qab no hauv Tus Thawj Saib Xyuas Ntxiv: //https://arduino.esp8266.com/stable/package_esp8266com_index.json // 5. nyem OK kom kaw qhov nyiam tab… // 6. Mus rau cov cuab yeej thiab pawg thawj coj saib, thiab tom qab ntawd xaiv tus thawj tswj hwm… // 7. Nkag mus rau esp8266 los ntawm esp8266 zej zog thiab teeb tsa software rau Arduino… // 8. Koj yuav xav tau rub tawm thiab teeb tsa CH340 tus tsav tsheb yog tias koj tsis tuaj yeem tau txais NodeMCU tham nrog koj Arduino IDE: https://www.arduino.cc/en/Main/Software // Thaum tag nrho cov txheej txheem saum toj no tau ua tiav peb nyeem los ua haujlwm peb esp8266 NodeMCU microcontroller nrog Arduino IDE. Koj yuav xav paub seb NodeMCU version twg koj muaj. Nov yog phau ntawv qhia sib piv: https://www.arduino.cc/en/Main/Software // Ua los ntawm NodeMCU ESP8266 microcontroller, roj teeb lossis USB fais fab mov, thiab SG90 Servo // Koj tuaj yeem siv qhov thib ob uas tsis tau hloov kho esp8266 module ua lub teeb ci hotspot AP tsis txhob siv lub xov tooj smartphone. // NearBot Circuit: // D0 tus pin rau Servo teeb liab xaim (lub teeb pom kev zoo tshaj plaws xaim) // 3V tus pin rau servo 5v xaim (nruab nrab xaim) (sib txuas ua ke mus rau usb cable lossis VO tus pin ntawm NodeMCU yog tias koj muaj V3. / /USB lub zog rau USB ntsaws rau ntawm NodeMCU // GND tus pin rau Servo Av xaim (cov xim dub tshaj plaws) // Nco tseg kab pib nrog ob txoj hauv kev mus rau tom ntej, thiab tsis quav ntsej los ntawm lub khoos phis tawj. Cov ntawv sau tsuas yog rau peb tib neeg! #Suav nrog #suav nrog // Tej zaum yuav xav tau rau kev luam ntawv txuas ntxiv. #Suav nrog // Lub tsev qiv ntawv Servo #define D0 16 // Txheeb tus pin los ua tus lej txuas yooj yim dua. #Define D1 5 // I2C Bus SCL (moos) #define D2 4 // I2C Bus SDA (cov ntaub ntawv) #define D3 0 #define D4 2 // Tib yam li "LED_BUILTIN", tab sis inverted logic #define D5 14 // SPI Bus SCK (moos) #define D6 12 // SPI Bus MISO #define D7 13 // SPI Tsheb npav MOSI #define D8 15 // SPI Bus SS (CS) #define D9 3 // RX0 (Serial console) #define D10 1 // TX0 (Serial console) Servo myservo; // Tsim cov khoom siv servo npe myservo // Xov tooj lossis ntxiv ESP8266 module teeb tsa rau hotspot AP hom: const ch ar* ssid = ""; // Muab koj lub npe hotspot tso rau hauv kab lus cim char* password = ""; // Muab koj tus lej hotspot lo lus zais tso rau hauv kab lus tsis muaj teeb tsa () {Serial.begin (115200); // teeb tsa tus lej baud tus lej kom lub microcontroller tuaj yeem tham nrog cov ntawv luam tawm hauv lub Arduino IDE - Koj yuav xav hloov nws mus rau 9600 xwb! myservo.attach (D0); // txuas cov servo ntawm tus pin D0 aka GPIO16 rau cov khoom siv servo - Saib ntxiv ntawm: https://www.esp8266.com/viewtopic.php?f=32&t=8862#… myservo.write (10); // txav servo caj npab mus rau 10 degrees kev sib hloov Serial.println ("Xauv"); // tso tawm cov lus saib xyuas lo lus "Xauv" WiFi.mode (WIFI_STA); // Teeb wifi rau Chaw Nres Tsheb WiFi.begin (ssid, password); // Txuas mus rau hotspot beacon} void loop () {// Lub voj rov ua dua thiab nrawm dua yog tias (WiFi.status ()! = WL_CONNECTED) {// Yog wifi tsis txuas nrog, ua cov hauv qab no… Serial.println ("Tsis tuaj yeem tau txais kev sib txuas wifi"); myservo.write (10); // Tsiv caj npab servo mus rau 10 degrees Serial.println ("Xauv"); } lwm tus {// Yog WiFi YOG txuas nrog, tom qab ntawd ua… ntev rssi = WiFi. RSSI (); // Tsim qhov sib txawv uas muaj npe rssi thiab muab nws ua haujlwm uas rov ua lub teeb liab lub zog nyeem ntawm lub hotspot beacon Serial.print (rssi); // tso tawm rssi nyeem ntawv rau tus saib xyuas yog tias (rssi> -50 && rssi <-5) {// Yog tias lub teeb liab lub zog muaj zog dua -50, thiab tsis muaj zog dua -5. tom qab ntawd ua cov hauv qab no… myservo.write (170); // Tig caj npab servo rau 170 degrees Serial.println ("Xauv"); } lwm tus {// Yog tias cov xwm txheej saum toj no tsis tau ntsib ua raws li hauv qab no … myservo.write (10); // Hloov caj npab servo rov qab mus rau 10 degrees. Serial.println ("Xauv"); }}}

Kauj Ruam 10: Koj Yuav Tsum Paub …

Tsis lees paub:

Tam sim no rov ua dua ntawm Txoj Cai NearBot ua haujlwm tau zoo rau kev ncua deb tsawg dua 2 meters lossis 6.5 ko taw. Tshaj li qhov ntawd, nws tau txais qhov tseeb dua, tab sis tseem ua haujlwm.

Qhov no tuaj yeem kho tau, tab sis tam sim no kuv tsis paub yuav ua li cas. Kuv yuav nyiam nws yog tias ib tus neeg yuav ua haujlwm nrog kuv yog li kuv tuaj yeem hloov kho cov lus qhia no nrog cov txheej txheem tseeb dua ntawm kev suav nrug!

Cov kev txuas no tuaj yeem siv tau yooj yim: YouTuber CNLohr txhim kho qhov deb thiab txoj haujlwm paub qhov tseeb firmware rau ESP8266 nrog kev ua tiav tsawg:

Espressif tau tsim Lub Sijhawm Dav Dav Kev Tshawb Fawb Kev Tshawb Fawb uas yuav ua haujlwm nrog Arduino IDE rau ESP8266, tab sis tsis tau tso nws tawm:

SubPos txoj haujlwm tso rau siv ESP8266 cov qauv thiab Txoj Kev Poob Xeem, uas yog qhov kuv tsis paub yuav siv li cas hauv Arduino IDE:

Kuv pom ib qho piv txwv hauv Java lus, tab sis kuv tsis paub yuav rov ua li cas yog Arduino IDE:

nrug deb = Math.pow (10.0, ((double) (tx_pwr/10)) - rx_pwr - 10*Math.log10 (4*Math. PI/(c/zaus)))/(20*mu)));

Kauj Ruam 11: Nov Yog Txhua Yam

Yog tias koj ua koj tus kheej NearBot, tshaj tawm koj li "Kuv tau ua nws" hauv cov lus hauv qab no!

Yog tias koj muaj tswv yim ntau ntxiv txog yuav siv Dab Tsi NearBot platform rau, thov tawm tswv yim rau koj lub tswv yim! Nws tuaj yeem yog kev tshoov siab rau lwm tus neeg siv qhia!

Yog tias koj nyiam qhov kev qhia no, thov txiav txim siab pov npav rau qhov qhia hauv kev sib tw!

Pom zoo: