loading

Overview of the ESP8266 WiFi Module

The ESP8266 is a really useful, cheap WiFi module for controlling devices over the Internet. It can work with a micro-controller like the Arduino or it can be programmed to work on its own.

The Internet of Things (IoT) has just been made a whole lot cheaper and easier!

The ESP8266 comes with factory installed firmware allowing you to control it with standard “AT commands”. You can also easily create and upload your own code and this makes it hugely powerful and flexible.

The ESP8266 was launched in 2014 and is rapidly growing in popularity. There is only one ESP8266 processor but it is found on many different breakout boards. These all differ in terms of which pins are exposed and the size of the flash memory etc. These breakout boards have evolved rapidly over the years and there is a lot of information to be found on the web. This is both a blessing and a curse as some of the advice is outdated or just plain wrong.

As a result it took me 3 days before I could get it to do anything! Some people are lucky but for me it was a battle to get anything working. At times I thought I had broken it but with some perseverance it always came back to life!

I’ve finally got it singing and dancing and it turns out to be easier than I thought!

I’ve consolidated all the useful info I found into one place and I thought I’d share this in an instructable. This will hopefully get you quickly up and running with all the basic functionality that you’ll need.

In this instructable were are looking at the ESP-01 breakout board.

This same approach should however apply to most (if not all) of the variants of the ESP out there.

Step 1: The ESP-01 in a Nutshell

  1. It supports the 802.11 b/g/n protocol
  2. It can connect to your router and work as a client or it can be an access point itself or both!
  3. It is IP addressable and can be a Web Server
  4. The “standard” version has 2 digital pins that can be used for input or output. Eg: to drive LED’s or relays. These pins can also be used for PWM. Other versions have more pins exposed. For example the ESP-12, which is a good option if you need more pins. Either way the programming is still the same.
  5. Analog input is also available on the ESP8266 chip (ADC/TOUT) but it’s not wired up on the ESP-01.
  6. It can be combined with an Arduino or it can be programmed to work on its own
  7. There are various tools and development environments (IDE’s) to program it.
  8. And it has lots more….

In this demo the ESP8266 acts as a Webserver hosting a Web Page that you can interact with over WiFi.

With this demo you can start your own home automation project and control it from the web!

Step 2: What You’ll Need

Firstly let’s see if we can get it up and running.

A lot of sites recommend re-flashing the firmware and using various tools. You don’t need to do that just yet.

We’ll be replacing the firmware with our own code. In another instructable: The Simple Guide to Flashing Your ESP8266 Firmware I show you how to revert it back to an updated factory version. If you'll only be programming the ESP8266 with your own code - as we will be doing in this demo - then you don't need factory firmware. Your code is the firmware.

We'll be using the Arduino IDE as a programming tool but we don't need an Arduino itself. The ESP8266 has all the functionality we need.

Note: that after uploading your own code, your ESP8266 won't respond to AT commands any more. Your code has replaced the firmware. Using your code and the ESP8266 library in the Arduino IDE you'll have access to a richer set of commands. See the documentation here: https://www.arduino.cc/en/Reference/WiFi

You can restore the firmware on the ESP8266 to go back to AT commands if you wish. See my other instructable: The Simple Guide to Flashing Your ESP8266 Firmware.

NB: It’s a 3.3V module and not 5V. The ESP-01 is more robust than I thought but you should set it up properly, especially if you’re using it with a 5V USB to Serial Programmer or micro-controller, otherwise you may fry it!

What you’ll need:

  1. An ESP8266 of course (use the ESP-01 variant or adapt your wiring accordingly)
  2. Breadboard
  3. 3.3V USB to Serial Programmer like the FTDI Basic (sometimes known as a UART: Universal Asynchronous Receiver/Transmitter). Some come with a jumper to switch between 5V and 3.3V.
  4. Breadboard Jumper Wires
  5. A separate 3.3V Power Supply. You do need one as the ESP8266 can chew a lot of mA (>250mA at times). The 3.3V output from the Serial Programmer or the Arduino is not sufficient. Without a separate power supply your ESP may be erratic and you will waste time trying to upload code.
  6. Led, push button, 330 ohm resistor, 10k ohm resistor, .1µF capacitor across your power supply (as standard practice).
  7. Add a Logic Level Converter into the circuit if you’re using a micro-controller or FTDI programmer at 5V

If you have an ESP8266 with a built in USB port then you don't need to go through any of this hassle. The Wemos D1 Mini is a good alternative. See this: https://www.wemos.cc/product/d1-mini.html

Step 3: The Components in More Detail

ESP-01

I got my ESP-01 from: http://netram.co.za/2720-wifi-serial-transceiver-module-esp8266.html

