ESP8266 Support WIKI

User Tools

Site Tools


getting-started-with-the-esp8266

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
getting-started-with-the-esp8266 [2015/07/13 13:43]
danfoster Removing spam
getting-started-with-the-esp8266 [2017/02/14 20:51] (current)
admin [Getting Started with ESP8266]
Line 1: Line 1:
-===== Getting Started with ESP8266 =====+====== Getting Started with ESP8266 =====
 This page gives some information on how to get started using a ESP8266-based board. This page gives some information on how to get started using a ESP8266-based board.
 It is intended for the newbie with past experience in arduino-like mcu who wants to get a first hand at ESP8266. It is intended for the newbie with past experience in arduino-like mcu who wants to get a first hand at ESP8266.
Line 5: Line 6:
 ==== Procuring a ESP8266 based board ==== ==== Procuring a ESP8266 based board ====
 === Which ESP board? === === Which ESP board? ===
-ESP8266 usually comes assembled on a board, the most popular ones having been the ESP-NN by vendors such as AIThinkers. Olimex has also started to sell their own boards, and you can find several others too. +ESP8266 usually comes assembled on a board, the most popular ones having been the **ESP-NN** by vendors such as //AIThinkers////Olimex// has also started to sell their own boards, and you can find several others too.  The boards integrate an ESP8266 chip plus a [[wp>​Flash memory|Flash memory ​chip]] (Flash RAM)crystal, and usually on on-board WiFi antennaThe Flash RAM size and chip model can vary.
-The boards integrate an ESP8266 chip plus a SRAM chip, and an crystal. ​SRAM size and chip model can vary.+
  
-Among the ESP-XX boards, the most notable to get started is the **ESP-01**, which has a male 2x4 1/10" pitch connector that can be readily used with Dupont wires. It is not breadboard friendly because it cannot straddle the two sides of breadboards,​ though.+Among the ESP-XX boards, the most notable to get started is the **ESP-01**, which has a male 2×4 0.1" pitch connector that can be readily used with Dupont wires. ​This board exposes serial communication pins (RX/TX), and the minimal 4 control pins, GPIO0, GPIO2, CH_PD and ReSeT, plus VCC and GND of course. With this board you will have very limited  
 +access to all-purpose GPIOs.  ​It also has an on-PCB Wifi Antenna etched on the PCB, which has sufficient gain for shorter range applications. ​ Note that the ESP-01 connector on its own cannot straddle the two sides of a standard breadboard.
  
-ESP-01 exposes serial communication pins (RX/TX), and the minimal 4 control pins, GPIO0, GPIO2, CH_PD and ReSeT, plus VCC and GND of course. With that you will not have access to all-purpose GPIOs. +The other ESP-NN modules expose ​more GPIO pins, but are packaged in SMT packages, at best with a 2mm-pitch notches.
-ESP-01 also has a Wifi Antenna etched on the PCB, which is efficient enough for starters. +
- +
-The other ESP-NN modules expose GPIO pins, but are packaged in SMT packages, at best with a 2mm-pitch notches.+
 Some modules have etched antenna, some have ceramic antenna, and some have just a socket or a pin. Some modules have etched antenna, some have ceramic antenna, and some have just a socket or a pin.
 A favorite for that is the ESP-07, which has a shield (with FCC marking, but probably not registered at FCC) A favorite for that is the ESP-07, which has a shield (with FCC marking, but probably not registered at FCC)
  
 === Where to get ESP modules from? === === Where to get ESP modules from? ===
-Modules can be found in several places, just google ​for ESP8266 or ESP-01. eBay has several ​sellers, some are found on AliExpress or the bignames ​DIY electronics in US or Europe. +Modules can be found in several places, just Google ​for ESP8266 or ESP-01. eBay has a number of sellers, ​and some are found on AliExpress or the big name DIY electronics ​vendors ​in US or Europe. ​ ​Prices ​vary in the $3-$5 range for boards imported from China and slightly more if sourced from an in-country supplier. ​ European vendors such as Olimex offer modules too 
-Price vary in the $3-$5 range.+
  
