7 Feb 2020

MicroPython on the ESP8266 (macOS) Part 2


Rshell (Alternative to Ampy)

----------------------------------

Remote MicroPython shell. This is a simple shell which runs on the host and uses MicroPython's raw-REPL to send python snippets to the pyboard in order to get filesystem information, and to copy files to and from MicroPython's filesystem.

Install
sudo pip3 install rshell

Enter:
rshell

Term output:
Welcome to rshell. Use Control-D (or the exit command) to exit rshell.
No MicroPython boards connected - use the connect command to add one

connect serial /dev/tty.wchusbserial1420 115200
(connect serial [port] [baud])

Term output:
Connecting to /dev/tty.wchusbserial1420 (buffer-size 512)...
Trying to connect to REPL connected

etc...

Use Rshell:

----------------------------------

List files on the board
ls /pyboard/

Entering REPL
repl (Use Control-X to exit.)

Get help 
help()

https://github.com/dhylands/rshell
https://github.com/wendlers/mpfshell

Upload *.py files

----------------------------------

Copy a file from local directory to esp8266 board
cp main.py /pyboard/

Copy a file from the board to desktop
cp /pyboard/main.py desktop

Run in the REPL
import main

Reset

----------------------------------

There are soft resets and hard resets. A soft reset simply clears the state of the MicroPython virtual machine but leaves hardware peripherals unaffected. To do a soft reset, simply press Ctrl + D on the REPL, or within a script do:

import sys 
sys.exit()

A hard reset is the same as performing a power cycle to the board. In order to hard reset the WiPy, press the switch on the board or:

import machine 
machine.reset()

No comments:

Post a Comment

Popular Posts