MicroPython with ESP-WROOM-02 installed micropython on ESP-WROOM-02, but it is interactive with REPL as it is. There is no choice but to use it for. You can use the file system if you have 1M or more of memory, but copying files to the file system is also troublesome. So, I introduced a simple shell called mpfshell. mpfshell mpfshell is a tool that allows you to put, get and easily access files from your local Mac like ftp.
Download mpfshell from https://github.com/wendlers/mpfshell.
The mpfshell documentation has
python
$ sudo pip install pyserial
$ sudo pip install colorama
$ sudo pip install websocket_client
It says to install the above three, but I omitted it because pyserial was installed on my mac. You can check the installed packages below.
python
$ sudo pip list
Execute setup.py in the downloaded mpfshell to install mpfshell.
python
$ sudo python setup.py install
Start mpfshell and try to access the board. The xxxx in'open tty.usbserial-xxxx'is the actual USB serial device name. After opening it, ls to see a list of board filesystems. By default boot.py is installed.
python
$ mpfshell
** Micropython File Shell v0.7.6, [email protected] **
-- Running on Python 2.7 using PySerial 3.1.1 --
mpfs [/]> open tty.usbserial-xxxx
Connected to esp8266
mpfs [/]> ls
Remote files in '/':
boot.py
This completes the installation and testing.
Usage is similar to ftp.
python
mpfs [/]> get boot.py
Copy the boot.py file to your Mac's current directory.
python
mpfs [/]> put main.py
Copy main.py from your Mac's current directory. By the way, if there is a file called main.py, it will be automatically executed after startup.
python
mpfs [/]> cat boot.py
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import gc
import webrepl
webrepl.start()
gc.collect()
Write the script of the previous L Chika in main.py and turn on the LED. Create the following files on your Mac.
python
$ cat main.py
import machine
import time
pin = machine.Pin(4, machine.Pin.OUT)
pin.high()
time.sleep(3)
pin.low()
Send the file with mpfshell and start repl from mpfshell.
python
mpfs [/]> put main.py
mpfs [/]> cat main.py
import machine
import time
pin = machine.Pin(4, machine.Pin.OUT)
pin.high()
time.sleep(3)
pin.low()
mpfs [/]> repl
*** Exit REPL with Ctrl+] ***
>
MicroPython v1.8.4-10-gbc28ac8 on 2016-09-09; ESP module with ESP8266
Type "help()" for more information.
>>>
If you enter Ctrl-d here, it will soft reboot and main.py will be executed. Hopefully the LED should stay on for 3 seconds. To return from the repl to the mpfshell, type Ctrl +]. When you reset the board, the LED will light up for 3 seconds as well.
Recommended Posts