-European vendors ​such as Olimex has neat modules too.+Vendors ​such as nodeMCU also offer integrated development boards that are breadboard-friendly,​ include USB connectivity onboard and present a reasonable number of I/O pins to the connector. ​ Their version 2 board is based on the ESP-12E and is available on eBay etc. for around $12-15.
  
-While you will be at it, remember to also order a (couple) USB/TTL converters. +If you are using a bare ESP-XX module then you will also need to connect to the 3.3V TTL serial port during developmentThere are many USB to serial converter modules available which present a virtual serial connection to your host PC or laptop and connect to the chip's serial interface. ​ These are based on either the FT232, CH340G or CP2102 ​chipNote: 
-Several models exist, ​based on FTDI FT232 chip, CH340G or CP2102. + 
-There are fake FT232 chips that will cause issues (due to FTDI a blotch that disables ​these chips in their windows ​driver), so better aim for CH340G or CP2102 ​if you'​re ​not ordering from the big namesPrice is from $1.4 for CH340G-based up to $5.+  * The FT232 is made by FTDI, but there are number of unlicensed FT232 clones available and some modules use these.  These FT232 clones can cause problems on Windows PCs because the FTDI-supplied FT232 driver ​now includes detection logic and will not communicate to unlicensed clones. 
 +  * The modules based on the CH340G or CP2102 ​chips do not have this issue. 
 +  * How must by a serial module what can drive TTL at 3.3V levels. ​ Many are 3.3V/5V jumpered or DIP-switchable. 
 +  * Some modules also provide a 3.3V VCC line but these are typically at 300mA or so and cannot provide enough power to run the ESP chip during WifI operation So a separate 3.3V power supply ​is needed A common approach is to use a 5.5V to 3V power module, and again there are many options available online for a few $
  
-:!: Some adapters have a 3.3V/5V switch, but they usually cannot provide enough power (300mA) to ESP chip, so a separate 5V-3.3V converter (called an '​buck'​ converter, usually adjustable) could be a good idea too. 
  
 ==== Got an ESP-NN board in the mail, now what ? ==== ==== Got an ESP-NN board in the mail, now what ? ====
-=== At-tension please ​ === +If you have development ​board such as the Lolin NodeMcu V3 Module the wiring is already done so just connect the development board to the computer USB port with a micro USB to USB cable (aka mobile phone cable)Now go straight to [[talk_to_me_baby|talk to me baby]].
-:!: Caution :!:, before anything, ESP8266 is **__3.3V__** ​board, which is //not// advertised ​as 5V-friendly. +
-This means the module must be powered from //3.3V// and any 5V I/O must be level shifted ​to 3.3V in either/both directions.+
  
-**For beginning use, the best thing is to use a USB to 3.3V TTL converter and a 3.3v power supply** and not mess with 5V levels (except maybe to feed into a 3.3v regulator).  ​Get everything working and talking and figure out how it works first, ​then proceed ​to use a level shifter+:!: **Caution**: The first and most important ​thing to note -- especially for Arduino developers -- is that  
 +ESP8266 chip only uses **__3.3V__** for power and I/O.  ​If you attempt to connect directly to 5V devices ​then at best this may simply not work and at worst this will cause permanent or fatal damage ​to the chip 
  
-Note: if you use an external power supplybe sure to connect it's ground to your USB TTL's ground, otherwise it may have trouble.+**When getting to know and use this devicethe best approach is to use a USB to 3.3V TTL converter and a 3.3v power supply**. ​ Avoid working with any devices that require or output 5V levels. ​ Get everything working and talking first 
  