You can have a look at the various versions here: http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family


Breadboard Power Supply

A good power supply seems to be a crucial aspect for the ESP8266. A breadboard power supply is really useful, especially when you’re dealing with mixed voltages. The one shown here supplies 3.3V and 5.5V and plugs right into your breadboard. I should have got one a long time ago! The ESP8266 can chew a lot of mA (>300mA at times). If your ESP reboots or seems unreliable then you need a separate power supply for the ESP (keep a common ground though). Also connect a capacitor across 3.3V and ground to minimise spikes and to provide a small reservoir of power.

http://netram.co.za/938-breadboard-power-supply-5v33v.html


USB to Serial programmer

Get one that supports 3.3V or has a 3.3V/5V jumper otherwise if you only have 5V then you should use a bi-directional Logic Level Converter in between the programmer and the ESP8266. The FTDI Basic has a 3.3V/5V jumper on the back:

http://netram.co.za/2842-ftdi-basic-usb-to-ttl-programmer.html

http://netram.co.za/2679-logic-level-converter-bi-directional.html


Logic Level Converter

Bi-Directional 5V & 3.3V. This is only required if you are using a 5V serial programmer.


Breadboard Jumpers

Include some JST jumpers as they’re handy for plugging onto modules with pins and then joining them to the breadboard. Include some male to female cables for this purpose. The ESP-01 isn't breadboard friendly so you'll need these.

Step 4: The Breadboard Layout

Looking at the breadboard, the FTDI programmer is the red board on top and the ESP8266-01 at the bottom. The FTDI programmer only needs 3 wires connected: the ground wire and the RX to TX and TX to RX on the ESP. On the left is the breadboard power supply (it would normally plug into the breadboard).

NB: The quality of the power supply to the ESP is one of the most important factors. There is a small capacitor (.1uF) across 3.3V and Ground to minimise spikes. If you are having problems with programming your ESP it may well be your power supply. What will help is to add another larger capacitor across 3.3V and Ground. eg: 10uF.

Step 5: The ESP-01 Pinouts

The picture above of the ESP8266 pinouts is found all over the net. I think it may have originated from Neil “Kolban’s Book on ESP8266”. This is a fantastic resource and is available as a pdf download from: https://leanpub.com/ESP8266_ESP32. It’s 400 pages long, was updated in November 2016, and if you’re into serious ESP8266 development then this is the book to get. It’s free but make a donation if you can.

Breadboard wiring notes:

  • The wires are shown connecting to the front of the ESP-01 for clarity. Attach them to the same pins from behind. The ESP-01 is not breadboard friendly and JST connector male-female jumpers are handy for connecting it.
  • GPIO 0 must be held low for programming. This should be removed if you remove the FTDI and operate the ESP8266 on its own power supply.
  • CH_PD should be held high at all times.
  • The RESET pin is held high with a 10k ohm resistor and brought to ground by the RESET button which will reboot the chip. Press RESET every time before you upload code, and every time you connect or disconnect GPIO 0. The reset button will save you a lot of hassle.

When you power the circuit up the red LED on the ESP-01 should light up and the blue LED should flash briefly. Later when uploading code to the ESP the blue LED should flash continuously during the process. Any other LED combinations suggests that there is a problem.

NB: If you want to remove the Serial programmer and run the ESP on its own, make sure you disconnect GPIO 0 from ground and push the RESET button otherwise the ESP may not work properly.

Step 6: Schematic

Step 7: Using the Arduino Instead of a Serial Programmer

You can also use an Arduino instead of your USB to Serial programmer.

A few things to note:

  1. On a 5V Arduino the digital output will be at 5V and this could fry your ESP2866. So either use a 3.3V Arduino or a Logic Converter chip
  2. The 3.3V Vout on the Arduino is insufficient to drive your ESP8266 and you could get unreliable results. Preferably use another 3.3V supply.
  3. As a recommended practice always upload a blank sketch to your Arduino before connecting any other devices to avoid any unpredictable results. A blank sketch has empty setup() and loop() functions.
  4. If you are using an Arduino Uno it only has one hardware TX&RX pair. To communicate with both the ESP8266 and the Serial Monitor at the same time you will also need to use the SoftwareSerial include file. It used to have a limitation on the baud rate but can now theoretically support a baud rate of up to 115200. A Mega 2560 has more hardware TX and RX pins so this could be a better way to go.
  5. And finally and importantly: Look closely at the TX and RX pins on the Arduino. You will notice that they have arrows next to them. The TX pin has an arrow pointing away from it. What this says is TX IN! What this really means is that the TX pin is actually the RX pin! And likewise the RX pin is actually the TX pin! So when using the Arduino as a serial adapter with another device you must connect RX to RX and TX to TX. I only discovered this nuance after several hours of pain! Why-oh-why did they label it like this?

