python:micropython:comserie

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
python:micropython:comserie [2023/06/04 15:54] – [2 Communication synchrone] philpython:micropython:comserie [Date inconnue] (Version actuelle) – supprimée - modification externe (Date inconnue) 127.0.0.1
Ligne 1: Ligne 1:
-[[:python:micropython:accueil|{{ :iconemaison.jpg?nolink&30|Sommaire MicroPython, CircuitPython}}]] 
- 
-===== MicroPython - Communication série ===== 
-{{ :micropython:logomicropython.png?nolink&120|}} 
- 
-[Mise à jour le : 4/6/2023] <color #ff7f27>En cours de rédaction</color> 
-  * **Ressources** 
-    * <html><a href="https://micropython.org/" target="_blank">MicroPython.org</a></html> 
-    * <html><a href="https://docs.micropython.org/en/latest/index.html#" target="_blank">MicroPython documentation</a></html> 
-    * <html><a href="https://docs.micropython.org/en/latest/library/machine.UART.html" target="_blank">classe UART – bus de communication série duplex</a></html> 
-    * <html><a href="https://thonny.org/" target="_blank">IDE Thonny</a></html> 
- 
-==== 1. Présentation ==== 
- 
-==== 2 Communication synchrone ==== 
-=== 2.1 Bus I2C === 
- 
-== Outils == 
-<button type="default" collapse="scan">Scanner I2C</button> 
-<collapse id="scan" collapsed="true"> 
-<code python scan.py> 
-# -------------------------------------------------------------------------------- 
-# Titre : Scanner I2C 
-# Source : adafruit 
-# Langage : CircuitPython 
-# Circuit : Raspberry Pi Pico 
-# 
-# Remarques 
-# Si le bus I2C semble bloqué, utiliser le code si dessous dans la console 
-#  >>> import busio 
-#  >>> busio.I2C().unlock() 
-# -------------------------------------------------------------------------------- 
-import time 
-import board 
-import busio 
- 
-i2c_0 = busio.I2C(board.GP9, board.GP8)   # Accès I2C0 sur le Grove Shield Pi Pico 
-i2c_1 = busio.I2C(board.GP7, board.GP6)   # Accès I2C1  
- 
-while not i2c_0.try_lock(): 
-    pass 
- 
-while not i2c_1.try_lock(): 
-    pass 
- 
-try: 
-    while True: 
-        print( 
-            "Adresses:", 
-            [hex(device_address_0) for device_address_0 in i2c_0.scan()]," sur I2C0", 
-            [hex(device_address_1) for device_address_1 in i2c_1.scan()]," sur I2C1", 
-        ) 
-        time.sleep(2) 
- 
-finally:  # unlock the i2c bus when ctrl-c'ing out of the loop 
-    i2c_0.unlock() 
-    i2c_1.unlock() 
-</code>  
-</collapse> 
- 
- 
-==== 3. Communication asynchrone ==== 
  
  • python/micropython/comserie.1685886853.txt.gz
  • Dernière modification : 2023/06/04 15:54
  • de phil