-On output, 3.3V levels ​//High// voltage is also seen as //High// voltage ​by 5V TTL +Once you have done this then consider how to connect any 5V devices and interfaces if you must You will need to  
 +implement level shifting to connect to 5V devices. ​ There are plenty of resources on the internet (for example [[http://husstechlabs.com/support/tutorials/bi-directional-level-shifter|(1)]],​ [[http://electronics.stackexchange.com/questions/​18186/​cheapest-way-to-translate-5v-spi-signal-to-3v-spi|(2)]]) ​ that will help you do this, and also low cost modules such as by-direction level shifters that are available for a few $,  Also be aware of the difference between unbuffered interfaces (such as I2C) and buffered ones (such as SPI) as the level shifting apporach is different for these. 
 +   
 +Also note that if you use an external power supply, then be sure to connect its ground to your USB TTL's ground, otherwise it may have trouble.
  
-Some have reportedly been running ​on 5V TTL I/O, but this may reduce the lifespan of your device, or burn it out immediately.+You can also use some ESP01-USB converter with all wiring ​on one board. [[all-in-one-esp-usb-converter|How to use it.]]
  
-There are three ways to split tension(voltage) on input, using a resistor divider, or using a bidirectional 2N7000-based 'level shifter'​ circuit, or putting two diodes in series in the power line: +{{::usb-to-esp8266-serial-wireless-wifi-module-developent-board-8266-wifi-module.jpg_640x640.jpg?​100}}
-  * Resistor divider will use two Rs, for example 1k and 2.2k (3.3V is just 2/3rd of 5V, mind you) +
-  * Level shifter has the great advantage of working both ways, great for GPIO pins, and (probably) drawing less current than a divider (uses 10k pull ups). It has the disadvantage of being slightly more expensive, and 2N7000 are static sensitive. See [[http://​husstechlabs.com/​support/​tutorials/​bi-directional-level-shifter]] for example. +
- +
-Discussion here too: [[http://​electronics.stackexchange.com/​questions/​18186/​cheapest-way-to-translate-5v-spi-signal-to-3v-spi]]+
  
 ==== Basic wiring ==== ==== Basic wiring ====
-So, now we assume that you got:+So, let'​s ​assume that you have:
   - an ESP-01   - an ESP-01
   - a USB/TTL converter   - a USB/TTL converter
Line 56: Line 53:
   - 1k and 2.2K resistors   - 1k and 2.2K resistors
  
-Note that the FTDI USB UART adapters internal 3.3v supply ​might not provide enough current to power the ESP8266 ​under all circumstancesso some external 3.3v power supply is recommended.  It it seems to disconnect or reset, try a separate power supply.+Note that some USB UART adapters internal 3.3v supply ​are rated at 1A and can therefore ​provide enough current to power the ESP8266, ​but in general an external 3.3v power supply is recommended.
  
 Looking at the (8 pin) board from the top (chips and antenna side), with the antenna to the right, the pins from the top down in the edge row are: Looking at the (8 pin) board from the top (chips and antenna side), with the antenna to the right, the pins from the top down in the edge row are:
  
-  * TXD (goes to the RxI of the UART USB adapter to the PC)+  * TXD (goes to the 3.3V RxI of the UART USB adapter to the PC)
   * CH_PD (enable/​power down, must be pulled to 3.3v directly or via resistor)   * CH_PD (enable/​power down, must be pulled to 3.3v directly or via resistor)
   * REST (reset, must be pulled to 3.3v)   * REST (reset, must be pulled to 3.3v)
Line 70: Line 67:
   * GPIO 2   * GPIO 2
   * GPIO 0 (leave open or pull up for normal, pull down to upload new firmware)   * GPIO 0 (leave open or pull up for normal, pull down to upload new firmware)
-  * RXD (goes to TxO of the UART USB adapter to the PC)+  * RXD (goes to the 3.3V TxO of the UART USB adapter to the PC)
  
-Other modules have more pins, but these will be included. ​ If GPIO 15 is broken out, it must be pulled low to get out of the bootloader.+Other modules have more pins, but these will be included. ​ If GPIO 15 is broken out, then it must be pulled low at power-on or after reset to get out of the boot-loader.
  
 {{:​scanofmyconnections.jpeg?​300|}} {{:​scanofmyconnections.jpeg?​300|}}
Line 78: Line 75:
 {{:​esp8266_flash_prog_board.jpg?​300|}} {{:​esp8266_flash_prog_board.jpg?​300|}}
  
-If there is power, ​red LED will come on, and blue LED will flash briefly as it comes out of reset - it flashes when the UART is transmitting.+If there is power, ​The red LED will come on, and the blue LED will flash briefly as it comes out of reset -- it flashes when the UART is transmitting
 + 
 +If you have problems with the module occasionally resetting once you've attached other devices then this might be a voltage regulation issue so try adding a 220 µF capacitor across Vcc and Gnd
  
 ==== Talk to me, baby ==== ==== Talk to me, baby ====
 Once setup, you will want to start talking to the ESP. Once setup, you will want to start talking to the ESP.
-For that, a terminal emulator on windows will do.  Tera Term, Putty, Hyperterminal or nearly anything else will work.  One caution is if you detach your UART device or it goes offline (e.g. loses power or the ESP causes the chip to reset), it might not clear and reset until you exit or close or restart the program.+For that, a terminal emulator on windows will do.  Tera Term, Putty, Hyperterminal or nearly anything else will work.  One caution is if you detach your UART device or it goes offline (e.g. loses power or the ESP causes the chip to reset), it might not clear and reset until you exit or close or restart the program.  On Linux and OSX, the standard screen command does this job.
  
 First, your board might talk at any of several baud rates. ​ The ones to try first are 9600 and 115200. ​ Then 57600 and/or 76800 (38400 * 2).  Note the noise when you reset the device (pull the RST pin to ground) is typically some bootup messages at 76800. ​ But there should be a "''​ready''"​ message at the selected baud rate if your UART Rx is wired correctly. First, your board might talk at any of several baud rates. ​ The ones to try first are 9600 and 115200. ​ Then 57600 and/or 76800 (38400 * 2).  Note the noise when you reset the device (pull the RST pin to ground) is typically some bootup messages at 76800. ​ But there should be a "''​ready''"​ message at the selected baud rate if your UART Rx is wired correctly.
  
-If your UART Tx is correct, typing "''​AT''" ​**followed by control-and control-j, yes both carriage return and linefeed are needed**, should return an "''​OK''"​. ​ And you are now ready to start working with the ESP8266. ​ It should echo the characters as you type them.+If your UART Tx rate is correct, ​then try typing "''​AT''"​ followed by Ctrl-and Ctrl-J (//both carriage return and linefeed are needed//).  This should return an "''​OK''"​. ​ And you are now ready to start working with the ESP8266. ​ It should echo the characters as you type them.
  
 === Boot up === === Boot up ===
  
-By "​**H**IGH" ​I mean pulled up, usually through a resistor ​(1k), but can be directly connected to 3.3v power, and "**L**OW"​ means something similar, but to the ground pin.+(Note that by  ​"​**H**IGH"​, this means pulled up to **Vcc**.  ​(This can be directly connected to 3.3v power but a 1k pull-up resistor is normally recommended.) ​**L**OW"​ means the equivalent pulled down to **Gnd**.
  
 If one of the boot-mode pins is not set correctly, when you reset, you won't get the ready message. ​ To diagnose this, you can see what the bootloader is putting out by setting the baud rate to 76800. ​ Then you can pull the RST pin **L**ow, then **H**igh, and see what the output is. If one of the boot-mode pins is not set correctly, when you reset, you won't get the ready message. ​ To diagnose this, you can see what the bootloader is putting out by setting the baud rate to 76800. ​ Then you can pull the RST pin **L**ow, then **H**igh, and see what the output is.
Line 96: Line 95:
 It will display a message giving the reason for the reset. ​ It should give a loading message and some addresses if everything is correct. ​ If it doesn'​t give any more messages, or "​Waiting for host", or something else, one of the other pins is not connected properly. It will display a message giving the reason for the reset. ​ It should give a loading message and some addresses if everything is correct. ​ If it doesn'​t give any more messages, or "​Waiting for host", or something else, one of the other pins is not connected properly.
  
-The CH_PD must be **H**igh, as well as the RST line and GPIO 2 (or left floating, i.e. unconnected)+The CH_PD must be **H**IGH, as well as the RST line and GPIO 2 (or left floating, i.e. unconnected)
  
-GPIO 0 has to be **H**igh for normal mode, **L**ow for flashing new firmware.  ​+GPIO 0 is interrogated by the bootrom loader and if this is **L**OW then it enters ​flashing new firmware ​model; if **H**IGH then it transfers to normal execution mode, 
  
 **For the modules with extra GPIOs (more than the 8 pin), GPIO 15 must be pulled low.** **For the modules with extra GPIOs (more than the 8 pin), GPIO 15 must be pulled low.**
getting-started-with-the-esp8266.1436795024.txt.gz · Last modified: 2015/07/13 13:43 by danfoster