Whilst I’m asking questions: why the ESP-01 was produced with so few of the useful pinouts exposed also baffles me! It is still a great starting point but if you need something more then go for the ESP-12.

To make things really simple, try an ESP-12 with a built in USB like:

https://www.wemos.cc/product/d1-mini.html

Step 8: Programming Using the Arduino IDE

There are various tools to program the ESP8266 but the Arduino IDE (Integrated Development Environment) is by far the easiest for most folk.

To program the ESP8266 with the Arduino IDE you’ll need to download the latest version if you don’t already have it and then install the ESP8266 support. Note that you are only using the Arduino programming environment you don't need any Arduino hardware itself.

To download the Arduino IDE go to: https://www.arduino.cc/en/Main/Software

Start up the Arduino IDE and select the Boards Manager

Step 9: Setup the ESP2866 Board Manager

Start the Arduino IDE and select the Boards Manager under Tools / Board ..

Step 10: Install the ESP2866 Board Manager

Find the esp8266, select it and click Install.

Step 11: Arduino Preference Setup

Go to File / Preferences

Step 12: Boards Manager URL's

In the Additional Boards Manager URLs field enter the URL for the ESP8266 package which is:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Step 13: ESP8266 Setup in IDE

Select the “Generic ESP8266 Module” and go back to the Boards Manager again

Step 14: ESP8266 Options

Setup you ESP-01 options. Select the appropriate COM port according to your PC.

Step 15: Talking to ESP8266

If you still have the original firmware on your ESP8266 you can try talking to it with the Serial Monitor.

  1. Open the Arduino Serial Monitor:
  2. Select the appropriate baud rate which is usually 115200 but could be anything down to 9600 depending on the firmware on the ESP.
  3. Also select “Both NL & CR”. Ie: New Line and Carriage Return characters after each “Send”.
  4. Type AT and press enter. The ESP should come back with OK. If not press the RESET button or try unplugging the USB cable and starting again. Make sure also that you have the right COM port selected. Also if you don’t have the “standard” firmware on your ESP it may not understand the AT command set. This is not necessarily a problem yet as you’ll be overwriting this with Arduino code later in this instructable.
  5. Type AT+GMR. This should come back with the version numbers of the firmware on your ESP. In another instructable I show you how you can restore the latest version of the “factory” firmware (if you want to).

Step 16: ESP8266 Arduino Code

Download code file (ESP8266_LED_Control.zip), unzip it and open it in the Arduino IDE.

Change the Router setting to yours. ie: change the SSID and PASSWORD fields.

Make sure your breadboard is setup correctly, and connect your USB cable to the Serial Programmer.

NB: When addressing the GPIO Pins in your code you should use the GPIO number. eg: 2 for GPIO 2 and not the physical pin number which will be different.

Step 17: Uploading Your Code to the ESP8266

Make sure you’ve closed ALL Serial port monitors on the same port, if you you’re using them. Eg: tools like CoolTerm. Open the Arduino Serial Monitor again, as you will need to see the IP address of the ESP after it loads.

NB: To upload your code you must have GPIO 0 grounded. You can leave it there whilst running your code in the browser. Press the RESET button before each load. If the upload fails, check your settings and try disconnecting and reconnecting the USB cable. Try Ctrl&U a couple of times. If all else fails try rebooting your PC. Sometimes the COM ports get a bit messed up.

The blue LED on the ESP should flash if the code is being uploaded successfully. The progress of the upload should look like the images above.

NB: If you want to remove the Serial programmer and run the ESP on its own, make sure you disconnect GPIO 0 from ground and push the RESET button otherwise the ESP may not work properly.

If your ESP8266 uploads are behaving erratically, improve your power supply.


Step 18: Let See What It's Doing

Switch over to the Arduino Serial Monitor and you should see the IP Address of the ESP. You could also log into your Router and check what’s connected there. The device will show up in the list of connected IP’s with a name like: ESP_1A6C4A.

Whilst you are in your router you could always reserve the ESP's IP address and set up some Port Forwarding so that you can connect to the ESP from outside your network - like the office..

You should see something like the above. Use that IP address in your browser.

Step 19: Let's Try It Out

After clicking on a few links you’ll hopefully see the LED going on and off!

You also see that it can do PWM and dim the LED.

The ESP8266 can also handle Interrupts on the digital pins and also has analog input. The analog input pin though is not exposed on the ESP-01,

Internet Explorer works fine but for some reason FireFox seems very slow with the ESP. This may have something to do with the setup of the HTTP header.

