Micropython OSX

https://www.python.org/
回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Micropython OSX

文章 yehlu »

https://www.jianshu.com/p/acecc6d494ad

install esptool

代碼: 選擇全部

pip3 install esptool
erase flash

代碼: 選擇全部

esptool.py --port /dev/tty.wchusbserialfa130  erase_flash
flash new

代碼: 選擇全部

esptool.py --port /dev/tty.wchusbserialfa130 --baud 460800 write_flash --flash_size=detect -fm dio 0 esp8266-20180511-v1.9.4.bin
connect

代碼: 選擇全部

screen /dev/tty.wchusbserialfa130 115200
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

OSError: [Errno 2] ENOENT: main.py

文章 yehlu »

https://github.com/micropython/micropyt ... /issues/90

代碼: 選擇全部

>>> import os
>>> os.listdir()
['boot.py']
>>> f = open("main.py", "w")
>>> f.write("print(\"main.py: Hello\")\n")
24
>>> f.close()
>>> os.listdir()
['boot.py', 'main.py']
CTRL-D -- on a blank line, do a soft reset of the board
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Basic WiFi configuration

文章 yehlu »

代碼: 選擇全部

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
sta_if.ifconfig() 
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

NTP 設定日期

文章 yehlu »

http://yhhuang1966.blogspot.com/2017/05 ... 66_20.html

代碼: 選擇全部

import time
time.time()     #傳回開機後秒數
from ntptime import settime         #從 ntptime 模組匯入 settime()
settime()        #以自 NTP 伺服器取得之 UTC 時間設定 RTC
time.localtime()                                #顯示目前之 UTC 時間
time.localtime(time.mktime(time.localtime())+28800)    #UTC 加 8 小時                
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

ampy

文章 yehlu »

https://learn.adafruit.com/micropython- ... stall-ampy

install

代碼: 選擇全部

sudo pip3 install adafruit-ampy
get file

代碼: 選擇全部

ampy --port /dev/tty.wchusbserialfa130 --baud 115200 get boot.py
put file

代碼: 選擇全部

ampy --port /dev/tty.wchusbserialfa130 --baud 115200 put boot.py
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

webrepl

文章 yehlu »

代碼: 選擇全部

>>> import webrepl_setup
WebREPL daemon auto-start status: disabled

Would you like to (E)nable or (D)isable it running on boot?
(Empty line to quit)
> E
To enable WebREPL, you must set password for it
New password (4-9 chars): password
Confirm password: password
Changes will be activated after reboot
Would you like to reboot now? (y/n) y
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

LED ON OFF

文章 yehlu »

https://docs.micropython.org/en/latest/ ... /repl.html

代碼: 選擇全部

>>> import machine
>>> pin = machine.Pin(2, machine.Pin.OUT)
>>> pin.on()
>>> pin.off()
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

webrepl

文章 yehlu »

http://yhhuang1966.blogspot.com/2017/05 ... fi_16.html

client
https://github.com/micropython/webrepl

AP password

代碼: 選擇全部

micropythoN

代碼: 選擇全部

import webrepl_setup
import webrepl
webrepl.start(password="123456789")    #密碼太長 (最長 9 碼)
回覆文章

回到「python」