Ligne 1 : |
Ligne 1 : |
| {{FEATHER-ESP8266-NAV}} | | {{FEATHER-ESP8266-NAV}} |
− |
| |
− | {{traduction}}
| |
| | | |
| == Préambule == | | == Préambule == |
Ligne 30 : |
Ligne 28 : |
| == Hello World == | | == Hello World == |
| | | |
− | Ok we can now turn on an LED. There is a red LED on each board, connected to '''GPIO #0'''
| + | Nous pouvons maintenant allumer une LED. Il y a une LED rouge sur chaque carte, elle est connectée sur le broche '''GPIO #0''' |
| | | |
− | {{ambox|text=NodeMCU's pinouts are not the same as the Arduino/gcc pinouts. We print the Arduino pinouts on the board so watch out!}} | + | {{ambox|text=La numérotation des broches de NodeMCU n'est pas identique à celle utilisée pour Arduino/gcc. Adafruit à imprimé la numérotation Arduino sur les cartes... faites attention!}} |
| | | |
− | {{ambox|text=The Lua documentation for the ESP8266 has GPIO #4 and #5 swapped so if #4/#5 aren't working for you, try swapping!}} | + | {{ambox|text=La documentation Lua pour l'ESP8266 a inversé les GPIO #4 et #5 swapped. Si les brcohes #4/#5 ne fonctionnent pas comme attendu, essayez de les inverser!}} |
| | | |
| {| class="wikitable" border="1" | | {| class="wikitable" border="1" |
| |- | | |- |
− | | align="center" | Pin Notes | + | | align="center" | Note concernant<br />la broche |
− | | align="center" | PCB/Arduino | + | | align="center" | Carte/Arduino |
| | align="center" | NodeMCU/Lua | | | align="center" | NodeMCU/Lua |
| |- style="font-size: 90%" | | |- style="font-size: 90%" |
Ligne 91 : |
Ligne 89 : |
| |} | | |} |
| | | |
− | So to set the pin #0 LED on and off (which would be pin #3 in Lua) first make it an output:
| + | Par conséquent, pour allumer ou éteindre la LED sur la broche #0 (qui sera la broche #3 dans Lua), nous allons configurer la broche en sortie: |
| | | |
| <nowiki>gpio.mode(3, gpio.OUTPUT)</nowiki> | | <nowiki>gpio.mode(3, gpio.OUTPUT)</nowiki> |
| | | |
− | Turn the LED on with:
| + | Allumer la LED avec: |
| | | |
| <nowiki>gpio.write(3, gpio.LOW)</nowiki> | | <nowiki>gpio.write(3, gpio.LOW)</nowiki> |
| | | |
− | Et eteindre la LED: | + | Et éteindre la LED: |
| | | |
| <nowiki>gpio.write(3, gpio.HIGH)</nowiki> | | <nowiki>gpio.write(3, gpio.HIGH)</nowiki> |
| | | |
− | You can make this a little more automated by running:
| + | Nous pouvons automatiser un peu les choses en utilisant le code suivant: |
| | | |
| <nowiki>while 1 do | | <nowiki>while 1 do |
| gpio.write(3, gpio.HIGH) | | gpio.write(3, gpio.HIGH) |
− | tmr.delay(1000000) -- wait 1,000,000 us = 1 second | + | tmr.delay(1000000) -- attendre 1.000.000 µs = 1 seconde |
| gpio.write(3, gpio.LOW) | | gpio.write(3, gpio.LOW) |
− | tmr.delay(1000000) -- wait 1,000,000 us = 1 second | + | tmr.delay(1000000) -- attendre 1.000.000 µs = 1 seconde |
| end</nowiki> | | end</nowiki> |
| | | |
| + | Ce qui fait clignoter LED en continu. |
| | | |
− | The LED will now be blinking on and off.
| + | {{underline|Note:}} |
| | | |
− | Note that since its in a loop, its not possible to get it to stop via the interpretter. To stop it, click the '''Reset''' button again!
| + | Etant donné que c'est une boucle infinie, il n'est pas possible de l'arrêter via l'interpréteur. Pressez une nouvelle fois le bouton '''Reset''' pour arrêter la boucle! |
| | | |
| == Scanner le réseau WiFi et connexion == | | == Scanner le réseau WiFi et connexion == |
− | We'll continue with a quick demo of scanning for WiFi and connecting.
| + | Continuons avec cette petite démo qui scan et connecte les réseaux WiFi et s'y connecte. |
| | | |
| Once you're back at the Lua prompt, set the ESP8266 into WiFi Client mode with | | Once you're back at the Lua prompt, set the ESP8266 into WiFi Client mode with |
Ligne 126 : |
Ligne 125 : |
| Then you can run the scanner and have it print out the available AP's | | Then you can run the scanner and have it print out the available AP's |
| | | |
− | <nowiki>-- print ap list | + | <nowiki>-- affiche la liste ap (Access Point = Point d Acces) |
| function listap(t) | | function listap(t) |
| for k,v in pairs(t) do | | for k,v in pairs(t) do |
Ligne 134 : |
Ligne 133 : |
| wifi.sta.getap(listap)</nowiki> | | wifi.sta.getap(listap)</nowiki> |
| | | |
− | or for more detail...
| + | ou pour plus de détails... |
| | | |
− | <nowiki>-- print ap list | + | <nowiki>-- afficher la liste des Access Points |
| function listap(t) | | function listap(t) |
| for ssid,v in pairs(t) do | | for ssid,v in pairs(t) do |
Ligne 146 : |
Ligne 145 : |
| wifi.sta.getap(listap)</nowiki> | | wifi.sta.getap(listap)</nowiki> |
| | | |
− | We can connect to the access point with '''wifi.sta.config''' and '''wifi.sta.connect''' - it will take a second or two to complete the connection, you can query the module to ask the status with '''wifi.sta.status()''' - when you get a 5 it means the connection is completed and DHCP successful
| + | Nous pouvons nous connecter sur un point d'accès à l'aide de '''wifi.sta.config''' et '''wifi.sta.connect''' - ce qui prendra une seconde ou deux pour établir complètement la connexion. Vous pouvez interroger l'état du module à l'aide de '''wifi.sta.status()'''. Lorsque vous obtenez la valeur 5, cela signifie que le processus de connexion et DHCP (obtention de l'adresse IP) sont complétés avec succès. |
| | | |
− | <nowiki>wifi.sta.config("accesspointname","yourpassword") | + | <nowiki>wifi.sta.config("nom_du_point_d_access","votre_mot_de_passe") |
| wifi.sta.connect() | | wifi.sta.connect() |
− | tmr.delay(1000000) -- wait 1,000,000 us = 1 second | + | tmr.delay(1000000) -- attendre 1,000,000 µs = 1 seconde |
| print(wifi.sta.status()) | | print(wifi.sta.status()) |
| print(wifi.sta.getip())</nowiki> | | print(wifi.sta.getip())</nowiki> |
| | | |
| == Exemple WebClient == | | == Exemple WebClient == |
| + | Une fois l'adresse IP obtenue, vous pouvez vous connecter sur un site (Adafruit par exmple) et lire + afficher le contenu d'une page web. |
| | | |
− | Once you're got the IP address you can connect to adafruit, for example, and read a webpage and print it out:
| + | Saisissez le code suivant: |
| | | |
| <nowiki>sk=net.createConnection(net.TCP, 0) | | <nowiki>sk=net.createConnection(net.TCP, 0) |
Ligne 164 : |
Ligne 164 : |
| </nowiki> | | </nowiki> |
| | | |
− | You can also have the module do DNS for you, just give it the hostname instead of IP address:
| + | Vous pouvez également demander au module de faire une résolution DNS pour vous. Il suffit de lui communiquer le nom de l'hôte (''hostname'') à la place de l'adresse IP: |
| + | |
| + | Saisissez le code suivant: |
| | | |
| <nowiki>sk=net.createConnection(net.TCP, 0) | | <nowiki>sk=net.createConnection(net.TCP, 0) |
Ligne 171 : |
Ligne 173 : |
| sk:send("GET /testwifi/index.html HTTP/1.1\r\nHost: www.adafruit.com\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")</nowiki> | | sk:send("GET /testwifi/index.html HTTP/1.1\r\nHost: www.adafruit.com\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")</nowiki> |
| | | |
− | This is just a light overview of testing out your HUZZAH ESP breakout! For much more, check out NodeMCU's tutorial page [https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en] for the details on what functions are available to you, as well as [http://www.lua.org/ http://www.lua.org] to learn more about the Lua scripting language
| + | Voici qui termine cette petite introduction (et tests) deu breakout ESP8266 / Feather ESP8266! |
| + | |
| + | Pour plus d'information, voyez la page du tutoriel NodeMCU sur [https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en]. Vous y obtiendrez de nombreux détails sur les fonctions disponibles. Vous pouvez également consulter le lien [http://www.lua.org/ http://www.lua.org] pour en apprendre plus sur le langage de scripting Lua. |
| + | |
| {{FEATHER-ESP8266-TRAILER}} | | {{FEATHER-ESP8266-TRAILER}} |