Adafruit HUZZAH ESP8266 breakout Created by lady ada Last updated on 2017-11-20 08:42:12 PM UTC
Guide Contents Guide Contents Overview Pinouts Power Pins Serial pins GPIO pins Analog Pins Other control pins Assembly 2 4 9 10 11 12 13 13 14 Prepare the header strip: Add the breakout board: And Solder! 14 15 15 Using NodeMCU Lua Connect USB-Serial cable Open up serial console Hello world! Scanning & Connecting to WiFi WebClient example Using Arduino IDE Connect USB-Serial cable Install the Arduino IDE 1.6.
I can't get Lua to respond to my commands © Adafruit Industries https://learn.adafruit.
Overview Add Internet to your next project with an adorable, bite-sized WiFi microcontroller, at a price you like! The ESP8266 processor from Espressif is an 80 MHz microcontroller with a full WiFi front-end (both as client and access point) and TCP/IP stack with DNS support as well. While this chip has been very popular, it's also been very difficult to use. Most of the low cost modules are not breadboard friendly, don't have an onboard 500mA 3.
The HUZZAH ESP8266 breakout is what we designed to make working with this chip super easy and a lot of fun. We took a certified module with an onboard antenna, and plenty of pins, and soldered it onto our designed breakout PCBs. We added in: Reset button User button that can also put the chip into bootloading mode, Red LED you can blink Level shifting on the UART and reset pin 3.
Two parallel, breadboard-friendly breakouts on either side give you access to: 1 x Analog input (1.0V max) 9 x GPIO (3.3V logic), which can also be used for I2C or SPI 2 x UART pins 2 x 3-6V power inputs, reset, enable, LDO-disable, 3.3V output One breakout at the end has an "FTDI" pinout so you can plug in an FTDI or console cable to upload software and read/write debugging information via the UART.
Each module comes pre-loaded with NodeMCU's Lua interpreter (NodeMCU 0.9.5 build 20150318 / Lua 5.1.4 to be specific), you can run commands, and 'save' Lua programs directly to the module's Flash using a USB-Serial converter cable. But, if you'd like, you can skip Lua and go direct to using the Arduino IDE. Once you download the ESP8266 core, you can treat it just like a microcontroller+WiFi board, no other processors needed! © Adafruit Industries https://learn.adafruit.
Each order comes with one assembled and tested HUZZAH ESP8266 breakout board, and a stick of 0.1" header that you can solder on and plug the breakout into a breadboard. A soldering iron and solder is required for that, and aren't included. You'll also need a USB-serial cable such as a USB console cable (Windows only), FTDI Friend (any OS), or FTDI cable (any OS) to upload software to the HUZZAH ESP8266! Don't forget to visit esp8266.
Pinouts The ESP8266 runs on 3.3V power and logic, and unless otherwise specified, GPIO pins are not 5V safe! The analog pin is also 1.0V max! This ESP8266 breakout has a ton of pins available, compared to the mini ESP-01 module. When programming the breakout in Lua or via the Arduino IDE, you can control these I/O pins to light up LEDs, read buttons, talk to sensors etc. There's also a bunch of pins for power and control. © Adafruit Industries https://learn.adafruit.
Power Pins The ESP8266 requires 3.3V power voltage and peaks at 500mA or so of current for small periods of time. You'll want to assume the ESP8266 can draw up to 250mA so budget accordingly. To make it easier to power, we put a highcurrent-capable 3.3V voltage regulator on the board. It can take 3.4-6V in but you should stick to 4-6V since the ESP8288 has high current usage when WiFi is on. There are two inputs for the regulator, V+ and VBat.
Serial pins RX and TX are the serial control and bootloading pins, and are how you will spend most of your time communicating with the ESP module. The TX pin is the output from the module and is 3.3V logic. The RX pin is the input into the module and is 5V compliant (there is a level shifter on this pin) The pins are available in two places, one set is on the right side breakout. The same pins are also at the bottom on the "FTDI/Serial" breakout © Adafruit Industries https://learn.adafruit.
GPIO pins This breakout has 9 GPIO: #0, #2, #4, #5, #12, #13, #14, #15, #16 all GPIO are 3.3V logic level in and out, and are not 5V compatible. Read the full spec sheet to learn more about the GPIO pin limits, but be aware the maximum current drawn per pin is 12mA. These pins are general purpose and can be used for any sort of input or output. Most also have the ability to turn on an internal pullup.
Analog Pins There is also a single analog input pin called A. This pin has a ~1.0V maximum voltage, so if you have an analog voltage you want to read that is higher, it will have to be divided down to 0 - 1.0V range Other control pins We have a few other pins for controlling the ESP8266 LDO - this is the enable pin for the regulator. By default it's pulled high, when connected to ground it will turn off the 3.3V regulator and is an easy way to cut power off to the whole setup.
Assembly Prepare the header strip: Cut two strips to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down © Adafruit Industries https://learn.adafruit.
Add the breakout board: Place the breakout board over the pins so that the short pins poke through the breakout pads And Solder! Be sure to solder all pins for reliable electrical contact. Solder one side of the board at first (For tips on soldering, be sure to check out our Guide to Excellent Soldering (https://adafru.it/aTk)). © Adafruit Industries https://learn.adafruit.
Flip the breadboard around to solder the other strip © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
You're done! Check your solder joints visually and continue onto the next steps If you're planning on programming with an FTDI or console cable, it's handy to have 6 pins soldered on the end for plugging in. Cut another 6-pin strip to length if necessary. Insert it into a breadboard - long pins down Place the breakout on the breadboard facing down © Adafruit Industries https://learn.adafruit.
Solder all 6 pins! You're done! Check your solder joints visually and continue onto the next steps © Adafruit Industries https://learn.adafruit.
Using NodeMCU Lua We have found Lua is best for typing in short commands for testing things out, we suggest Arduino IDE for the best and most-tested programming interface! Each HUZZAH ESP8266 breakout comes pre-programmed with NodeMCU's Lua interpreter. As of this writing, we ship with NodeMCU 0.9.5 build 20150318 powered by Lua 5.1.
You will see the red and blue onboard LED flicker when powered up, but they will not stay lit. Open up serial console Next up, on your computer, use a serial console program such as CoolTerm (Mac) or Putty (Windows) or screen (linux). Teraterm seems to dislike the initial 115.2kbps data stream from the ESP8266 so you can try it but you'll possibly need to reset the terminal software.
Once the terminal software is connected, click the Reset button on the HUZZAH ESP board to reset it and have it print out the welcome message: © Adafruit Industries https://learn.adafruit.
If you don't get this message, first check that the red/blue leds flickered when you press the reset button. If they didnt, make sure the board is powered via V+ or Vbat. If they do flicker, make sure you've got the right baud rate selected in the software (9600) and the RX/TX/GND pins connected right Hello world! Ok we can now turn on an LED. There is a red LED on each board, connected toGPIO #0 NodeMCU's pinouts are not the same as the Arduino/gcc pinouts.
Pin Notes PCB/Arduino NodeMCU/Lua No pullups! 0 3 2 4 3 9 4 1 5 2 9 11 10 12 12 6 13 7 14 5 15 8 16 0 So to set the pin #0 LED on and off first make it an output by typing (not copy & paste) gpio.mode(3, gpio.OUTPUT) Turn the LED on by typing (not copy & paste) gpio.write(3, gpio.LOW) And off by typing (not copy & paste) gpio.write(3, gpio.HIGH) You can make this a little more automated by running a longer script.
gpio.mode(3, gpio.OUTPUT) while 1 do gpio.write(3, gpio.HIGH) tmr.delay(1000000) -- wait 1,000,000 us = 1 second gpio.write(3, gpio.LOW) tmr.delay(1000000) -- wait 1,000,000 us = 1 second end The LED will now be blinking on and off. Note that since it's in a loop, it's not possible to get it to stop via the interpreter. To stop it, click the Reset button again! This code halts the processor during the tmr.
wifi.setmode(wifi.STATION) Then you can run the scanner and have it print out the available AP's -- print ap list function listap(t) for k,v in pairs(t) do print(k.." : "..v) end end wifi.sta.getap(listap) or for more detail... -- print ap list function listap(t) for ssid,v in pairs(t) do authmode, rssi, bssid, channel = string.match(v, "(%d),(-?%d+),(%x%x:%x%x:%x%x:%x%x:%x%x:%x%x),(%d+)") print(ssid,authmode,rssi,bssid,channel) end end wifi.sta.getap(listap) We can connect to the access point with wifi.
wifi.sta.config("accesspointname","yourpassword") wifi.sta.connect() tmr.delay(1000000) -- wait 1,000,000 us = 1 second print(wifi.sta.status()) print(wifi.sta.getip()) WebClient example Once you've got the IP address you can connect to adafruit, for example, and read a webpage and print it out: sk=net.createConnection(net.TCP, 0) sk:on("receive", function(sck, c) print(c) end ) sk:connect(80,"104.236.193.178") sk:send("GET /testwifi/index.html HTTP/1.1\r\nHost: wifitest.adafruit.com\r\nConnection: keep-a
This is just a light overview of testing out your HUZZAH ESP breakout! For much more, check out NodeMCU's documentation page https://nodemcu.readthedocs.io/ for the details on what functions are available to you, as well as http://www.lua.org to learn more about the Lua scripting language © Adafruit Industries https://learn.adafruit.
Using Arduino IDE 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.
You will see the red and blue onboard LED flicker when powered up, but they will not stay lit. Install the Arduino IDE 1.6.4 or greater 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 You can also try downloading the ready-to-go package from the ESP8266-Arduino project, if the proxy is giving you problems Install the ESP8266 Board Package Enter http://arduino.esp8266.com/stable/package_esp8266com_index.
Visit our guide for how to add new boards to the Arduino 1.6.4+ IDE for more info about adding third party boards. Next, use the Board manager to install the ESP8266 package. Setup ESP8266 Support When you've restarted, select Adafruit HUZZAH ESP8266 from the Tools->Board dropdown © Adafruit Industries https://learn.adafruit.
80 MHz as the CPU frequency (you can try 160 MHz overclock later) © Adafruit Industries https://learn.adafruit.
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 © Adafruit Industries https://learn.adafruit.
You don't have to set Programmer because it will always use the serial port, just ignore that menu item! Blink Test We'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); } 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! 1. 2.
The sketch will start immediately - you'll see the LED blinking. Hooray! Connecting via 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: /* * Simple HTTP get webclient test */ #include 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.
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.
Open up the IDE serial console at 115200 baud to see the connection and webpage printout! 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! © Adafruit Industries https://learn.adafruit.
Other Options You can load MicroPython onto your ESP8226 and write code in Python! It's an official MicroPython core and is fairly well supported. We even have tons of projects and getting started guides! You can also try using embedXcode which has a template for the ESP8266 with Xcode esp-open-sdk is a toolchain that will let you progam the ESP8266 processor directly (more info at the esp8266.com wiki) © Adafruit Industries https://learn.adafruit.
Downloads Datasheets ESP8266 specification sheet ESP8266 Datasheet v4.3 SPX3819 3.3V linear regulator on board for rev A AP2112K-3.3 linear regulator on board for rev C and greater FCC test report for the module used on this breakout CE test report for the module used on this breakout CAD Files Fritzing object in the Adafruit Fritzing Library EagleCAD PCB files on GitHub More Information! Huuuuge amount of information on http://www.esp8266.
© Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
ESP8266 F.A.Q. When I connect stuff to some of the pins, the Huzzah stops working. Whats up with that? The ESP8266 uses some of the pins as 'boot mode' pins so on boot they must be set to certain values: CH_PD (EN) should be always pulled high (it will disable the entire module if low) RST should be always pulled high (it will disable the entire module if low) GPIO 0 sets whether the bootloader is active, it must be pulled HIGH during power up/reset for the user program to run.
Make sure you're using a good quality USB/Serial cable. Install the official drivers for that cable too! We've also noticed that PL2303-based cables don't work on Macs for some reason. FTDI or CP210x based chipsets work best I tried that, but I'm still having difficulties uploading with the Arduino IDE Sometimes, it helps to switch the board type to "Generic ESP8266 Module".