Esptool Installation
----------------------------------
Install Pip (or use easy_install). Pip is a packet manager for Python.
sudo pip install --upgrade pip
sudo pip install esptool (pip uninstall esptool)
Alternatively, we can use easy_install. This is a python module bundled with setuptools that lets us automatically download, build, install, and manage Python packages.
sudo easy_install pip
sudo easy_install esptool
Add path (if necessary)
sudo nano /etc/paths
Path to script /usr/local/bin/esptool.py or check via uninstalling command. If you run
pip show -f esptool then it should list all of the files installed by the esptool package.
Esptool Commands:
esptool.py -h to see a summary of all available commands and command-line options.
esptool.py version
MicroPython Firmware Installation
----------------------------------
--> Erase flash ESP8266
esptool.py --port /dev/tty.wchusbserial1420 erase_flash
--> Burn MicroPython on chip
1. Navigate to the folder with firmware
2. Run:
esptool.py --port /dev/tty.wchusbserial1420 --baud 460800 write_flash --flash_size=detect 0 esp8266-20191220-v1.12.bin
Term output:
esptool.py v2.8
Serial port /dev/tty.wchusbserial1420
Connecting........_
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
and etc...
more details
--> Test Connection
Connect the ESP82266 board into usb port and find connected devices
ls /dev/tty.*
ls /dev/cu.*
Term output:
/dev/tty.wchusbserial1420
Access to the REPL (read-eval-print loop) which is always available on the UART0 serial peripheral, which is connected to the pins GPIO1 for TX and GPIO3 for RX.
screen /dev/cu.wchusbserial1420 115200
>>> print("Hi")
Hi
(it is already running on the ESP8266 board)
To exit from 'screen' type 'Ctl-a, k'; and then answer 'y' to exit
Example:
>>> import machine
>>> pin = machine.Pin(2, machine.Pin.OUT)
>>> pin.on()
>>> pin.off()
Uploading *.py files into the ES8266 board
----------------------------------
To upload files, we can use
WebREPL or
ampy tools. To use WebREPL connect your computer to the ESP8266’s access point (MicroPython-xxxxxx) and open client
https://micropython.org/webrepl/.
more details
Enable WebREPL
>>> import webrepl_setup
Ampy is made to talk to a CircuitPython MicroPython board over its serial connection. You will need your board connected and any drivers to access it serial port installed.
more details
Install Ampy
sudo pip3 install ampy or
sudo pip install adafruit-ampy or
pip3 install --upgrade git+https://github.com/adafruit/ampy
or install from sources (Update python version to Python 3.x)
git clone https://github.com/adafruit/ampy.git
sudo python3 setup.py install
--> Upload
ampy --port /dev/tty.wchusbserial1420 --baud 115200 put main.py
For convenience, you can set an AMPY_PORT environment variable which will be used if the port parameter is not specified. For example export on Linux or OSX:
export AMPY_PORT=/dev/tty.wchusbserial1420
ampy ls
and now just it
ampy put main.py
--> Show files (ESP266 flash)
ampy --port /dev/tty.wchusbserial1420 --baud 115200 ls
Ampy Commands
----------------------------------
get retrieve a file from the board.
ls list contents of a directory on the board.
put put a file on the board.
rm remove a file from the board.
run run a script and print its output.
ampy --port /serial/port ls
ampy --port /serial/port put test.py /foo/bar.py
ampy --port /serial/port get boot.py
ampy --port /serial/port mkdir foo
ampy --port /serial/port rm test.py
ampy --port /serial/port rm /foo/bar
---------------
git clone https://github.com/pyserial/pyserial
sudo python setup.py install