| |
| python:micropython:generalites [2023/06/03 11:25] – [Tableau] phil | python:micropython:generalites [Date inconnue] (Version actuelle) – supprimée - modification externe (Date inconnue) 127.0.0.1 |
|---|
| [[:python:micropython:accueil|{{ :iconemaison.jpg?nolink&25|Sommaire MicroPython, CircuitPython}}]] | |
| |
| ==== MicroPython - Circuit Python - Généralités ==== | |
| |
| {{ :python:micropython:mpyvscpy.jpg?nolink&400|}} | |
| |
| [Mise à jour le : 3/6/2023] | |
| |
| * **Ressources** | |
| * <html><a href="https://micropython.org/" target="_blank">Site MicroPython</a></html> | |
| * <html><a href="https://circuitpython.org/" target="_blank">Site CircuitPython</a></html> | |
| |
| ---- | |
| |
| <callout type="primary" icon="true"><html><a href="https://micropython.org/" target="_blank"><strong>MicroPython</strong></a></html> est une implémentation simple et efficace du langage de programmation **Python 3**, qui inclut un petit sous-ensemble de la bibliothèque standard Python et qui est optimisée pour fonctionner sur des microcontrôleurs. Il est suffisamment compact pour s’adapter à **256 ko d’espace de code** et à **16 ko de RAM**.</callout> | |
| |
| <callout type="primary" icon="true"><html><a href="https://circuitpython.org/" target="_blank"><strong>CircuitPython</strong></a></html> est un **dérivé open source** du langage de programmation **MicroPython** destiné aux étudiants et aux débutants. Le développement de CircuitPython est soutenu par **Adafruit Industries**. Il s'agit d'une implémentation logicielle du langage de programmation Python 3, écrit en C.</callout> | |
| |
| |
| |
| |
| === 2. Cartes à microcontrôleur programmables avec MicroPython === | |
| ^ ESP8266 ^ ESP32 ^ Raspberry Pi Pico W (RP2W) ^ BrainPad Pulse et Tick ^ | |
| | {{ :python:micropython:huzzah8266.jpg?nolink }} | {{ :python:micropython:huzzah32.jpg?nolink }} | {{ :python:micropython:rpipicow.jpg?nolink }} | {{ :python:micropython:brainpad2021.jpg?nolink }} | | |
| | <html><a href="https://docs.micropython.org/en/latest/esp8266/quickref.html" target="_blank">MicroPython</a></html> | <html><a href="https://docs.micropython.org/en/latest/esp32/quickref.html" target="_blank">MicroPython</a></html> | <html><a href="https://docs.micropython.org/en/latest/rp2/quickref.html" target="_blank">Micropython</a></html> | <html><a href="https://www.brainpad.com/" target="_blank">Site BrainPad</a></html> | | |
| ^ Pyboard v1.1 ^ Wipy ^ Flip&Click SAM3X ^ Micro bit ^ | |
| | {{ :python:micropython:pyboard.jpg?nolink }} | {{ :micropython:wipysidetranstemp-800x800.png?nolink }} | {{ :micropython:flip-n-click-sam3x-thickbox_default-1.jpg?nolink }} | {{ :micropython:microbit.jpg?nolink }} | | |
| | <html><a href="https://micropython.org/" target="_blank">MicroPython</a></html> | <html><a href="https://pycom.io/" target="_blank">Pycom</a></html> | <html><a href="https://www.mikroe.com/flip-n-click-sam3x" target="_blank">MikroElektronica</a></html> | <html><a href="http://microbit.org/fr/" target="_blank">BBC</a></html> | | |
| \\ | |
| === 3. Les bibliothèques === | |
| ==3.1 Le module machine == | |
| Le module **machine** contient des fonctions spécifiques au matériel d'un microcontrôleur particulier. Ces fonctions permettent d'accéder aux composants matériels. En particulier : | |
| - l'unité centrale, \\ | |
| - les temporisateurs, \\ | |
| - les bus et \\ | |
| - les broches d'entrée/sortie. | |
| |
| //Exemples// | |
| <code python *.py> | |
| import machine # Importe tout le module | |
| from machine import Pin # Importe uniquement la classe Pin pour accéder aux E/S | |
| |
| led = Pin(2, Pin.OUT) | |
| led.value(1) | |
| </code> | |
| |
| == 3.2 Le module time == | |
| Le module **time** fournit des fonctions liées au temps. La classe **sleep** de ce module met en pause l'exécution du programme en cours pendant le nombre de secondes spécifiées. | |
| |
| //Exemples// | |
| <code python *.py> | |
| from machine import Pin | |
| from time import sleep | |
| |
| led = Pin(2, Pin.OUT) | |
| |
| while True: | |
| led.value(1) | |
| sleep(0.5) | |
| led.value(0) | |
| sleep(0.5 | |
| </code> | |
| |
| === 4. WebREPL === | |
| * **Source** : <html><a href="https://www.lecluse.fr/blog/iot_micropython/installer-micropython-sur-un-esp826632/" target="_blank">Installer micropython sur un ESP8266/32</a></html> | |
| |
| |