Note: that after uploading your own code, your ESP8266 won't respond to AT commands any more. Your code has replaced the firmware. Using your code and the ESP8266 library in the Arduino IDE you'll have access to a richer set of commands. See the documentation here: https://www.arduino.cc/en/Reference/WiFi.

You can restore the firmware on the ESP8266 to go back to AT commands if you wish. See my other instructable: The Simple Guide to Flashing Your ESP8266 Firmware.

Step 20: ESP Resources

"Kolban’s Book on ESP8266" updated in November 2016 is for serious enthusiasts.

It is 470+ pages long and has an incredible amount of detail. You can get it for free but make a donation if you can.

https://leanpub.com/ESP8266_ESP32

He has now separated out the ESP32 and published a new book:

https://leanpub.com/kolban-ESP32

ESP32

"Like the ESP8266, the ESP32 is a WiFi compatible microcontroller, plus it adds support for Bluetooth low-energy (i.e BLE, BT4.0, Bluetooth Smart), and nearly 30 I/O pins."

See: https://www.sparkfun.com/products/13907

ESP Sites

http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family

http://www.esp8266.com/

https://iotbytes.wordpress.com/esp8266-pinouts/

http://espressif.com/en/products/hardware/esp8266ex/resources


AT Commands

https://www.itead.cc/wiki/ESP8266_Serial_WIFI_Module#AT_Commands

https://espressif.com/sites/default/files/documentation/4a-esp8266_at_instruction_set_en.pdf


Arduino Boards Manager

http://randomnerdtutorials.com/how-to-install-esp8266-board-arduino-ide/

https://github.com/esp8266/Arduino


Notes on Flashing the Firmware:

I have published an instructable showing you how to flash the factory firmware onto your ESP8266.

See: https://www.instructables.com/id/The-Simple-Guide-to-Flashing-Your-ESP8266-Firmware/

