Micropython 01 start

From artserver wiki

Board: ESP8266

Flash uPython

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())

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"
Code Notes +
Date"Date" is a type and predefined property provided by Semantic MediaWiki to represent date values.
2019 +