Micropython Sur NodeMCU

Nous allons voir ici comment flasher un nodeMCU avec le firmware MicroPython.

nodeMCU

C’est un plaquette ou tout est embarqué à la façon d’un arduino mais avec en prime une puce wifi, l'esp8266.

La carte dispose de nombreux port.

NodeMCU V1

NodeMCU V1 Pin Map

  • Un connecteur usb/ttl intégré.
  • Les pin D0-10 peuvent être : PWM, I2C, 1-wire.

MicroPython

Une version réduite du python tournant sur un ESP8266.

Le firmware émule un système de fichier dans lequel on va pouvoir copier des fichiers python contenant du code ;) et les exécuter.

Outillage

ESPTOOL

ESPTOOL : Installation

Le logitiel esptool est dévelloppé en python, disponible sur pypi.

sudo pip install esptools

ESPTOOL : Utilisation

Effacement de la flash.

esptool.py --port /dev/ttyUSB0 --baud 460800 erase_flash

Flashage de la mémoire avec le nouveau firmware.

esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=8m 0 esp8266-20161017-v1.8.5.bin

AMPY

Toujours écris en python, cette outils permet de manipuler des fichiers sur l’ESP8266 avec un firmware mircopython.

AMPY : Installation

sudo pip3 install adafruit-ampy

AMPY : Utilisation

nithir@ocelot:~/bas/esp8266$ ampy --help
Usage: ampy [OPTIONS] COMMAND [ARGS]...
ampy - Adafruit MicroPython Tool
Ampy is a tool to control MicroPython boards over a serial connection.
Using ampy you can manipulate files on the board's internal filesystem and
even run scripts.  Options:
-p, --port PORT Name of serial port for connected board.  Can optionally
           specify with AMPY_PORT environemnt variable.  [required]
-b, --baud BAUD  Baud rate for the serial connection (default 115200).  Can
           optionally specify with AMPY_BAUD environment variable.
--version        Show the version and exit.
--help           Show this message and exit.
Commands:
get    Retrieve a file from the board.
ls     List contents of a directory on the board.
mkdir  Create a directory on the board.
put    Put a file on the board.
reset  Perform soft reset/reboot of the board.
rm     Remove a file from the board.
run    Run a script and print its output

PICOCOM

Picocom est un outils en ligne de commande qui permet de se connecter sur un port serie.

installation

sudo apt install picocom

utilisation

cf. man page