Chen Tuo 2022/06/10-2022/06/11
use micropython Conduct ESP32 Development .
Conduct ESP32 Development , The official standard development environment is ESP-IDF, Development language use C Language . But no matter ESP-IDF still C Language is too difficult for beginners .micropython The emergence of enables us to use Python Language operation ESP32, So those unprofessional EP32 Fans and even children can pass micropython To experience ESP32 Development of , And find fun in it .
MicroPython yes Python 3 A compact and efficient implementation of programming languages , It includes Python A small part of the standard library , And optimized , It can run in microcontrollers and restricted environments .
MicroPython The goal is to be as common as possible Python compatible , To allow you to easily transfer code from the desktop to ESP32 Such a microcontroller or embedded system .
Want to be in ESP32 Up operation micropython It's very simple , Just follow us , The following operations are in Win10 Proceed under .
https://micropython.org/
We can see micropython It can be used for many kinds of hardware devices , We choose ESP32.
Such development boards are easy to buy on the Internet , Search for esp32 The development board can find many , The price only needs 10 multivariate .
Choose the latest stable version to download :
esp32-20220117-v1.18.bin
stay ESP32 Install on run micropython Software tools are needed , There are many tools available , We use flash_download_tool.
Download it from the official website :
https://www.espressif.com/zh-hans/support/download/other-tools?keys=&field_type_tid%5B%5D=14
Click to download :
flash_download_tool_3.9.2_0.zip
Or download from Baidu online disk :
link :https://pan.baidu.com/s/1QXssXcSlOf8wXI69NOeTRQ?pwd=k2ky
Extraction code :k2ky
choice ESP32 Of develop Developer model ,OK
View... From device manager USB-SERIAL Serial port number , I am here COM3.
Remember serial port number .
Click on STOP, Click again START:
Wait for download to complete …
Use serial port debugging assistant and ESP32 Interaction , And check the program running results .
Please see the installation and use of Microsoft serial port debugging assistant 《Win10 Use CH340 USB-SERIAL A serial port 》
https://zhuanlan.zhihu.com/p/343013801
https://blog.csdn.net/chentuo2000/article/details/112323488
Serial port display :
Now you can use python Operating the hardware .
Follow the prompts to enter :
Be careful ,help() There must be a carriage return in the back .
Click Send button :
The serial port terminal will display some instructions .
And basic Wifi To configure
Input :
print ('hello world')
send out , Serial port response :
There is a blue one on the development board LED The lamp is connected to the pin 2 On .
according to help() Prompt for a command :
import machine
pin2 = machine.Pin(2, machine.Pin.OUT)
pin2.value(1)
send out , You can see the blue LED The light is on :
Enter the command pin2.value(0) You can turn off the blue LED The lamp .
micropython control ESP32 The hardware needs the support of the driver module . In the above order machine yes micropython External device driver module , Include pin,i2c,spi,uart,adc,dac,pwm etc. . except machine Module and network module network, as well as esp32 And so on, other modules . You can use the command help ('modules') Check out the list of modules :
To view the functions of a module, you can also use help command , For example, look at the modules we used earlier machine You can use the command help(‘machine’)
For more functions, please refer to micropython Official documents of .
https://docs.micropython.org/en/latest/esp32/quickref.html