Différences
Ci-dessous, les différences entre deux révisions de la page.
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:53] – [3.1 Bus I2C] phil | python:micropython:comserie [Date inconnue] (Version actuelle) – supprimée - modification externe (Date inconnue) 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | [[: | ||
- | |||
- | ===== MicroPython - Communication série ===== | ||
- | {{ : | ||
- | |||
- | [Mise à jour le : 4/6/2023] <color # | ||
- | * **Ressources** | ||
- | * < | ||
- | * < | ||
- | * < | ||
- | * < | ||
- | |||
- | ==== 1. Présentation ==== | ||
- | |||
- | ==== 2 Communication synchrone ==== | ||
- | |||
- | ==== 3. Communication asynchrone ==== | ||
- | === 3.1 Bus I2C === | ||
- | |||
- | == Outils == | ||
- | <button type=" | ||
- | < | ||
- | <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 time | ||
- | import board | ||
- | import busio | ||
- | |||
- | i2c_0 = busio.I2C(board.GP9, | ||
- | i2c_1 = busio.I2C(board.GP7, | ||
- | |||
- | while not i2c_0.try_lock(): | ||
- | pass | ||
- | |||
- | while not i2c_1.try_lock(): | ||
- | pass | ||
- | |||
- | try: | ||
- | while True: | ||
- | print( | ||
- | " | ||
- | [hex(device_address_0) for device_address_0 in i2c_0.scan()]," | ||
- | [hex(device_address_1) for device_address_1 in i2c_1.scan()]," | ||
- | ) | ||
- | time.sleep(2) | ||
- | |||
- | finally: | ||
- | i2c_0.unlock() | ||
- | i2c_1.unlock() | ||
- | </ | ||
- | </ | ||
- | |||