Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
dev:esp:esp32:micropython [2020/08/11 20:51] – yoann | dev:esp:esp32:micropython [2021/04/04 08:53] (Version actuelle) – Modification commande flash ESP32 77.192.232.26 | ||
---|---|---|---|
Ligne 30: | Ligne 30: | ||
création d'un environnement virtuel Python | création d'un environnement virtuel Python | ||
+ | <code bash> | ||
+ | python3 -m venv esptool | ||
+ | source esptool/ | ||
+ | |||
+ | pip3 install esptool | ||
+ | </ | ||
===== Premiere installation ==== | ===== Premiere installation ==== | ||
+ | |||
+ | Brancher la carte | ||
+ | |||
+ | afficher les messages système: | ||
+ | <code bash> | ||
+ | dmesg | tail | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [19606.286934] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 | ||
+ | [19606.286938] usb 1-4: Product: CP2102 USB to UART Bridge Controller | ||
+ | [19606.286941] usb 1-4: Manufacturer: | ||
+ | [19606.286944] usb 1-4: SerialNumber: | ||
+ | [19606.338930] usbcore: registered new interface driver usbserial_generic | ||
+ | [19606.339009] usbserial: USB Serial support registered for generic | ||
+ | [19606.344277] usbcore: registered new interface driver cp210x | ||
+ | [19606.344917] usbserial: USB Serial support registered for cp210x | ||
+ | [19606.345122] cp210x 1-4:1.0: cp210x converter detected | ||
+ | [19606.347886] usb 1-4: cp210x converter now attached to ttyUSB0 | ||
+ | </ | ||
+ | |||
+ | Ici la carte est attachée par le système sur le port ttyUSB0. | ||
+ | |||
+ | Tester la connexion | ||
+ | <code bash> | ||
+ | esptool.py --port / | ||
+ | </ | ||
+ | |||
+ | Si tout se passe correctement on obtient un résultat du type: | ||
+ | < | ||
+ | esptool.py v2.8 | ||
+ | Serial port / | ||
+ | Connecting........__ | ||
+ | Detecting chip type... ESP32 | ||
+ | Chip is ESP32D0WDQ6 (revision 1) | ||
+ | Features: WiFi, BT, Dual Core, Coding Scheme None | ||
+ | Crystal is 40MHz | ||
+ | MAC: 30: | ||
+ | Uploading stub... | ||
+ | Running stub... | ||
+ | Stub running... | ||
+ | Manufacturer: | ||
+ | Device: 4016 | ||
+ | Detected flash size: 4MB | ||
+ | Hard resetting via RTS pin... | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Pour pouvoir utiliser le port série, l' | ||
+ | <code bash> | ||
+ | sudo adduser my_user dialout | ||
+ | newgrp dialout | ||
+ | </ | ||
+ | </ | ||
Si Micropython est installé pour la première fois, il faut effacer entièrement la mémoire flash | Si Micropython est installé pour la première fois, il faut effacer entièrement la mémoire flash | ||
Ligne 41: | Ligne 101: | ||
Le firmware peut alors être installé: | Le firmware peut alors être installé: | ||
<code bash> | <code bash> | ||
- | esptool.py --chip esp32 --port / | + | esptool.py --chip esp32 --port / |
</ | </ | ||
+ | |||
+ | < | ||
+ | Il est possible de réduire le débit en ajoutant l' | ||
+ | </ | ||
Ligne 54: | Ligne 118: | ||
Il faut maintenant interagir avec Micropython s’exécutant sur le microcontrôleur ESP32. Le REPL Micropython est disponible via le port série: il faut donc un programme capable de lire/ | Il faut maintenant interagir avec Micropython s’exécutant sur le microcontrôleur ESP32. Le REPL Micropython est disponible via le port série: il faut donc un programme capable de lire/ | ||
- | * pycom | + | * picocom -b 115200 / |
- | * minicom | + | * screen / |
- | * screen | + | * minicom -D / |
+ | Presser < | ||
+ | < | ||
+ | PY: soft reboot | ||
+ | MicroPython v1.12-663-g9883d8e81 on 2020-08-11; ESP32 module with ESP32 | ||
+ | Type " | ||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | from machine import Pin | ||
+ | |||
+ | led = Pin(2, Pin.OUT) | ||
+ | |||
+ | led.on() | ||
+ | led.off() | ||
+ | </ | ||
===== Références ===== | ===== Références ===== |