程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Developing esp32 firmware burning and testing with micropython

編輯:Python

Chen Tuo 2022/06/10-2022/06/11

1. brief introduction

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 .

2. Download for ESP32 Of micropython Binary system file

  • micropython Official website

https://micropython.org/

 

  • DOWNLOAD

 

We can see micropython It can be used for many kinds of hardware devices , We choose ESP32.

  • choice 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 .

  • Download for ESP32 Binary system bin file

 

Choose the latest stable version to download :

esp32-20220117-v1.18.bin

  • Installation and operation micropython

stay ESP32 Install on run micropython Software tools are needed , There are many tools available , We use flash_download_tool.

  • download Windows Of Flash Burning tools

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

  • decompression

 

  • double-click flash_download_tool_3.9.2.exe function

 

choice ESP32 Of develop Developer model ,OK

  • use USB Switch to serial connection PC and ESP32 Development board

View... From device manager USB-SERIAL Serial port number , I am here COM3.

 

Remember serial port number .

  • Set... As shown below

 

  • Burning the firmware

Click on STOP, Click again START:

 

Wait for download to complete …

  • Download complete

 

4. Program run test

Use serial port debugging assistant and ESP32 Interaction , And check the program running results .

  • Install the serial port debugging assistant

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

  • According to the development board RST key .

Serial port display :

 

Now you can use python Operating the hardware .

5. interactions

  • Ask for help

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

 

  • Interactive commands hello world

Input :

print ('hello world')

send out , Serial port response :

 

  • Light a lamp

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 modular

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 .

  • Official documents

https://docs.micropython.org/en/latest/esp32/quickref.html

Reference documents

  1. stay ESP32 Up operation micropython
    https://zhuanlan.zhihu.com/p/124059889
  2. ESP32 MicroPython Development tour The basic chapter ① —— Set up the environment , function Helloworld
    https://blog.csdn.net/weixin_44614230/article/details/121641451?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7EPayColumn-1-121641451-blog-105306366.pc_relevant_blogantidownloadv1&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7EPayColumn-1-121641451-blog-105306366.pc_relevant_blogantidownloadv1&utm_relevant_index=1


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved