While the HUZZAH ESP8266 breakout 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, 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, you will need a USB to serial converter! Use either an FTDI cable or any console cable, you can use either 3V or 5V logic and power as there is level shifting on the RX pin.
Don't forget to visit esp8266.com for the latest and greatest in ESP8266 news, software and gossip!
The ESP8266 uses a lot of current, so if you're getting flakey behavior make sure you are plugging your console cable into either a motherboard USB port or a powered USB hub. Don't use the 'extra' USB port on your monitor or keyboard.
Connect USB-Serial cableConnect either your console cable or FTDI cable. If using FTDI, make sure the black wire goes to the GND (ground) pin
If using a console cable, connect the black wire to ground, red wire to V+, white wire to TX and green wire to RX
You will see the red and blue onboard LED flicker when powered up, but they will not stay lit.
Install the ESP8266 Board PackageEnter http://arduino.esp8266.com/stable/package_esp8266com_index.json
into Additional Board Manager URLs field in the Arduino v1.6.4+ preferences.
Next, use the Board manager to install the ESP8266 package.
Setup ESP8266 SupportWhen you've restarted, select Adafruit Feather HUZZAH ESP8266 from the Tools->Board dropdown. Note that even though this is a Huzzah breakout, its the same 'definition' file as the Feather so just use that!
80 MHz as the CPU frequency (you can try 160 MHz overclock later)
115200 baud upload speed is a good place to start - later on you can try higher speeds but 115200 is a good safe place to start. You can move down to lower speeds if you are having upload issues, or speed it up if your setup is stable, for faster uploads!
The matching COM/serial port for your FTDI or USB-Serial cable
You don't have to set Programmer because it will always use the serial port, just ignore that menu item!
Blink TestWe'll begin with the simple blink test
Enter this into the sketch window (and save since you'll have to)
void setup() { pinMode(0, OUTPUT); } void loop() { digitalWrite(0, HIGH); delay(500); digitalWrite(0, LOW); delay(500); }
void setup() { pinMode(0, OUTPUT); } void loop() { digitalWrite(0, HIGH); delay(500); digitalWrite(0, LOW); delay(500); }
Now you'll need to put the board into bootload mode. You'll have to do this before each upload. There is no timeout for bootload mode, so you don't have to rush!
Once the ESP board is in bootload mode, upload the sketch via the IDE
If the upload is successful, it should end with this message:
Hard resetting via RTS pin...
Hard resetting via RTS pin...
Once you see that, press the RESET button and the sketch will then run.
Connecting via WiFiOK 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:
/* * Simple HTTP get webclient test */ #include <ESP8266WiFi.h> const char* ssid = "yourssid"; const char* password = "yourpassword"; const char* host = "wifitest.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()); Serial.print("Netmask: "); Serial.println(WiFi.subnetMask()); Serial.print("Gateway: "); Serial.println(WiFi.gatewayIP()); } 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"); }
/* * Simple HTTP get webclient test */ #include <ESP8266WiFi.h> const char* ssid = "yourssid"; const char* password = "yourpassword"; const char* host = "wifitest.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()); Serial.print("Netmask: "); Serial.println(WiFi.subnetMask()); Serial.print("Gateway: "); Serial.println(WiFi.gatewayIP()); } 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"); }
Dont forget to update
const char* ssid = "yourssid";
const char* password = "yourpassword";
to your access point and password, then upload the same way: get into bootload mode, then upload code via IDE
Open up the IDE serial console at 115200 baud to see the connection and webpage printout!
Don't worry if it says this is a test of the CC3000 modules. We wrote this little webpage in 2013 and haven't updated it much! :)
That's it, pretty easy!
This page was just to get you started and test out your module. For more information, check out the ESP8266 port github repository for much more up-to-date documentation!
Page last edited March 08, 2024
Text editor powered by tinymce.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4