NodeMCU-32S MicroPython固件的使用

ESP32开发板 NodeMCU-32S MicroPython固件的使用。

第一步 下载固件

第二步 安装Python环境

  • 再Python官网下载Python安装包,安装即可.

第三步 烧录固件

  • 插上开发板后查看,在设备管理器中查看端口(Windows+R 输入devmgmt.msc),如果未识别需要下载安装驱动,记住这里的端口号(如:COM3).

  • 打开命令行依次执行

  • (1) 安装esptool 输入:

pip install esptool

  • (2)擦除FLASH,把原来芯片程序擦除
    ( COM3 替换为自己的端口)

esptool.py --port COM3 erase_flash

  • (2)写入固件
    (COM3 替换为自己的端口,C:\esp32-20171102-v1.9.2-443-g236297f4.bin替换为自己的固件路径)

esptool.py --port COM3 --baud 115200 write_flash -z 0x1000 C:\esp32-20171102-v1.9.2-443-g236297f4.bin --verify

第四步 使用串口工具调试

  • 连接串口工具输入help(),输出以下内容说明固件已经烧录成功了

Welcome to MicroPython on the ESP32!
For generic online docs please visit http://docs.micropython.org/
For access to the hardware use the 'machine' module:
import machine
pin12 = machine.Pin(12, machine.Pin.OUT)
pin12.value(1)
pin13 = machine.Pin(13, machine.Pin.IN, machine.Pin.PULL_UP)
print(pin13.value())
i2c = machine.I2C(scl=machine.Pin(21), sda=machine.Pin(22))
i2c.scan()
i2c.writeto(addr, b'1234')
i2c.readfrom(addr, 4)
Basic WiFi configuration:
import network
sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
sta_if.scan() # Scan for available access points
sta_if.connect("<AP_name>", "<password>") # Connect to an AP
sta_if.isconnected() # Check for successful connection
Control commands:
CTRL-A -- on a blank line, enter raw REPL mode
CTRL-B -- on a blank line, enter normal REPL mode
CTRL-C -- interrupt a running program
CTRL-D -- on a blank line, do a soft reset of the board
CTRL-E -- on a blank line, enter paste mode
For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')

  • 上面micropython输出的欢迎界面内容仔细看下会发先,不仅列出了文档地址,还提供了几个示例代码,注意在最后两行的帮助命令

For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')

  • help('modules') #会列出所有的模块

help('modules')
main framebuf re upip
_boot gc select upip_utarfile
_onewire hashlib socket upysh
_thread heapq ssl urandom
apa106 inisetup struct ure
array io sys urequests
binascii json time uselect
btree machine ubinascii usocket
builtins math ucollections ussl
cmath micropython uctypes ustruct
collections neopixel uerrno utime
dht network uhashlib utimeq
ds18x20 ntptime uheapq uzlib
errno onewire uio zlib
esp os ujson
flashbdev random uos

Plus any modules on the filesystem

  • help(obj) #会列出这个对象的提供方(help(obj)前需要先import obj 这个模块).

help(network)
object <module 'network'> is of type module
name -- network
init -- <function>
WLAN -- <function>
LAN -- <function>
phy_mode -- <function>
STA_IF -- 0
AP_IF -- 1
MODE_11B -- 1
MODE_11G -- 2
MODE_11N -- 4
AUTH_OPEN -- 0
AUTH_WEP -- 1
AUTH_WPA_PSK -- 2
AUTH_WPA2_PSK -- 3
AUTH_WPA_WPA2_PSK -- 4
AUTH_MAX -- 6
PHY_LAN8720 -- 0
PHY_TLK110 -- 1

  • 具体模块请参考源码 GitHub
  • 最后我们需要熟悉python语法结合help()给我们的提示,就可以简单的使用MicroPython来操作NodeMCU-32S了

- 本文内容来自网络,如有侵权,请联系本站处理。

2022-08   阅读(162)   评论(0)
 标签: 创客 ESP32 MicroPython

涨知识
步进电机

步进电机是将电脉冲信号,转变为角位移或线位移的开环控制电机,又称为脉冲电机。

评论:
相关文章
【ESP32 C++教程】Unit5-2 执行器件之舵机

本节主要讲解舵机驱动类和用按键控制舵机。


【ESP32 C++教程】Unit5-1 执行器件之继电器

本节主要讲解执行器件类型和用按键控制继电器。


【ESP32 C++教程】Unit4-3 红外接收和遥控

本小节主要讲解红外接收和遥控器件,以及遥控操作LED。


【ESP32 C++教程】Unit4-2 模拟量传感器

本小节讲解模拟量传感器使用,旋转电位器,DHT11温湿度传感器和实现自定义传感器类。


【ESP32 C++教程】Unit4-1 数字量传感器

本小节讲解Sensor类及派生类、数字量传感器使用和传感器的推荐交互流程。


【ESP32 C++教程】Unit3-2 触摸输入

本小节讲解ESP32内置触摸引脚的用法,


【ESP32 C++教程】Unit3-1 按键输入

本小节主要介绍按键信号转换、Button类及派生类、和Button交互推荐流程。


【ESP32 C++教程】Unit2-2 Ws2812灯珠

本小节主要介绍Ws2812灯珠的使用、对父类进行扩展实现自定义功能,和指针向下强制转换的使用。


【ESP32 C++教程】Unit2-1 RGB三色LED

本小节主要介绍RGB三色LED的使用,以及多态的具体实现。


【ESP32 C++教程】Unit1-3 ESP32 Arduino 开发框架

ESP32 Arduino Framework是专门针对ESP32开发板的Arduino应用开发框架,为用户开发IOT应用、HMI应用提供一致的开发体验。