Modifications

Sauter à la navigation Sauter à la recherche
2 824 octets ajoutés ,  2 juin 2021 à 10:04
Ligne 125 : Ligne 125 :     
== Interface Infrarouge ==
 
== Interface Infrarouge ==
L'émission/réception infrarouge sur ESP32 est pris en charge par le module RMT (pour ''Remote'', voir [https://github.com/micropython/micropython/pull/5184 ce fil de discussion] sur l'implémentation de la fonctionnalité).
+
L'émission infrarouge sur ESP32 est pris en charge par le module RMT (pour ''Remote'', voir [https://github.com/micropython/micropython/pull/5184 ce fil de discussion] sur l'implémentation de la fonctionnalité).
 +
 
 +
Bien que ce module soit destiné à l'émission/réception, seule l'émission semble prise en charge.
    
[[Fichier:MicroPython-esp32-evb-IR.jpg]]
 
[[Fichier:MicroPython-esp32-evb-IR.jpg]]
    +
=== Envoyer des codes IR ===
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
 
from esp32 import RMT, Pin
 
from esp32 import RMT, Pin
 
r = esp32.RMT(0, pin=Pin(12), clock_div=8, carrier_freq=38000)
 
r = esp32.RMT(0, pin=Pin(12), clock_div=8, carrier_freq=38000)
 +
# The channel resolution is 100ns (1/(source_freq/clock_div))=1/(80 000 000/8)
 +
 +
# Send start->0 for 100ns, 1 for 2000ns, 0 for 200ns, 1 for 4000ns
 +
r.write_pulses((1, 20, 2, 40), start=0) 
 +
</syntaxhighlight>
 +
 +
Vous pouvez éventuellement utiliser la bibliothèque '''ir_tx''' de Peter Inch (voir ci-dessous)
 +
 +
=== Recevoir des codes IR ===
 +
 +
Peter Inch à fait un excellent travail avec sa [https://github.com/peterhinch/micropython_ir bibliothèque '''micropython_ir'''] .
 +
 +
Celle-ci fonctionne parfaitement avec MicroPython sur ESP32.
 +
 +
Le protocole NEC est l'un des plus répandus. Si vous avez une veille télécommande, il y a de fortes changes qu'elle utilise le protocole d'émission NEC.
 +
 +
[[Fichier:MicroPython-esp32-evb-NEC-Remote.jpg|250px]]
 +
 +
Le code d'exemple suivant à été testé directement sur la plateforme ESP32-EVB (GPIO 39)
 +
 +
<syntaxhighlight lang="python">
 +
MicroPython v1.15 on 2021-04-18; ESP32 module with ESP32
 +
Type "help()" for more information.
 +
>>>
 +
>>> from machine import Pin
 +
>>> from ir_rx.nec import NEC_8
 +
>>>
 +
>>> ir = NEC_8( Pin( 39, Pin.IN), callback )
 +
>>>
 +
>>> def callback( data, addr, ctrl ):
 +
...    if data < 0:
 +
...        print('Repeat code')
 +
...    else:
 +
...        print( 'Data {:02x} Addr {:04x}'.format(data,addr) )
 +
...
 +
>>> ir = NEC_8( Pin( 39, Pin.IN), callback )
 +
>>> Data 14 Addr 0000
 +
Repeat code
 +
Data 0a Addr 0000
 +
Repeat code
 +
Data 0a Addr 0000
 +
Repeat code
 +
Repeat code
 +
Repeat code
 +
Repeat code
 +
Repeat code
 +
Repeat code
 +
Data 18 Addr 0000
 +
Repeat code
 +
Data 19 Addr 0000
 +
Repeat code
 
</syntaxhighlight>
 
</syntaxhighlight>
    +
Voici les protocoles supportés par la bibliothèque micropython_ir
 +
* from ir_rx.nec import NEC_8, NEC_16
 +
* from ir_rx.sony import SONY_12, SONY_15, SONY_20
 +
* from ir_rx.philips import RC5_IR, RC6_M0
 +
* from ir_rx.mce import MCE # Microsoft MCE remote control
   −
{{underline|Ressources:}}
+
=== Ressources ===
 
* [http://docs.micropython.org/en/v1.15/library/esp32.html#rmt Documentation Officielle du module RMT]
 
* [http://docs.micropython.org/en/v1.15/library/esp32.html#rmt Documentation Officielle du module RMT]
 
* [http://blog.bschwind.com/2016/05/29/sending-infrared-commands-from-a-raspberry-pi-without-lirc/ Excellent article bien documenté sur la réception et décodage de signaux IR sur un GPIO].
 
* [http://blog.bschwind.com/2016/05/29/sending-infrared-commands-from-a-raspberry-pi-without-lirc/ Excellent article bien documenté sur la réception et décodage de signaux IR sur un GPIO].
 +
 +
== Interface CAN ==
 +
{{ambox-stop|text=Le firmware officiel ESP32 ne contient pas de classe CAN. }}
 +
 +
Ceci étant, nos86 à produit une [https://github.com/nos86/micropython/tree/esp32-can-driver version de MicroPython V1.13 pour ESP32 incluant un module machine_can.c] ainsi que l'exemple [https://github.com/nos86/micropython/blob/esp32-can-driver/examples/esp32_can.py esp32_can.py] autour du transciever MCP2251 (comme sur la présente carte).
 +
 +
Il y a bien eu une tentative de [https://github.com/micropython/micropython/pull/5310 Pull-Request #5310] mais ce dernier n'est pas arrivé à terme, il ne suivait pas l'interface {{fname|machine.CAN}} du port STM32.
    
== Interface LAN8710A ==
 
== Interface LAN8710A ==
Ligne 149 : Ligne 215 :  
lan = network.LAN( id=None, clk_type=3, mdc=Pin(23), mdio=Pin(18), power=Pin(21), phy_addr=1, phy_type=network.PHY_LAN8720 )
 
lan = network.LAN( id=None, clk_type=3, mdc=Pin(23), mdio=Pin(18), power=Pin(21), phy_addr=1, phy_type=network.PHY_LAN8720 )
 
</nowiki>
 
</nowiki>
 +
 +
== GPIO ==
 +
Les GPIO disponibles sur la carte s'utilisent comme n'importe quel GPIO sous MicroPython.
 +
 +
'''Attention:''' Les fonctions de la carte (relais, CAN, IR, etc) sont également indiqué sur la documentation du GPIO
 +
 +
[[Fichier:MicroPython-esp32-evb-GPIO.jpg]]
    
== Où acheter ==
 
== Où acheter ==
29 922

modifications

Menu de navigation