Cov txheej txheem:

Txoj Haujlwm ESP8266 - MicroPython: 4 Cov Kauj Ruam
Txoj Haujlwm ESP8266 - MicroPython: 4 Cov Kauj Ruam

Video: Txoj Haujlwm ESP8266 - MicroPython: 4 Cov Kauj Ruam

Video: Txoj Haujlwm ESP8266 - MicroPython: 4 Cov Kauj Ruam
Video: ការដំឡើងកម្មវិធី Arduino IDE និង ការប្រើប្រាស់កូដដំបូង 2024, Kaum ib hlis
Anonim
Program ESP8266 - MicroPython
Program ESP8266 - MicroPython
Program ESP8266 - MicroPython
Program ESP8266 - MicroPython
Program ESP8266 - MicroPython
Program ESP8266 - MicroPython

MicroPython yog txoj haujlwm uas tso cai rau koj los ua haujlwm me me ntawm nab hab sej 3 ntawm microcontrollers thiab cov laug cam. Nws tau nce kev txhawb nqa ntawm microcontroller cov laug cam thiab ntau dua li txhim kho Linux tag nrho cuam tshuam rau hauv lub rooj tsavxwm nws tsuas yog muab qhov tsawg ntawm cov nab hab sej nrog kev hwm rau pawg thawj coj, nrog lub plhaub nab nab thiab koj tuaj yeem xa cov ntaub ntawv nab nab me rau ntawm pawg thawj coj saib thiab khiav nws..

Hauv cov lus qhia no kuv yuav qhia koj yuav siv MicroPython ntawm NodeMCU li cas, NodeMCU yog pawg thawj coj txhim kho raws li esp8266-12.

Kauj Ruam 1: Nqi Khoom

Nqi Khoom
Nqi Khoom
Nqi Khoom
Nqi Khoom

Rau qhov haujlwm no, koj yuav xav tau,

  • NodeMCU
  • LED
  • Cov qhob cij
  • Micro USB kab

Kauj Ruam 2: Txhim Kho MicroPython

Txhim kho MicroPython
Txhim kho MicroPython

Txhawm rau nruab micropython ntawm esp8266, Kuv tab tom siv pawg esp8266-12 version. Txhawm rau nruab micropython koj yuav xav tau esptool koj yuav tsum rub tawm thiab teeb tsa sej thiab pip, txhawm rau nruab esptool.

Khiav cov lus txib hauv qab no ntawm lub davhlau ya nyob twg lossis cmd txhawm rau nruab esptool.

pip nruab esptool

Tom ntej no, koj tuaj yeem mus ntsib micropython lub vev xaib thiab rub tawm qhov tseeb firmware rau esp8266, tom qab rub tawm nws qhib lub davhlau ya nyob twg hauv tib cov npe raws li cov ntaub ntawv firmware thiab tom qab ntawd ua raws cov lus txib hauv qab no.

esptool.py --port /dev /ttyUSB0 lwv_flash

esptool.py --port /dev /ttyUSB0 --baud 460800 write_flash --flash_size = ntes 0 esp8266-xxxxx-vxxxx.bin

Koj yuav tsum tau hloov chaw nres nkoj raws koj lub PC. Tom qab qhov no, koj yuav tsum tau ua tiav kev teeb tsa micropython.

Kauj Ruam 3: Kuaj Qhov Kev Pab Blink

Kev Xeem Blink Program
Kev Xeem Blink Program
Kev Xeem Blink Program
Kev Xeem Blink Program

Tam sim no koj tau ua tiav kev teeb tsa micropython nws yog lub sijhawm sim ob peb qhov kev xeem los ua qhov no peb yuav tsum qhib lub pob nab nab siv lub ntsuas saib, Kuv siv putty ntawm lub tshuab qhov rais kom qhib qhov saib xyuas ntawm lub chaw nres nkoj com esp8266 tau muab rau.

Lub plhaub nab nab no zoo ib yam li nab nab 3 lub plhaub, khiav cov ntawv hauv qab no kom ntsais ib qho txuas nrog rau esp8266.

ntshuam esppin = tshuab. Pin (0) tus pin = tshuab. Pin (0, tshuab. Pin. OUT)

Tom qab ntawv khiav kab hauv qab ntawm kab ntawv nab hab sej yuav qhib rau coj thiab kab thib ob yuav tua nws.

pin.value (1) pin.value (0)

Hloov pauv, koj kuj tseem tuaj yeem ua cov kab no los ua tib yam.

pin.off () pin.on ()

Kauj Ruam 4: Siv WebREPL

Siv WebREPL
Siv WebREPL

Tam sim no cia peb qhib micropython WebREPL uas tso cai rau peb rub cov ntawv sau mus rau esp8266 hla WiFi li tshem tawm qhov xav tau ntawm cov xov hlau.

Ua ntej, peb yuav tsum pab kom WebREPL, qhib lub davhlau ya nyob twg thiab ua raws cov kab hauv qab no, qhov teeb tsa no yog lub webrepl thiab nug koj kom teeb tus password kom txhim kho kev nyab xeeb.

ntshuam webrepl_setup

Tom ntej no, koj yuav tsum pom WiFi nkag mus rau npe hu ua MicroPython-xxxxxx, txuas rau nws thiab qhib lub vev xaib internet thiab mus ntsib webREPL lub vev xaib. Tam sim no koj yuav tsum tau txais lub vev xaib, ntaus txuas thiab sau tus password uas koj tsim. Tam sim no koj tuaj yeem ua cov ntawv sau ntawm esp8266 wireless.

Tam sim no koj tau txais micropython thiab khiav koj tuaj yeem ua cov ntawv sau ntawm nws, zoo ib yam li koj ua raspberry pi. Muaj ntau ntau cov qauv muaj rau micropython los ua haujlwm nrog thiab koj tuaj yeem tau txais cov ntaub ntawv zoo ntawm nws hauv micro python official lub vev xaib hauv qab esp8266 qeb.

Pom zoo: