Modifications

Sauter à la navigation Sauter à la recherche
Ligne 6 : Ligne 6 :     
While the Feather HUZZAH ESP8266 comes pre-programmed with NodeMCU's Lua interpretter, you don't have to use it! Instead, you can use the Arduino IDE which may be more familar. '''This will write directly to the firmware, erasing the NodeMCU firmware''', [https://github.com/nodemcu/nodemcu-flasher so if you want to go back to Lua, use the flasher to re-install it]
 
While the Feather HUZZAH ESP8266 comes pre-programmed with NodeMCU's Lua interpretter, you don't have to use it! Instead, you can use the Arduino IDE which may be more familar. '''This will write directly to the firmware, erasing the NodeMCU firmware''', [https://github.com/nodemcu/nodemcu-flasher so if you want to go back to Lua, use the flasher to re-install it]
 +
    
In order to upload code to the ESP8266 and use the serial console, connect any data-capable micro USB cable to the Feather HUZZAH and the other side to your computer's USB port. [https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx Install the required CP2104 USB driver to have the COM/Serial port appear properly]
 
In order to upload code to the ESP8266 and use the serial console, connect any data-capable micro USB cable to the Feather HUZZAH and the other side to your computer's USB port. [https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx Install the required CP2104 USB driver to have the COM/Serial port appear properly]
    +
 +
[http://www.esp8266.com/ N'oubliez pas de visiter esp8266.com pour vous tenir au courant des dernières nouvelles/logiciel/etc sur l'ESP8266!]
 +
 +
{{ambox-stop|text=N'oubliez pas d'installer le Pilote USB pour le convertisseur USB-vers-Serie CP2104! }}
 +
 +
== Installer Arduino IDE 1.6.4 ==
 +
Install the Arduino IDE 1.6.4 or greater
 +
 +
[http://www.arduino.cc/en/Main/Software Download Arduino IDE from Arduino.cc (1.6.4 or greater) - don't use 1.6.2! You can use your existing IDE if you have already installed it]
 +
 +
[https://github.com/esp8266/Arduino You can also try downloading the ready-to-go package from the ESP8266-Arduino project], if the proxy is giving you problems
 +
 +
{{ambox-stop|text= We're seeing some difficulties with IDE 1.6.6 so please try 1.6.5 or skip 1.6.6! }}
 +
 +
== Installer le support ESP8266 ==
 +
Enter [http://arduino.esp8266.com/stable/package_esp8266com_index.json http://arduino.esp8266.com/stable/package_esp8266com_index.json] into Additional Board Manager URLs field in the Arduino v1.6.4+ preferences.
 +
 +
{{ADFImage|FEATHER-ESP8266-Config-Arduino-IDE-00.png|640px}}
 +
 +
 +
[[FEATHER-M0-Config-Arduino-IDE Visitez ce guide sur le Feather M0 pour avoir plus de détails sur l'ajout du support de nouvelles cartes sous '''Arduino IDE 1.6.4+''']].
 +
 +
Next, use the '''Board manager''' to install the ESP8266 package.
 +
 +
{{ADFImage|FEATHER-ESP8266-Config-Arduino-IDE-01.png|640px}}
 +
 +
== Configurer le support ESP8266 ==
 +
When you've restarted, select '''Generic ESP8266 Module''' from the Tools->Board dropdown
 +
 +
{{ADFImage|FEATHER-ESP8266-Config-Arduino-IDE-10.png|640px}}
 +
 +
80 MHz as the CPU frequency
 +
 +
{{ADFImage|FEATHER-ESP8266-Config-Arduino-IDE-11.png|640px}}
 +
 +
115200 baud upload speed (You can also try faster baud rates, we were able to upload at a blistering 921600 baud but sometimes it fails & you have to retry)
 +
 +
{{ADFImage|FEATHER-ESP8266-Config-Arduino-IDE-12.png|640px}}
 +
 +
The matching COM port for your FTDI or USB-Serial cable
 +
 +
{{ADFImage|FEATHER-ESP8266-Config-Arduino-IDE-13.png|640px}}
 +
 +
and '''nodemcu''' as the reset method
 +
 +
{{ADFImage|FEATHER-ESP8266-Config-Arduino-IDE-14.png|640px}}
 +
 +
Check also that you have
 +
* '''Flash Mode''' : QIO
 +
* '''Flash Frequency''' : 40MHz
 +
* '''Upload Using''' : Serial
 +
* '''CPU Frequency''' : 80 MHz
 +
* '''Flash Size''' : 4M
 +
* '''Reset Method''' : nodemcu
 +
 +
== Exemple Blink ==
 +
We'll begin with the simple blink test
 +
 +
Enter this into the sketch window (and save since you'll have to)
 +
 +
<nowiki>void setup() {
 +
  pinMode(0, OUTPUT);
 +
}
 +
 +
void loop() {
 +
  digitalWrite(0, HIGH);
 +
  delay(500);
 +
  digitalWrite(0, LOW);
 +
  delay(500);
 +
}</nowiki>
 +
 +
Now you can simply upload! The '''Feather HUZZAH''' has built in auto-reset that puts it into bootloading mode automagically
 +
 +
{{ADFImage|FEATHER-ESP8266-Config-Arduino-IDE-20.png|640px}}
 +
 +
The sketch will start immediately - you'll see the LED blinking. Hooray!
 +
 +
== Se connecter en WiFi ==
 +
OK once you've got the LED blinking, lets go straight to the fun part, connecting to a webserver. Create a new sketch with this code:
 +
 +
<nowiki>      /*
 +
*  Simple HTTP get webclient test
 +
*/
 +
 +
#include <ESP8266WiFi.h>
 +
 +
const char* ssid    = "yourssid";
 +
const char* password = "yourpassword";
 +
 +
const char* host = "www.adafruit.com";
 +
 +
void setup() {
 +
  Serial.begin(115200);
 +
  delay(100);
 +
 +
  // We start by connecting to a WiFi network
 +
 +
  Serial.println();
 +
  Serial.println();
 +
  Serial.print("Connecting to ");
 +
  Serial.println(ssid);
 +
 
 +
  WiFi.begin(ssid, password);
 +
 
 +
  while (WiFi.status() != WL_CONNECTED) {
 +
    delay(500);
 +
    Serial.print(".");
 +
  }
 +
 +
  Serial.println("");
 +
  Serial.println("WiFi connected"); 
 +
  Serial.println("IP address: ");
 +
  Serial.println(WiFi.localIP());
 +
}
 +
 +
int value = 0;
 +
 +
void loop() {
 +
  delay(5000);
 +
  ++value;
 +
 +
  Serial.print("connecting to ");
 +
  Serial.println(host);
 +
 
 +
  // Use WiFiClient class to create TCP connections
 +
  WiFiClient client;
 +
  const int httpPort = 80;
 +
  if (!client.connect(host, httpPort)) {
 +
    Serial.println("connection failed");
 +
    return;
 +
  }
 +
 
 +
  // We now create a URI for the request
 +
  String url = "/testwifi/index.html";
 +
  Serial.print("Requesting URL: ");
 +
  Serial.println(url);
 +
 
 +
  // This will send the request to the server
 +
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
 +
              "Host: " + host + "\r\n" +
 +
              "Connection: close\r\n\r\n");
 +
  delay(500);
 +
 
 +
  // Read all the lines of the reply from server and print them to Serial
 +
  while(client.available()){
 +
    String line = client.readStringUntil('\r');
 +
    Serial.print(line);
 +
  }
 +
 
 +
  Serial.println();
 +
  Serial.println("closing connection");
 +
}</nowiki>
 +
 +
Dont forget to update
 +
 +
<nowiki>const char* ssid    = "yourssid";
 +
const char* password = "yourpassword";</nowiki>
 +
 +
to your access point and password, then upload the same way: get into bootload mode, then upload code via IDE
 +
 +
{{ADFImage|FEATHER-ESP8266-Config-Arduino-IDE-30.png|640px}}
 +
 +
Open up the IDE serial console at 115200 baud to see the connection and webpage printout!
 +
 +
{{ADFImage|FEATHER-ESP8266-Config-Arduino-IDE-31.png|640px}}
 +
 +
That's it, pretty easy!
 +
 +
This page was just to get you started and test out your module. For more information, check out le [https://github.com/esp8266/Arduino dépôt GitHub de l'ESP8266] for much more up-to-date documentation!
       
{{FEATHER-ESP8266-TRAILER}}
 
{{FEATHER-ESP8266-TRAILER}}
29 836

modifications

Menu de navigation