<p>Hello Tones - trying to upload your code to my ESP-01. Not sure of the firmware version. Does this matter? Below is the error message....</p><p>Error Message</p><p>Arduino: 1.8.1 (Windows 10), Board: &quot;Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 1M (512K SPIFFS), ck, Disabled, None&quot;</p><p>Sketch uses 232249 bytes (46%) of program storage space. Maximum is 499696 bytes.</p><p>Global variables use 33264 bytes (40%) of dynamic memory, leaving 48656 bytes for local variables. Maximum is 81920 bytes.</p><p>Uploading 236400 bytes from C:\Users\DJC-LI~1\AppData\Local\Temp\arduino_build_962768/ESP8266_Led_Control_PWM.ino.bin to flash at 0x00000000</p><p>................................................................................ [ 34% ]</p><p>................................................................................ [ 69% ]</p><p>......................................................................warning: espcomm_send_command: didn't receive command response</p><p>warning: espcomm_send_command(FLASH_DOWNLOAD_DATA) failed</p><p>warning: espcomm_send_command: wrong direction/command: 0x01 0x03, expected 0x01 0x04</p><p>error: espcomm_upload_mem failed</p><p>error: espcomm_upload_mem failed</p><p>This report would have more information with</p><p>&quot;Show verbose output during compilation&quot;</p><p>option enabled in File -&gt; Preferences.</p><p>-----------</p><p>Was able to get it to load once... and the Arduino IDE Monitor show this... keeps repeating...</p><p> ets Jan 8 2013,rst cause:4, boot mode:(3,7)</p><p>wdt reset</p><p>load 0x4010f000, len 1384, room 16</p><p>tail 8</p><p>chksum 0x2d</p><p>csum 0x2d</p><p>v09f0c112</p><p>~ld</p><p>------ End -----</p><p>Thanks for taking a look, not sure what is going on - Dan</p>
<p>Hi Dan</p><p>It looks like a power supply <br>issue. Whenever the ESP8266 behaves erratically it's usually because <br>your power supply is not sufficient. To be on the safe side, whilst <br>prototyping, use a power supply that can provide at least 1A. Keep the <br>leads short and also put a 10uF and a .1uF capacitor across the + and - <br>to smooth it. </p><p>Otherwise, the upload is starting which shows that <br>everything else seems to be configured ok. On the firmware: any code <br>that you upload to the ESP8266 becomes the new firmware, so versioning <br>is not an issue. (Except in the unlikely event that you've bricked the <br>ESP8266 and it's a boot loader issue.)</p><p>So sort out the power supply and give it another go.</p>
<p>So-far, I've been finding the same problem.. Most projects seem to be wired for the device to be powered off whatever it's plugged into (USB&lt;--&gt;FTDI , Arduino, etc.) and the regulators on those devices are at best going to give you 250mA, not even scratching the requirements if they intend on using the WiFi in any way.. ) I kinda cheat... Most of my breadboard projects, I've powered off reclaimed ATX Supplies.. I have 2, where the 3.3V output is rated up as high as 28A!! (that's 28000mA!!!!).. Absolutely no Brown-out (power loss), but also playing with fire if there is a short or wired in reverse.</p><p>I usually wire the supply to a separate rail on the breadboard, and common-GND everything.. VCC from the USB-FTDI and +3.3V from the supply, are _NEVER_ connected together! I've also run into quite a few FTDI modules, where, despite the switch being set to 3.3V, the VCC is still punching +5V. (Deek-Robot's version, with the slide switch, as example.)</p>
<p>Thanks for this great instructable!</p><p>I tried hooking up my esp01s a few months ago with no success using various tutorials from the web, which all contradicted each other slightly.<br>This one was very clear and concise. Thank you for having all the required information in one place.</p>
<p>Hi nixrod, thanks for the feedback. I had exactly the same problem trying to get my esp01 going and that spurred me on to write this instructable.</p>
<p>Great instructable! Got me through the initial exposure to ESPs! (except I missed turning off GPIO 0 from GND when using AT commands...that took me quite some time to figure out :D Thanks for posting all this!!</p>
<p>Hi Michael, thanks for the feedback and well done on a good looking proto board!</p>
<p>Hi, thanks for the great instructable. It worked fine for me except I cannot get the led to dim. I am using an ESP-01 ESP8266, i.e. the one with 8 pins / 2 GPIOs 0 and &quot;. Should it work? Can you clarify what you said about analogue signals., please</p>
<p>Hi Scanos</p><p>I'm puzzled. The ESP-01 <br>definitely has PWM as that's what I used in the original build and it <br>does work. Does the LED turn fully on and off ok? Maybe try other PWM values. ie: change the 512 (which is half way) to a lower value?</p>
<p>Hi, I set the 512 to 128 and it worked. I also guess that I could have used a higher rated resistor. Thanks for that. I assume that I can use your program to read a voltage from a DSB1820 temperature sensor? </p>
<p>Here is my setup, thanks for the tutorial, was a lot of fun getting the flashing to work, nice work</p>
<p>Awesome, thanks for the feedback.</p>
<p>Tried doing this but it wont send back AT commands so i tried uploading the code anyways and it seemed to work but when it tries to connect and i watch it in serial monitor i get what i pasted below and nothing more</p><p>any thoughts?</p><p>Connecting to ASUS</p><p>..............................</p>
<p>Hi Smeem</p><p>So it looks like the upload works ok. </p><p>Double check the pin settings as per Step 5 to make sure the ESP8266 can now operate out of programming mode. ie: &quot;<u>GPIO 0</u> must be held low for programming. This should be removed <br>if you remove the FTDI and operate the ESP8266 on its own power supply.&quot;</p><p>Also double check that you have specified your WiFi SID and Password properly and that your WiFi will allow incoming connections. It could be a security/access issue on your WiFi Router?</p><p>Also as with most &quot;strange&quot; issues with the ESP8266 it is usually always that the power supply is insufficient. It can't run off the Arduino power supply. Make sure you have a separate power supply capable of at least 500mA or more. Also put some capacitors across the + and -, close to the ESP8266. eg: a 10uF and a 1nF in parallel. The big one to provide some spare capacity and the small one to minimise power pikes.</p><p>Let me know how it goes.</p>
<p>Silly me I dropped the ball majorly there, I forgot to disconnect GPIO0 from ground and run it after the reset. Thank you works well, wonderful tutorial</p>
<p>Brilliant, thanks Smeem.</p>
Odd it still seems to not want to take at commands though
<p>Hi Smeem</p><p>Thanks for the question as I realise this wasn't explicit in the Instructable. </p><p>I've updated it to add the following:</p><p>Note: that after uploading your own code, your ESP8266 won't respond <br>to AT commands any more. Your code has replaced the firmware. Using your<br> code and the ESP8266 library in the Arduino IDE you'll have access to a<br> richer set of commands. See the documentation here: <a href="https://www.arduino.cc/en/Reference/WiFi" rel="nofollow">https://www.arduino.cc/en/Reference/WiFi.</a></p><p>You can restore the firmware on the ESP8266 to go back to AT commands if you wish. See my other instructable: <a href="https://www.instructables.com/id/The-Simple-Guide-to-Flashing-Your-ESP8266-Firmware/" rel="nofollow">The Simple Guide to Flashing Your ESP8266 Firmware</a>.</p>
brilliant thank you ive already been working on some stuff but terrible with code thank you again for the instructable
<p>Thanks for the awesome tutorial! It worked perfectly.</p>
<p>Hi Lionel</p><p>Thanks for the feedback. Much appreciated!</p><p>ps: I've started using the Wemos D1 Mini - it has the ESP-12 variant on it with lots more pins. It also has a USB connection - which makes it's a whole lot easier to use!</p>
<p>Can you plz look at this</p><p><a href="https://www.instructables.com/community/security-system-not-responding-after-combinin-ultr/" rel="nofollow">https://www.instructables.com/community/security-s...</a></p><p>small help thanks</p>
<p>Thank you very much! It's the first time when I programmed an ESP8266 (in fact NODEMCU 1.0). Be blessed!</p>
<p>It works only once after I have uploaded the code. I was able to get the output on my Browser.</p><p>But when I power it off and on again, i assume that my ESP will automatically run on the previous code. But it did not. I even tried resetting the ESP no use!!..</p><p>What could be the reason?</p><p>Please help me</p>
<p>Okay, I found this Myself. Once the programming is complete I have to remove the GPIO 2 that was connected to ground prvsly. </p><p>I have another doubt, right now I am able to opean the page only on devices that are connected to my router, How can I open it on other devices?</p>
<p>Hi,</p><p> Is the firmware supposed to reboot after a reset? I disconnected GPIO 0 and did a reset but it didn't reboot till I also disconnected GPIO 1 and then did another reset. Powering off then back on also required that both GPIO's be disconnected before I got a reboot of the firmware. Is there anyway around not having to disconnect GPIO 1 when resetting?</p>
<p>hi can someone tell me how to connect the 8266 to my win10 laptop i plug it in via usb,i get the sound its connected but then nothing ive tried finding driver links...</p><p>Nothing thay helps me connect the esp8266 to my windows 10.</p><p>problem is i bought 5 off these for is a smalla project,all i want the board to do is turn something on and off but need it to do that at a a min distance of 25mtrs.i got the idea from a drone i bought.that goes about 30mtrs and i control my drone with my iphone 6.</p><p>So i thought well if i can control my drone via mobile ,then surely i can turn something on and off</p><p>I asked about and was told that the esp8266 is what i needed,as its a transmitter but thats the thing i didnt think id have to programme anything i thought plug and play off i go,</p><p>Ive thought alnog the lines of this im a rc helicopter,drone specialist and flight instructor of RC items and build helicopters,planes race built high speed rc boats...so could i not take one of my digital transmitters and wire this to the esp8266 then download ardiuno or even a app like the one to my iphone i use to fly my drone with and then once connected i can then turn the sep8266 into a on and off switch... via mobile</p><p>Any light into this project of what i need if anything what software and any programme writing ill need to put on the esp8266 to make it work. </p><p>Any help at all as it would be good to read a few comments and learn all the exciting things i could make </p>
<p>dude i have this following error i'm using Arduino 1.6.11 will you able to solve this please..</p><p>C:\Users\Johnson\Downloads\ESP8266_LED_Control\ESP8266_LED_Control.ino:84:43: warning: multi-character character constant [-Wmultichar]</p><p> String request = client.readStringUntil('\r\n');</p><p> ^</p><p>ESP8266_LED_Control:28: error: 'WiFiServer' does not name a type</p><p> WiFiServer WebServer(80);</p><p> ^</p><p>ESP8266_LED_Control:30: error: 'WiFiClient' does not name a type</p><p> WiFiClient client;</p><p> ^</p><p>C:\Users\Johnson\Downloads\ESP8266_LED_Control\ESP8266_LED_Control.ino: In function 'void setup()':</p><p>ESP8266_LED_Control:46: error: 'WiFi' was not declared in this scope</p><p> WiFi.disconnect();</p><p> ^</p><p>ESP8266_LED_Control:47: error: 'WIFI_STA' was not declared in this scope</p><p> WiFi.mode(WIFI_STA);</p><p> ^</p><p>ESP8266_LED_Control:52: error: 'WL_CONNECTED' was not declared in this scope</p><p> while (WiFi.status() != WL_CONNECTED) {</p><p> ^</p><p>ESP8266_LED_Control:60: error: 'WebServer' was not declared in this scope</p><p> WebServer.begin();</p><p> ^</p><p>C:\Users\Johnson\Downloads\ESP8266_LED_Control\ESP8266_LED_Control.ino: In function 'void loop()':</p><p>ESP8266_LED_Control:72: error: 'client' was not declared in this scope</p><p> client = WebServer.available();</p><p> ^</p><p>ESP8266_LED_Control:72: error: 'WebServer' was not declared in this scope</p><p> client = WebServer.available();</p><p> ^</p><p>exit status 1</p><p>'WiFiServer' does not name a type</p>
<p>Hi Johnson<br>Did you setup the ESP8266 board manager in the Arduino IDE first?<br>ie: as per Step 9 onwards. ie: to install the ESP8266 board manager and setup the URL in preferences? It sounds like the correct ESP8266 libraries are not being found by the compiler.</p>
<p>ps: This could also be because of a simple syntax error in your code. Check all your { and } and ; to make sure that they are all nested properly.</p>
<p>This hard work really deserves a star, thanks for sharing.</p>
<p>Hi pvtryan - thanks for your feedback it's much appreciated</p>
<p>nice!!! thanks for posting...</p>
<p>Thanks Joe, for reading and taking the time to comment.</p>
<p>you're welcome...</p>
<p>In your excellent description you state:</p><p><em>&quot;Switch over to the Arduino Serial Monitor and you should see the <u>IP Address</u><br> of the ESP. You could also log into your Router and check what&rsquo;s <br>connected there. The device will show up in the list of connected IP&rsquo;s <br>with a name like: ESP_1A6C4A. </em></p><p><em>Whilst you are in your router you <br>could always reserve the ESP's IP address and set up some Port <br>Forwarding so that you can connect to the ESP from outside your network -<br> like the office..&quot;</em></p><p>MY QUESTIONS ARE:</p><p>1) is it possible to specify &amp; lock in an internal IP address that will be available on the Router e.g 192.168.1.150 or is this just randomly allocated by the router? Maybe this is something in the Router I've not yet discovered ??</p><p>2) Have you been able to successfully set up Port Forwarding to the ESP. I've been able to do this OK with my TP-Link router to a Uno which is fitted with a Ethernet card connected that then use DuckDNS to give me a virtual permanent external IP from the outside world. Obviously this relates to my 1st question above where I want to have a permanent internal IP address which I can Port Forward to. </p>
<p>Hi rbright</p><p>1. Yes, you should be able to reserve any IP address in your router for any connected device. Normally in one of the screens you'll see the IP and MAC addresses of all connected devices and there will usually be a &quot;Reserve&quot; button (or equivalent) that you can click for any specific device to setup the IP address you want to reserve.</p><p>2. Yes, this should work for you too. If you go to the website WhatIsMyIP.com you will see your external IP address, and this is what you need. You are right that some Service Providers will change your external IP address from time to time. In which case you will need to use a Dynamic DNS Service something along the lines you mention or DynDNS.org etc. Either way your router should be able to support this. Using Port Forwarding or Virtual Server settings in your router you should be able to map an external IP address and Port number to an internal IP address and Port number. For example: rbright.dyndns.org:8080 to 192.168.1.150:80 (your device), or an external IP of say 196.1.2.3:80 to 192.168.1.150:80. The internal IP address eg: 192.168.1.150 or whatever you've chosen for your device will be static if you've reserved it in your router.</p><p>I hope that helps?</p>
<p>I am using an ESP8266 12F with a relay connected to GPIO4. To adjust this code, do I simply change </p><p>int pinGPIO2= 2; //To control LED</p><p>to</p><p>int pinGPIO4 = 19; //To control LED</p><p>I can't seem to get the relay to trigger...</p>
<p>Hi mrinstructablesman</p><p>One thing to be aware of is that the Arduino IDE Code uses different Pin numbers to the Physical Pinouts on the board. I haven't used the 12-F but I would say you need to use Pin 4 and not pin 19 in your code for GPIO4.</p><p>Also are you driving your relay with a Transistor and Fly Back diode?</p>
<p>Hi TonesB,</p><p>very great Instructable, like you are saying all the information is somewhere on the net and you you just make a so simple but so complet step by step tutorial. You should have a price for this one and the other one for flashing back the factory code. I had difficulty to start but with your guide now I can progress with the ESP, thank you.</p><p>If I can, I will like to had a comment for the Dummies like me, at STEP 15 you need to remove the GPIO 0 from ground(because you wired it as per the drawing in step 4 and 5) other wise you will stay in boot mode and the communication will not respond. Every time you are changing the configuration you need to reset the power so the new configuration is read by the ESP. Those two point look very basic when you have some experience but for Dummies like me you can save one evening.</p><p>Keep your good work</p>
<p>Hi moustick</p><p>Thanks for your feedback, much appreciated. On the GPIO 0: I had no problems leaving it grounded. I do mention though that if you disconnect the Programmer you must remove GPIO 0 from ground and press the Reset button to reboot the ESP.</p>
<p>Hi! Nice instructable! Regarding a stand alone operation, what kind of battery do you recommend? Is the Li-Ion max voltage too high for this module? I have plenty of spare cell phone Li-Ion batteries and it would be nice to be able to power my projects with them. Thanks!</p>
<p>Hi ereynoso</p><p>Thanks for your feedback!<br> The ESP8266 datasheet says it can take a maximum input voltage of 3.6V.<br> A 3.7V Li-Ion battery after charging can be about 4.2V and this would <br>definitely be too high. So you would need a 3.3V voltage regulator in <br>your circuit. The ESP8266 can also draw quite a bit of current when <br>transmitting. The datasheet shows that this can be over 200mA and some <br>people say a lot more. </p><p>So bottom line: yes you can use Li-Ion batteries with a 3.3V regulator and if they have sufficient mAh for your application.</p>
<p>Excellent Instructable, thank you for creating/posting it!</p>
<p>Hi domiflichi</p><p>Thanks for your feedback! Much appreciated.</p>
<p>Excellent summary of the current 'state of play' with ESP8266. I may be biased but I expect the Arduino IDE to take over from using NodeMCU although the arduino is not as memory efficient but then the ESP mas memory to spare and speed +.</p><p>Specifically the Arduino<br>IDE is intended to be used with genuine Arduino boards BUT with ESPs there is a<br>lot of other &lsquo;interperating&rsquo; of code required as follows with EPSs but then<br>they have faster processor and stacks of memory to spare.</p><p>For the comparison I loaded<br>my basic modified version of BLINK into each as follows &amp; you can see the additional memory requirements over a UNO when loading the same program using either a ESP-01 / ESP-12E :</p><br> <br> <strong>BOARD</strong><br> <strong>Memory Used </strong><br> <strong>Total Avail Memory</strong><br> <br> <br> UNO<br> 2450 Bytes<br> 32K<br> <br> <br> ESP-01<br> 221K<br> 434KB<br> <br> <br> ESP-12E<br> 221K<br> 1044KB<br> <br>
<p>Hi rbright</p><p>Thanks for the feedback and the info! I agree. The ESP has loads of memory and speed, so for most applications one doesn't need to worry. The purists may want to get down to fully optimised code but in the big scheme of things this would be a waste of time.</p>
<p>There's a long discussion somewhere else, hackaday I think, where <br>someone fairly official like the CEO of Espressif Systems publicly <br>stated that the GPIO/UART pins on the ESP8266 ARE 5V tolerant. Someone <br>else did some further tests, at many voltages, measuring current and <br>similarly concluded that you OUGHT to be OK.</p><p>As long as your SUPPLY doesn't go above about 3.3V, you are theoretically OK putting 5V signals on TX/RX.</p><p>THEORETICALLY. Note that I am NOT going to pay for your fried ESPs :-p</p><p>My personal advice:<br>A<br> 3.3V OUTPUT should go OK into a 5V INPUT and still be seen as fairy <br>reliably logic 0/1, so ESP TX --&gt; 5V programmer RX, just wire it <br>fine. 3.3V is above &quot;about 2.5V&quot; so is still considered a &quot;high&quot;.</p><p>A<br> 5V output into a 3.3V input would USUALLY be a bad idea (ignoring my <br>first paragraph) but 5V/2 = 2.5V, comfortably below 3.3V but also <br>comfortably above the 1.7V(ish) that ought to be considered &quot;high&quot;, so <br>build yourself a simple voltage divider with 2 identical resistors, say,<br> 5k [here's hoping instructables doesn't eat my ASCII art]:<br></p><p>GND ---[R]--- ESP RX ---[R]--- Programmer TX<br></p><p>You<br> could do even better by working out the &quot;correct&quot; ratio of 2 DIFFERENT <br>resistors, or something even more cunning with a resistor and a zenner -<br> these are left as an exercise for the reader ;-)</p>
<p>Hi NoseyNick</p><p>I think you're right. The ESP8266 is a lot more resilient than people think. At one stage I connected it up wrong. It got quite warm and I was convinced I'd fried it. It still came back to life though. The important thing is to give it a good 3.3V supply - with sufficient current - otherwise it could be unreliable. The 3.3V from a Programmer or an Arduino doesn't seem to be enough.</p>
<p>Your comment that &quot;there is only one ESP8266 processor but it is found on many different breakout boards&quot; is incorrect. There are seventeen at this point in time. Please read this article for the entire list:</p><p><a href="https://en.wikipedia.org/wiki/ESP8266">https://en.wikipedia.org/wiki/ESP8266</a></p>

About This Instructable

68,100views

636favorites

License:

Bio: I've been in IT and Software Development forever! My real passion though is where Software and Industrial Design meet. Especially micro-controller based gadgets and ... More »
More by TonesB:Appliance Monitor The Simple Guide to Flashing Your ESP8266 Firmware ESP8266 WiFi Module for Dummies 
Add instructable to: