Cov txheej txheem:
- Kauj Ruam 1: Qhov Chaw
- Kauj ruam 2: Khoos phis tawj khoos phis tawj
- Kauj Ruam 3: Kev thaiv kab hlau
- Kauj Ruam 4: Kev Txhim Kho MicroPython
- Kauj ruam 5: Teeb Network
- Kauj Ruam 6: Nruab Qhov Kev Pab Cuam
- Kauj Ruam 7: Kev txhim kho yav tom ntej
Video: MicroPython IoT Rover Raws li WEMOS D1 (ESP-8266EX): 7 Cov Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
** Hloov tshiab: Kuv tshaj tawm cov vis dis aus tshiab rau v2 nrog rab yaj phom **
Kuv tuav Robotics kev cob qhia rau cov menyuam yaus thiab kuv ib txwm tab tom nrhiav kev lag luam kom tsim tau cov phiaj xwm txaus nyiam. Thaum Arduino clones pheej yig, nws siv C/C ++ lus uas menyuam tsis paub. Ib qho ntxiv, nws tsis muaj WiFi-built-in uas yuav tsum tau rau IoT cov haujlwm. Ntawm qhov tod tes, thaum Raspberry Pi muaj WIFI thiab cov menyuam tuaj yeem ua haujlwm siv Python, nws tseem yog lub platform kim kom tsuas yog tswj ob peb lub GPIO chaw nres nkoj kom qhib cov khoom siv thiab tua. Kuv xav tau ib yam dab tsi nyob nruab nrab ntawm qhov muaj peev xwm WIFI thiab Python. Nws zoo nkaus li kuv pom kuv cov lus teb hauv MicroPython flashed mus rau qhov pheej yig ESP8266-based board.
Micropython yog dab tsi?
Raws li nws lub vev xaib, MicroPython yog qhov ua tau zoo thiab ua tau zoo ntawm Python 3 cov phiaj xwm cov lus uas suav nrog ntu me me ntawm Python tus qauv tsev qiv ntawv thiab nws tau ua kom zoo los ua haujlwm ntawm microcontrollers thiab hauv ib puag ncig txwv (xws li ESP8266). Nws yog qhov tseem ceeb Python IDE ntawm lub nti. Ib qhov txiaj ntsig loj yog tias koj tuaj yeem tsim cov cai thiab hloov nws ntawm yoov siv lub web-browser tus thov kev pab hu ua Webrepl. (Sim ua qhov ntawd hauv Arduino.) Koj kuj tseem tuaj yeem pom cov ntaub ntawv sensor hauv lub sijhawm tiag tiag ntawm Webrepl es tsis txhob cia siab rau cov ntaub ntawv txiav lossis lub vijtsam LED hauv Arduino.
ESP8266 yog dab tsi?
Hauv ntej, xav txog nws li Arduino nrog lub peev xwm sib txuas hauv network. Koj tuaj yeem siv Arduino IDE los ua haujlwm ESP8266 cov laug cam hauv C/C ++ lossis koj tuaj yeem nyem nws nrog NodeMCU lossis MicroPython. Hauv txoj haujlwm no, Kuv yuav ua kom pom MicroPython mus rau ESP8266 lub rooj tsavxwm.
Kuv txiav txim siab kom tau WEMOS D1 uas yog raws li ESP8266-12EX rau txoj haujlwm yooj yim no uas kuv yuav tau caij tsheb 2WD siv lub web browser. Muaj lwm cov laug cam uas tau tsim los rau MicroPython tab sis kuv xav tau qee yam pheej yig uas kuv tuaj yeem muab pov tseg yog tias nws tsis tau raws li qhov kuv xav tau. Raws li qhov xav tau, nws ua tau raws li txhua qhov kuv xav tau thiab feem ntau kuv yuav koom nrog WeMos thiab Micropython rau hauv cov phiaj xwm yav tom ntej.
Kauj Ruam 1: Qhov Chaw
- Wemos D1 lossis ib qho ESP8266 raws cov laug cam
- Lub cev tiv thaiv kab mob (Kuv siv tus pheej yig L293D los ntawm AliExpress)
- Cov roj teeb tuav rau 4 x AA thiab 9V (4 x AA roj teeb yog rau lub cav thiab 9V yog rau Wemos board)
- 2WD tsheb chassis
- Dupont cables
Tej zaum yuav xav tau cov hlau txuas, tus ntsia hlau tsav tsheb thiab rab phom nplaum los tso txhua yam ua ke.
Kauj ruam 2: Khoos phis tawj khoos phis tawj
Ua ntej, sib sau lub chassis raws li cov lus qhia.
Tom qab ntawd, kub kua nplaum lwm yam khoom raws li qhia.
Cov xov hlau yuav tsum tau muab txuas rau lub tshuab hluav taws xob thiab siv cov kua nplaum kub los txhawb lub dav hlau sib txuas.
Muab qhov hloov me me rau 4AA lub roj teeb tuav. Qhov no yuav qhib/tua lub zog rau lub cav thaiv.
Kauj Ruam 3: Kev thaiv kab hlau
Ua raws li kuv daim kab xev raws li qhia.
Wemos rau Motor Shield:
D1 IB 2
D2 IN1 D3 IN4 ** hla D4 D5 IN3 GND -> GND
Tsav Shield rau Tsav/Lub Hwj Chim:
Lub davhlau ya nyob twg -> Sab laug Tsav
B davhlau ya nyob twg -> Txoj Cai Tsav Tsheb VCC -> Roj teeb (+) GND -> Roj teeb (-)
Kauj Ruam 4: Kev Txhim Kho MicroPython
Ua ntej, Wemos muaj cov lej/USB nti raws CH304G. Nov yog tib lub nti pom hauv pheej yig Arduino-clones thiab koj yuav tsum teeb tsa tus tsav tsheb kom raug rau Mac lossis PC. Ua raws cov lus qhia ntawm lub xaib no txhawm rau txhim kho tus tsav tsheb.
Txuas Wemos rau koj lub computer thiab paub meej tias koj lub khoos phis tawj tuaj yeem tshawb pom Wemos. Ntawm Mac, khiav cov lus txib hauv qab no thiab koj yuav pom lub cuab yeej hu ua /dev/tty.wchusbserial640.
$ ls -lt /dev /tty* | taub hau
crw-rw-rw- 1 lub hauv paus log 17, 4 Mar 2 23:31 /dev/tty.wchusbserial640
Yog tias koj nyob hauv PC, koj tuaj yeem siv Cov Lus Qhia no ua tus siv.
Tom ntej no, koj yuav tsum teeb tsa Python 2 lossis 3 ntawm koj lub khoos phis tawj txij li lub cuab yeej nyem, esptool.py, raws li Python. Thaum MicroPython phau ntawv qhia tuaj yeem hais tias lub cuab yeej tsuas yog ua haujlwm nrog Python 2.7, Kuv muaj peev xwm khiav qhov ntawd hauv Python 3 yam tsis muaj teeb meem. Rub tawm Python tshiab los ntawm https://www.python.org thiab ua raws cov lus qhia teeb tsa rau koj lub PC lossis Mac.
Thaum kawg, koj yuav tsum tau teeb tsa MicroPython ntawm Wemos. MicroPython qhov chaw muaj kev qhia zoo heev txog yuav teeb tsa MicroPython ntawm ESP8266 li cas. Tsuas yog ua raws cov lus qhia teeb tsa hauv Kev Pib nrog MicroPython ntawm ESP8266.
Hauv qab no yog cov lus txib kuv siv:
$ esptool.py --port /dev/tty.wchusbserial640 lwv_flash
esptool.py v1.3 Txuas…. Khiav Cesanta flasher stub… Erasing flash (qhov no yuav siv sijhawm ib pliag)… Lej siv sijhawm 10.5 thib ob
$ esptool.py --port /dev/tty.wchusbserial640 write_flash -fm dio -fs 32m -ff 40m 0x00000 esp8266-20170108 -v1.8.7.bin
esptool.py v1.3 Txuas…. Khiav Cesanta flasher stub… Flash params teeb tsa rau 0x0240 Sau 589824 bytes ntawm 0x0 hauv 50.8 vib nas this (92.8 kbit/s)… Tawm …
MicroPython tam sim no tau teeb tsa ntawm koj lub rooj tsavxwm!
Kauj ruam 5: Teeb Network
Thaum MicroPython tam sim no tau teeb tsa ntawm koj Wemos, nws tseem tsis tau txuas nrog koj lub network tam sim no. Koj yuav tsum xub xub qhib lub network. Ntawm Mac, ua raws SCREEN cov lus txib kom pib ua ntu ntu ntu rau Wemos.
$ screen /dev/tty.wchusbserial640 115200
Thaum koj pom lub vijtsam dawb, ntaus RETURN kom pom sai:
>>
(Nco tseg: Txhawm rau tawm, ntaus CTRL-A CTRL-)
Tam sim no, cia kom muaj kev nkag mus rau webclient. Ntaus "ntshuam webrepl_setup" los teeb tsa qhov program. Nkag mus E kom pab tau WebREPL thiab tom qab ntawv teeb tus password. Rov pib dua kom qhib kev hloov pauv.
>> ntshuam webrepl_setup
WebREPL daemon pib-pib xwm txheej: xiam oob khab Koj puas xav tau (E) nable lossis (D) ua tau kom nws khiav ntawm khau raj? (Kab kab kom txiav)> E Txhawm rau pab kom WebREPL, koj yuav tsum teeb tus password rau nws tus password tshiab: xxxxx Paub meej tias tus lej password: xxxxx Kev hloov pauv yuav raug qhib tom qab rov pib dua Koj puas xav rov pib dua tam sim no? (y/n) y
Thaum kawg, rub tawm Webrepl tus thov kev pab rau koj lub tshuab. Qhov no yog nyob ntawm yeem tab sis tus neeg siv khoom tuaj nrog lwm cov cuab yeej muaj txiaj ntsig uas koj yuav xav siv tom qab. Piv txwv li, webrepl_cli.py yog cov lus txib kom luam cov ntaub ntawv rau Wemos hauv scp-zoo li syntax. Siv git los rub tus neeg siv khoom. (Nruab qhov cuab yeej git yog tias koj tseem tsis tau muaj.)
git clone
Qhib koj lub vev xaib thiab ntawm URL teb, nkag mus rau qhov chaw koj rub tawm webrepl tus thov cov ntaub ntawv qhov chaw xws li:
file: ///Users/xxxxx/wemos/webrepl/webrepl.html
Qhov no yuav tsum tso saib cov neeg siv webrepl ntawm koj tus browser. Ua ntej koj tuaj yeem txuas rau nws, koj yuav tsum xub txuas rau nws WIFi Access Point. Yog tias koj saib WIFI muaj rau koj lub khoos phis tawj, koj yuav pom lub network pib nrog MicroPython-xxxx. Txuas mus rau lub network ntawd. (Lus ceeb toom: Thaum koj txuas rau lub network ntawd, koj yuav plam koj li kev siv Internet.)
Rov qab mus rau koj tus neeg siv webrepl thiab nyem rau Txuas. Nws yuav tsum tam sim rau tus password. Nkag mus rau koj tus lej Wemos thiab koj yuav tsum txuas.
Txais tos rau MicroPython!
Lo lus zais: WebREPL txuas nrog >>>
Koj Wemos tseem tab tom ua haujlwm hauv AccessPoint Hom. Thaum qhov no ua tau zoo, Kuv xav kom nws khiav hauv Chaw Nres Tsheb qhov uas nws txuas rau kuv lub tsev WIFI kom kuv lub khoos phis tawj tuaj yeem nkag mus tau los ntawm WIFI hauv tsev thiab tseem muaj Internet nkag tau. Txhawm rau ua qhov ntawd, koj yuav tsum tsim cov ntaub ntawv hu ua boot.py nrog kev teeb tsa network thiab xa nws mus rau Wemos.
Nov yog qhov piv txwv boot.py. Hloov ssid thiab password rau koj lub tsev WIFI network. Tsis tas li, kuv xav muab nws tus IP zoo li qub ntawm 192.168.0.32. Hloov nws mus rau koj lub tsev WIFI tus IP chaw nyob.
boot.py (koj tuaj yeem rub nws los ntawm hauv qab no)
import gc ua
ntshuam webrepl def do_connect (): ntshuam network sta_if = network. WLAN (network. STA_IF) yog tias tsis sta_if.isconnected (): print ('txuas rau network …') sta_if.active (True) sta_if.ifconfig (('192.168. 0.32 ',' 255.255.255.0 ',' 192.168.0.1 ',' 192.168.0.1 ')) sta_if.connect (' ',' ') thaum tsis sta_if.isconnected (): kis dhau (' network teeb tsa: ', sta_if.ifconfig ()) do_connect () webrepl.start () gc.collect ()
Siv Webrepl tus thov kev pab "Xa Cov Ntaub Ntawv" xa koj daim ntawv boot.py rau koj Wemos. Nias lub pob pib dua kom rov pib dua. Yog tias koj tseem txuas nrog USB siv SCREEN hais kom ua, koj yuav pom:
txuas mus rau network… network teeb tsa: ('192.168.0.32', '255.255.255.0', '192.168.0.1', '192.168.0.1') WebREPL daemon pib ntawm ws: //192.168.4.1: 8266 WebREPL daemon pib ntawm ws: //192.168.0.32: 8266 Pib webrepl hauv qhov ib txwm tsis tuaj yeem qhib cov ntaub ntawv 'main.py' rau nyeem MicroPython v1.8.7-7-gb5a1a20a3 ntawm 2017-01-09; ESP module nrog ESP8266 Hom "pab ()" kom paub ntau ntxiv. >>>>>> Xwb
Qhov no ua pov thawj tias koj Wemos txuas nrog koj lub tsev WIFI siv ipaddress ntawm 192.168.0.32.
Koj tuaj yeem ping tus IP chaw ntawd los ua pov thawj.
$ ping 192.168.0.32
PING 192.168.0.32 (192.168.0.32): 56 cov ntaub ntawv bytes
64 bytes los ntawm 192.168.0.32: icmp_seq = 0 ttl = 255 sij hawm = 9.334 ms 64 bytes los ntawm 192.168.0.32: icmp_seq = 1 ttl = 255 sij hawm = 11.071 ms..
Kauj Ruam 6: Nruab Qhov Kev Pab Cuam
Thaum kawg, koj yuav tsum tau teeb tsa lub program tseem ceeb uas yuav txuas ntxiv ua haujlwm ntawm koj Wemos.
Rov qab mus rau koj lub vev xaib thiab ua haujlwm webrepl tus thov kev pabcuam. Hloov tus IP chaw nyob rau koj li Wemos tus IP chaw nyob. Hauv kuv qhov xwm txheej, tam sim no yog 192.168.0.32. Nkag mus rau koj tus lej Wemos thiab tam sim no koj yuav tsum txuas nrog Wemos.
Cia peb rub qhov txuas txuas txuas nrog main.py. Rub tawm cov ntawv txuas rau koj lub khoos phis tawj. Nyem rau Xaiv Cov Ntaub Ntawv los xaiv qhov rub tawm main.py thiab nyem rau Xa mus rau ntaus ntawv.
Koj yuav tsum tau nias lub pob So kom thauj lub program main.py. Tom qab nias lub pob Pib dua, koj yuav pom:
txuas rau network…
network teeb tsa: ('192.168.0.32', '255.255.255.0', '192.168.0.1', '192.168.0.1')
WebREPL daemon pib ntawm ws: //192.168.4.1: 8266 WebREPL daemon pib ntawm ws: //192.168.0.32: 8266 Pib webrepl hauv hom ib txwm mloog, txuas koj tus browser rau …
Qhov no txhais tau tias koj qhov haujlwm tseem ceeb.py tau qhib thiab sau rau chaw nres nkoj 80.
Txhawm rau sim, qhib koj lub vev xaib thiab nkag mus
Qhov no yuav tsum tso saib lub vijtsam tswj lub tsheb raws li qhia hauv video. Yog tias koj cov xov hlau txuas nrog kom raug, tswj cov nyees khawm yuav xa cov cim kom raug rau koj lub GPIO chaw nres nkoj kom txav lub tsheb.
Kauj Ruam 7: Kev txhim kho yav tom ntej
Cov khoom ua-hauv qab no yog ntawm kuv cov npe v2:
- Siv PWM los tswj lub cev muaj zog ceev
- Txhim kho lub web interface. Tej zaum siv aREST moj khaum. Kuv tsis ntseeg aREST lib muaj nyob ntawm MicroPython tam sim no yog li kuv yuav tsum tau hack nws.
Ua tsaug rau koj nyeem Cov Lus Qhia no. Ua raws kuv hauv Facebook, Youtube, thiab Qhia rau ntau txoj haujlwm yav tom ntej.
Pom zoo:
Huab Cua Raws Li Lub Tshuab Hluav Taws Xob (ESP8266 Raws Li Midi Generator): 4 Cov Kauj Ruam (nrog Duab)
Huab Cua Raws Li Lub Tshuab Hluav Taws Xob (ESP8266 Raws Li Midi Generator): Nyob zoo, hnub no kuv yuav piav qhia yuav ua li cas thiaj ua rau koj tus kheej me ntsis Huab cua raws li lub tshuab hluav taws xob. thiab lub teeb pom kev zoo.Tsis txhob cia siab tias nws yuav ua txhua zaj nkauj lossis chord progr
Pib Nrog Esp 8266 Esp-01 Nrog Arduino IDE - Txhim Kho Esp Boards hauv Arduino Lub Tswv Yim thiab Kev Ua Haujlwm Esp: 4 Cov Kauj Ruam
Pib Nrog Esp 8266 Esp-01 Nrog Arduino IDE | Txhim Kho Esp Boards hauv Arduino Lub Tswv Yim thiab Kev Ua Haujlwm Esp: Hauv cov lus qhia no peb yuav kawm paub yuav teeb tsa esp8266 cov laug cam hauv Arduino IDE li cas thiab yuav ua haujlwm li cas esp-01 thiab tso cov lej rau hauv. qhov no thiab feem ntau ntawm cov neeg ntsib teeb meem
Cov Duab Duab Duab thiab Cov Duab 1: 4 Cov Kauj Ruam (nrog Duab)
Cov Duab Duab Cubes thiab Cov Duab 1: Thaum sim nrog qee cov ntoo ntoo thiab cov duab los qhia, kuv pom ob peb txoj hauv kev los ua cov voos thiab lwm yam duab los ntawm cov khoom siv yooj yim. Los ntawm kev muab cov no los ua Cov Ntawv Qhia, Kuv vam tias yuav txhawb nqa kev ua si thiab kev kawm. Kev hloov pauv ntawm qhov kev qhia no
Cov Duab Duab Duab Duab, WiFi Txuas - Raspberry Pi: 4 Cov Kauj Ruam (nrog Duab)
Cov Duab Duab Duab Duab, WiFi Txuas - Raspberry Pi: Nov yog txoj hauv kev yooj yim heev thiab tus nqi qis mus rau cov duab thav duab digital - nrog qhov zoo ntawm kev ntxiv /tshem cov duab hla WiFi ntawm 'nyem thiab luag' siv (pub dawb) xa cov ntaub ntawv . Nws tuaj yeem siv tau los ntawm qhov me me £ 4.50 Pi Zero. Koj tseem tuaj yeem hloov pauv
DIY Ntse Ua Raws Kuv Drone Nrog Lub Koob Yees Duab (Arduino Raws): 22 Cov Kauj Ruam (nrog Duab)
DIY Ntse Ua Raws Kuv Drone Nrog Lub Koob Yees Duab (Arduino Raws): Drones yog cov khoom ua si nrov heev thiab cov cuab yeej niaj hnub no. Koj tuaj yeem pom cov kws tshaj lij thiab txawm tias pib ua haujlwm drones thiab cov khoom siv ya hauv khw. Kuv muaj plaub lub drones (quadcopters thiab hexcopters), vim tias kuv nyiam txhua yam uas ya, tab sis lub davhlau 200th tsis yog