CloudManager ESP8266闪存映像
cloudmanager-micropython-esp8266的Python项目详细描述
带有CloudManager的micropython ESP8266闪存映像
此软件包提供了一个用于闪存ESP8266板的实用程序,例如nodeMCU或 带有micropython的wemos d1板。它可以选择配置网络和 设置板以在开始时运行cloudmanager或webrepl。
要求
此实用程序需要Python3.6+并使用PythonPIP包管理器安装。
Mac OSX要求
在mac osx上,您可能需要安装usb到串行转换器芯片的设备驱动程序 与董事会接洽。
对于nodemcu板,您需要安装silabs[芯片的串行驱动程序](https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx)([直接链接](https://www.silabs.com/Support%20Documents/Software/Mac_OSX_VCP_Driver.zip))
对于WEMOS D1板,您需要安装[CH340 USB到UART驱动程序](https://www.wemos.cc/downloads)([Direct Link](https://www.wemos.cc/downloads/CH34x_Install_mac.zip))
安装
使用python pip工具安装软件包
$ pip install cloudmanager_micropython_esp8266
闪动电路板
flash_esp_image实用程序将把micropython映像闪存到板上,并可以选择对其进行配置。
如果没有安装其他串行设备,只需将图像闪存到板上
这是最简单的选择,该实用程序将尝试猜测设备所在的串行端口并对其进行闪存。
- 将电路板插入USB端口
- 不带参数运行flash_esp_image实用程序。
$ flash_esp_image esptool.py --port /dev/ttyUSB0 --baud 115200 erase_flash esptool.py v1.2.1 Connecting... Running Cesanta flasher stub... Erasing flash (this may take a while)... Erase took 9.1 seconds esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash --verify --flash_size=32m --flash_mode=qio 0 /tmp/cloudmanager-micropython-esp8266/local/lib/python2.7/site-packages/cloudmanager_micropython_esp8266/firmware/firmware-combined.bin esptool.py v1.2.1 Connecting... Running Cesanta flasher stub... Flash params set to 0x0040 Writing 557056 @ 0x0... 19456 (3 %) 557056 (100 %) Wrote 557056 bytes at 0x0 in 48.3 seconds (92.3 kbit/s)... Leaving... Verifying just-written flash... Verifying 0x8734c (553804) bytes @ 0x00000000 in flash against /tmp/cloudmanager-micropython-esp8266/local/lib/python2.7/site-packages/cloudmanager_micropython_esp8266/firmware/firmware-combined.bin... -- verify OK (digest matched) $
板现在应该用micropython刷新,并且micropython repl提示符将在串行端口上可用。
闪存板并将其配置为作为cloudmanager客户端自动启动
- 将电路板插入USB端口
- 使用参数运行flash_esp_image实用程序来配置network和cloudmanager。
以下示例在默认端口上启动CloudManager服务器,并告诉电路板使用WPA密码“wifiPassword”连接到WiFi网络“myWiFi”,然后在默认端口“18266”上运行的地址为“192.168.1.127”的CloudManager服务器上注册为名为“nodemcu1”的设备
$ mbm server-start $ mbm board-list $ flash_esp_image --wifi_ssid mywifi --wifi_password mywifipassword --cloudmanager_server 192.168.1.127 --cloudmanager_port 18266 --name nodemcu1 esptool.py --port /dev/ttyUSB0 --baud 115200 erase_flash esptool.py v1.2.1 Connecting... Running Cesanta flasher stub... Erasing flash (this may take a while)... Erase took 9.0 seconds esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash --verify --flash_size=32m --flash_mode=qio 0 /tmp/cloudmanager-micropython-esp8266/local/lib/python2.7/site-packages/cloudmanager_micropython_esp8266/firmware/firmware-combined.bin esptool.py v1.2.1 Connecting... Running Cesanta flasher stub... Flash params set to 0x0040 Writing 557056 @ 0x0... 557056 (100 %) Wrote 557056 bytes at 0x0 in 48.3 seconds (92.3 kbit/s)... Leaving... Verifying just-written flash... Verifying 0x8734c (553804) bytes @ 0x00000000 in flash against /tmp/cloudmanager-micropython-esp8266/local/lib/python2.7/site-packages/cloudmanager_micropython_esp8266/firmware/firmware-combined.bin... -- verify OK (digest matched) >>> >>> import os >>> os.mkdir('etc')>>> from bootconfig.config import get, set>>> set('wifi_ssid', 'mywifi')>>> set('wifi_password', 'mywifipassword')>>> set('redis_server', '192.168.1.127')>>> set('redis_port', '18266')>>> set('name', 'nodemcu1')>>> import bootconfig.service >>> bootconfig.service.autostart()>>> import redis_cloudclient.service >>> redis_cloudclient.service.autostart()>>> import machine >>> machine.reset()$ mbm board-list Platform Name State esp8266 nodemcu1 idle $
现在可以使用mbm实用程序在板上上载/运行代码。
连接到串行终端
esp_terminal命令是一个简单的终端程序,它将使用与flash_esp_image实用程序相同的设备和端口通过usb/serial自动连接micropython repl。
$ esp_terminal MicroPython v1.8.5-124-gbc4441a on 2016-11-06; ESP module with ESP8266 Type "help()" for more information. >>>