Micropython 01 start: Difference between revisions
From artserver wiki
No edit summary |
m (Text replacement - "Code_Notes" to "Code Notes") Tag: Manual revert |
||
(3 intermediate revisions by the same user not shown) | |||
Line 30: | Line 30: | ||
== Load files and run code on a uPython == | == Load files and run code on a uPython == | ||
Tools available: | Tools available: | ||
* Adafruit [https://github.com/pycampers/ampy] python module | * Adafruit [https://github.com/pycampers/ampy ampy] python module | ||
* [https://github.com/dhylands/rshell rshell] remote Shell for MicroPython | * [https://github.com/dhylands/rshell rshell] remote Shell for MicroPython | ||
* [https://github.com/wendlers/mpfshell] remote Shell specially for ESP8266-based boards and the WiPy board | * [https://github.com/wendlers/mpfshell mpfshell] remote Shell specially for ESP8266-based boards and the WiPy board | ||
===Using ampy=== | ===Using ampy=== | ||
Line 56: | Line 56: | ||
Reset: either by pressing the reset button, or disconnecting and connecting to power, '''for the new main.py to be compiled.''' | Reset: either by pressing the reset button, or disconnecting and connecting to power, '''for the new main.py to be compiled.''' | ||
[[Section::Code Notes]] | |||
[[Date::2019]] |
Latest revision as of 13:54, 25 August 2022
Board: ESP8266
- [uPython esp8266/quickref http://docs.micropython.org/en/latest/esp8266/quickref.html]
Flash uPython
- uPython firmware: http://micropython.org/download#esp8266 download latest stable
- install esptool.py to flash the board
pip install esptool
Flash squence:
- connect board to usb
- erase the flash
esptool.py --port /dev/ttyUSB0 erase_flash
- write firmware <code?esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0
REPL over serial port
REPL(Read Evaluate Print Loop) AKA the interactive MicroPython prompt.
stty < /dev/ttyUSB0
speed 115200 baud; line = 0; min = 100; time = 2; -icrnl -imaxbel -opost -onlcr -isig -icanon -echo
- connect to REPL
screen /dev/ttyUSB0 115200
- Ctl-A will exit screen
Load files and run code on a uPython
Tools available:
- Adafruit ampy python module
- rshell remote Shell for MicroPython
- mpfshell remote Shell specially for ESP8266-based boards and the WiPy board
Using ampy
In the ESP8266 file system there are the files:
boot.py
is executed first (if it exists)main.py
is executed once boot.py is finished executing
So What will do is save the following script as <codeblink_led.py
from time import sleep
from machine import Pin
p2 = Pin(2, Pin.OUT)
while True:
p2.value(not p2.value())
sleep(0.5)
create a syslink between blink_led.py and main.py ln blink_led.py main.py
Use ampy to put the script (main.py) on the board
ampy --port /dev/ttyUSB0 put main.py
Reset: either by pressing the reset button, or disconnecting and connecting to power, for the new main.py to be compiled.
Code Notes
2019
... more about "Micropython 01 start"