Afficher la pageAnciennes révisionsLiens de retourHaut de page Cette page est en lecture seule. Vous pouvez afficher le texte source, mais ne pourrez pas le modifier. Contactez votre administrateur si vous pensez qu'il s'agit d'une erreur. [[microc:accueilmc|{{ :iconemaison.jpg?nolink&30|Sommaire Microcontrôleur}}]] ===== Installation de MicroPython sur les modules Espressif ESP32 et ESP8266 ===== {{ :python:micropython:materiel:espmicrop.jpg?nolink|}} [Mise à jour le : 19/8/2023] * **Ressources** * <html><a href="https://randomnerdtutorials.com/flashing-micropython-firmware-esptool-py-esp32-esp8266/" target="_blank">Flashing MicroPython Firmware with esptool.py on ESP32 and ESP8266</a></html> * **Bibliographie** * **Programmez** ! Juillet/Août 2019 * **Elektor 489** Mai/Jui 2021 ---- ==== 1. Description des cartes ESPRESSIF ==== * Voir les Wikis * [[microc:uc:esp01|Les cartes ESP01(S)]] * [[microc:uc:esp8266|La carte ESP8266 Feather Huzzah]] * [[microc:uc:esp32|La carte ESP32 Feather Huzzah]] ==== 2. Installer MicroPython ==== === 2.1 En ligne de commande (sous Windows)=== * **Ressources** * <html><a href="https://randomnerdtutorials.com/flashing-micropython-firmware-esptool-py-esp32-esp8266/" target="_blank">Flashing MicroPython Firmware with esptool.py on ESP32 and ESP8266</a></html> * **Installer esptool** <callout type="info" icon="true"><html><a href="https://github.com/espressif/esptool" target="_blank">esptool</a></html> est un utilitaire basé sur Python, open source et indépendant de la plate-forme, permettant de communiquer avec le chargeur de démarrage ROM dans les puces Espressif ESP8266 et ESP32.</callout> Ouvrir une console et entrer la commande suivante : <code bash *.bash> pip install esptool </code> //Exemple// {{ :python:micropython:materiel:installesptool.png?nolink |}} * **Effacer la mémoire flash** <code bash *.bash> esptool --port <portcom> erase_flash </code> //Exemple// {{ :python:micropython:materiel:micropyesp32erase.png?nolink |}} * **Installer MicroPython** <callout type="warning" icon="true">Télécharger la dernière **version stable** de MicroPython pour la carte ciblée <html><a href="https://micropython.org/download#esp8266" target="_blank"><b>ici</b></a></html>.</callout> // Exemple // {{ :python:micropython:materiel:micropystable.png?nolink |}} <code bash *.bash> esptool --port <portcom> --baud <baudrate> write_flash --flash_size=detect 0 <path><firmware_name>.bin </code> // Exemple // {{ :python:micropython:materiel:micropyinstal.png?nolink |}} {{ :python:micropython:materiel:thonny.png?nolink&100|}} === 2.2 Avec l'IDE Thonny === * <html><a href="https://thonny.org/" target="_blank">Thonny</a></html> est un environnement de développement intégré pour Python conçu pour les débutants. Il prend en charge différentes façons de parcourir le code, l'évaluation d'expression étape par étape, la visualisation détaillée de la pile d'appels et un mode pour expliquer les concepts de références et de tas. <callout type="warning" icon="true">Télécharger la dernière **version stable** de MicroPython pour la carte ciblée <html><a href="https://micropython.org/download#esp8266" target="_blank"><b>ici</b></a></html>.</callout> * **Connecter** le module au port USB du PC * Ouvrir les options de Thonny (outils -> options) et sélectionner la carte en dépliant "**Port ou WebREPL**" {{ :python:micropython:materiel:thonny1.png?nolink |}} * Cliquer sur "**Installer ou mettre à jour le firmware**". Sélectionner le port et l'image préalablement chargée {{ :python:micropython:materiel:thonny2.png?nolink |}} ====3. Se connecter à la console REPL ==== * **Source** : <html><a href="https://docs.micropython.org/en/latest/esp32/tutorial/intro.html" target="_blank">Getting started with MicroPython on the ESP32</a></html> <callout type="info" icon="true">**REPL** pour **R**ead **E**val **P**rint **L**oop est un environnement de programmation informatique interactif simple qui prend les entrées d'un seul utilisateur, les exécute et renvoie le résultat; un programme écrit dans un environnement REPL est exécuté par morceaux.</callout> === 3.1 Connexion avec la ligne de commande (sous Windows)=== * Utiliser l'utilitaire **Putty** //Exemple// {{ :python:micropython:materiel:putty.png?nolink |}} //Test// {{ :python:micropython:materiel:puttycom11.png?nolink |}} === 3.2 Connexion avec l'IDE Thonny === {{ :python:micropython:materiel:thonn3.png?nolink |}} ====4. Configurer le Wifi ==== * **Source et plus loin...** : <html><a href="https://docs.micropython.org/en/latest/esp32/tutorial/intro.html" target="_blank">Getting started with MicroPython on the ESP32</a></html> * **Test avec REPL** <code python *.py> import network wlan = network.WLAN(network.STA_IF) wlan.active(True) wlan.connect('MON_SSID', 'MON_PASSWD') print('network config:', wlan.ifconfig()) </code> microc/uc/espressif.txt Dernière modification : 2023/08/19 11:40de phil