close-circle
Close
0%
0%

Arduino IDE for ESP8266 Quickstart Guide

Thanks to the hardwork by Richard Sloan and Ivan Grokhotkov, we can now use Arduino IDE to write sketches that would run ON the ESP8266.

Similar projects worth following
close
UPDATE May 25, 2015:
Great news!
Arduino IDE for ESP no longer requires a special build of the IDE.
To use Arduino IDE 1.6.4 or later with the ESP, follow the instructions on GitHub:
https://github.com/esp8266/arduino

The most up-to-date information on how to use the Arduino IDE for ESP is at:

https://github.com/esp8266/arduino#installing-with-boards-manager

Once you've setup ESP via board manager, choose it from the board menu:

Once you've chosen the correct ESP board, Arduino IDE will show ESP specific examples!

This blink will blink the built-in LED on the ESP.

If you wired up your ESP like diagrammed below, modify the IO pins in Blink (three places) from LED_BUILT_IN to 2.


The resistor values are as follows:

  • LED current limiting resistor = 1K
  • Pushbutton switch pullup resistor = 1K
  • Voltage divider resistors = 1K (top), 1.8K (bottom)
    You can connect FTDI TX to ESP RX directly if you have a 3.3V FTDI.

Compile and upload the sketch by pressing Control-U or clicking the Upload button.

If there are no compile errors, the IDE will display Uploading... and wait for you to put the ESP in bootloader mode.

To do that:

  1. Turn off the ESP.
  2. Bring GPIO0 to ground (if you use the above circuit, press AND HOLD DOWN the pushbutton).
  3. Turn on the ESP.
  4. You can release the pushbutton as soon as Arduino IDE starts uploading.

The ESP will automatically run the sketch as soon as the upload is completed.

This is exciting!

NOTE:

This Arduino IDE completely replaces the firmware on the ESP each time you upload, so if you want to use the ESP with NodeMCU or AT commands, you will need to reflash the ESP with the desired firmware.


Want to see it in action? Check out this Video.
How do I make the ESP-01 breadboard compatible? Check out this video.

View project log

Enjoy this project?

Share

Discussions

billwhit1 wrote 08/24/2016 at 22:33 point

Yes I'm new to the Rasb and Ardino and want to get off on the right foot. I'm a converted apple user. I worked with PC much earlier. Like Ohio Scientific  and lot's of MF prog, languages. IBM 360/370 assembly language. 

Which is better to use with OS X (iMac) Raspberry or Ardino. Which is more expensive ?  I've got a handle on *.? and in early apple 2 using CPM. I sure would like to find my floppy with CPM on it.

billwhit1@comcast.net

  Are you sure? yes | no

Hari Wiguna wrote 08/24/2016 at 22:53 point

Hi Bill,
Raspberry Pi is a full computer.  You only need another computer (mac or PC) to write the SD card that the Pi uses as its Harddrive.  After that you can use IT as a computer that just happens to have I/O pins.

The Arduino is a micro controller.  Not a full blown computer. You will need a PC or Mac.  They're both equally supported since the Arduino environment is written in Java.

Arduino is cheaper than the Pi, but that is to be expected.  The Pi is faster and can do more, but the Arduino is better at real-time processing and can handle I/O better.


It depends on what you want to do.  They are both excellent computers.

  Are you sure? yes | no

Dhanvinder Singh wrote 06/08/2016 at 20:30 point

hello this is the problem i am having now when i put in the link provided below in preferences

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

error downloading https://adafruit.github.io/arduino-board-index/boards/adafruit-1.3.2.tar.bz2 in the board manager when i trying to select Adafruit AVR Boards by  Adafruit

  Are you sure? yes | no

Dhanvinder Singh wrote 06/08/2016 at 15:14 point

we are trying to build a project and everytime we run it shows the following error.

Cannot run program "{runtime.tools.xtensa-lx106-elf-gcc.path}\bin\xtensa-lx106-elf-g++" (in directory "."): CreateProcess error=2, The system cannot find the file specified

could someone please assist. Thank you.

  Are you sure? yes | no

Nick Abbot wrote 06/07/2016 at 13:25 point

We are trying to build this project and having difficulty setting up the IDE.

The error we're getting is: exec: "/bin/xtensa-lx106-elf-g++": file does not exist

What is this file and where should it be?

Edit:

Here is the verbose log.

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\nabbot\Documents\Arduino\libraries" -fqbn=Arduino:avr:generic:CpuFrequency=80,FlashFreq=40,FlashMode=dio,UploadSpeed=115200,FlashSize=512K64,ResetMethod=ck,Debug=Disabled,DebugLevel=None____ -ide-version=10609 -build-path "C:\Users\nabbot\AppData\Local\Temp\buildbdc8da3f94e115e2149e9b25d6db80e1.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\DHTServer\DHTServer.ino"

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\nabbot\Documents\Arduino\libraries" -fqbn=Arduino:avr:generic:CpuFrequency=80,FlashFreq=40,FlashMode=dio,UploadSpeed=115200,FlashSize=512K64,ResetMethod=ck,Debug=Disabled,DebugLevel=None____ -ide-version=10609 -build-path "C:\Users\nabbot\AppData\Local\Temp\buildbdc8da3f94e115e2149e9b25d6db80e1.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\DHTServer\DHTServer.ino"

"/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr/tools/sdk/include" "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr/tools/sdk/lwip/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L    -DARDUINO=10609 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_AVR  -DESP8266 "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr\cores\esp8266" "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr\variants\generic" "C:\Users\nabbot\AppData\Local\Temp\buildbdc8da3f94e115e2149e9b25d6db80e1.tmp\sketch\DHTServer.ino.cpp" -o "nul"

"/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr/tools/sdk/include" "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr/tools/sdk/lwip/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L    -DARDUINO=10609 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_AVR  -DESP8266 "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr\cores\esp8266" "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr\variants\generic" "C:\Users\nabbot\AppData\Local\Temp\buildbdc8da3f94e115e2149e9b25d6db80e1.tmp\sketch\DHTServer.ino.cpp" -o "nul"

"/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr/tools/sdk/include" "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr/tools/sdk/lwip/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L    -DARDUINO=10609 -DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_AVR  -DESP8266 "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr\cores\esp8266" "-IC:\Program Files (x86)\Arduino\hardware\Arduino\avr\variants\generic" "C:\Users\nabbot\AppData\Local\Temp\buildbdc8da3f94e115e2149e9b25d6db80e1.tmp\sketch\DHTServer.ino.cpp" -o "C:\Users\nabbot\AppData\Local\Temp\buildbdc8da3f94e115e2149e9b25d6db80e1.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"

exec: "/bin/xtensa-lx106-elf-g++": file does not exist
Error compiling for board Generic ESP8266 Module.

  Are you sure? yes | no

Hari Wiguna wrote 06/08/2016 at 04:02 point

Hmm, I don't know what those errors meant.
Are you sure you start with these instructions?

https://github.com/esp8266/arduino#installing-with-boards-manager
That is the most up to date instructions.  You no longer need a special build.  It's now handled by the board manager.
I put an update at the beginning of this page, but maybe I need to remove the obsolete information.  I apologize for the confusion.

  Are you sure? yes | no

Ansh Shah wrote 02/20/2016 at 03:10 point

what to do to use esp8266's gpio0

  Are you sure? yes | no

Hari Wiguna wrote 02/20/2016 at 04:06 point

To program the ESP, GPIO0 must be low upon power up or restart.

Afterwards, during normal operation, yYou need to make sure that it is pulled up upon power up.  

Other than that you're free to use GPIO 0 like other pins.

  Are you sure? yes | no

arangates wrote 02/09/2016 at 03:17 point

can we program esp-01 without FTDI programmer ... using arduino alone?!

  Are you sure? yes | no

Hari Wiguna wrote 02/09/2016 at 04:16 point

I've never tried it, but I've seen two tricks that others have came up with to use the Arduino as an FTDI (usb to serial):

1. remove the ATMega chip (only possible with older Arduinos)

2. connect the reset pin so the Arduino is in reset state and would ignore the serial data meant for the ESP.

However, why tie up an Arduino when you can get a dedicated (and reusable) [USB to serial module for less than $2](http://www.aliexpress.com/item/Free-shipping-1pcs-FT232RL-FTDI-USB-3-3V-5-5V-to-TTL-Serial-Adapter-Module-for/32256920717.html?spm=2114.01010208.3.11.DKEGwO&ws_ab_test=searchweb201556_6,searchweb201644_5_505_506_503_504_301_502_10014_10001_10002_10016_1001...)?

  Are you sure? yes | no

arangates wrote 02/09/2016 at 04:20 point

cool ... I'll try !!! 

  Are you sure? yes | no

bitluni wrote 09/28/2015 at 08:40 point

Nice work!
If you need more GPIO pins check out my basic tutorial how to use the ESP-07 or ESP-12:

  Are you sure? yes | no

otto wrote 06/22/2015 at 21:33 point

Hi Hari, that looks like a really cool project! 

For my project I really need the ability to debug - I have a continuous stream of data coming from the sensor that I need to separate and then manipulate, and I need to know what the ESP is doing at the same time.  I now have it running on an Uno, and so far it's looking good - the ESP seems to be behaving well, but where it falls over is in uploading the data to ThingSpeak :-)  - I keep getting Error 400 Bad Request..  I am using the hardware serial for debug, the ESP  and the sensor are on two separate softwareserial ports. 

Man, this is so frustrating!  I feel I am so close....

I am hoping to eventually just run the code on the ESP and not even bother with the Arduino, but not being able to implement a softwareserial port on the ESP throws a bit of a spanner in the works!

  Are you sure? yes | no

otto wrote 06/22/2015 at 06:53 point

I have a small project that requires me to connect a serial sensor to the ESP8266.  Softwareserial is not an option (apparently), and the serial.swap() function does not seem to work very well.  Does anybody have any ideas??

  Are you sure? yes | no

Hari Wiguna wrote 06/22/2015 at 08:19 point

Otto, If you're willing to give up the ability to print debug statements back to the serial monitor, you can put a switch and swap the serial connection between the PC (for uploading sketch) and your serial device (when your sketch is running).  That's what I did to connect this serial LCD to the ESP.

  Are you sure? yes | no

Martin Kurnadi wrote 05/29/2015 at 22:59 point

Hi Hari. Thanks for Sharing, Your name really sounds Indonesian, do you still speak Bahasa ?  I used to live in Iowa and now back in Bandung. We have ESP8266 community here in Bandung and currently using your LuaUploader program. 

  Are you sure? yes | no

Hari Wiguna wrote 05/29/2015 at 23:16 point

Halo Martin! Yes, I was born in Indonesia. However, I have lived in the US most of my life.  I probably speak English with an Indonesia accent and speak Bahasa with an American accent. lol.

Glad that you're using LuaUploader.  Just be aware that there are other alternative editors and of course, now with Arduino IDE for ESP, there's not even any need to learn LUA. :-)  Tell me more about the ESP community in Bandung!

  Are you sure? yes | no

Martin Kurnadi wrote 05/30/2015 at 01:16 point

This is Awesome, I got replied from the LuaUploader creator really fast :) I used to live in the US for 11 years, now I speak English with Sundanese accent lol. Well, our community is for IoT hardware in general, but mostly Arduino and ESP8266. I am glad that ESP also can connect people from Indonesia to Lincoln. We are currently working together to make low cost sensor board based on ESP8266 that can make social impact in Indonesia. We start with making an opensource Rain Sensor Board (cost < Rp 100.000 ~ roughly $9.00). Low cost so that students / hobbyist can start learning ESP and IOT. The information will be stored in any cloud, but in this case it is stored in Geeknesia IoT Platform. Well if you use any Video Conference Tool. I would like to invite you to see our community meetup real time :) We are meeting every week, and I am about to leave to the meetup  (Friday 11:00PM  EST). If you are still online I can show you :) lol

  Are you sure? yes | no

gauravgpta wrote 05/05/2015 at 21:27 point

Does this support PWM(analog.write) on GPIO Pins?

 It doesnt seem to be working. However digitalwrite is working fine? Could I be missing something?

  Are you sure? yes | no

Hari Wiguna wrote 05/05/2015 at 22:10 point

I have not tried it myself. However, documentation claims that it should work:  "analogWrite(pin, value) enables software PWM on the given pin. PWM may be used on pins 0 to 15. Call analogWrite(pin, 0) to disable PWM on the pin."

  Are you sure? yes | no

davedarko wrote 05/05/2015 at 22:18 point

It's at least possible to have PWM on the pins of an ESP8266 - as you can see here at #┬ÁBob biped robot 

  Are you sure? yes | no

gauravgpta wrote 05/05/2015 at 22:53 point

I am using ESP 01 and its GPIO2.

  Are you sure? yes | no

Anand Dhuru wrote 04/11/2015 at 16:31 point

Absolutely fascinating development; but, however much I try cant get the sketch to compile; keep getting an error 

"Cannot run program "C:\Program Files\Arduino/hardware/tools/esp8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-g++": CreateProcess error=2, The system cannot find the file specified"

Is this because my system is running on Windows 7, 32 bit? Trying to find a solution, I ended up with a distinct impression that this works only with a 64 bit machine?

  Are you sure? yes | no

Hari Wiguna wrote 04/11/2015 at 21:43 point

Anand, you might be right about the build being a 64 bit build.  I am running on windows 7, 64 bit. Another kinda odd thing is how the path contains forward slashes.

  Are you sure? yes | no

Ryan wrote 04/15/2015 at 01:55 point

Make sure your downloading "arduino-1.6.1-p1" from the main page. I downloaded the "arduino-1.6.1" (no p1) from the releases page and had the same error.

  Are you sure? yes | no

Anand Dhuru wrote 04/15/2015 at 05:45 point

Thank you so much! After trying out LOTS of solutions, this worked flawlessly.

Still, happily on my Windows 32 bit machine, incidentally.

Which leads me to the next question; how do I upgrade to Arduino 1.6.3 and still retain the ESP support?

Allso, another question. This zip did not seem to install anything, it just seems to run like a portable app. Is that how its supposed to be?

  Are you sure? yes | no

RoGeorge wrote 04/07/2015 at 07:22 point

WOW, this is great, thank you very much!

  Are you sure? yes | no

ch.dugasduvillard wrote 04/07/2015 at 06:18 point

Amazing!!! I really have to buy an ESP and build my first project !!!
I suppose it's working with ESP12 module.

I really have to get one at least :)

  Are you sure? yes | no

Hari Wiguna wrote 04/07/2015 at 06:28 point

It works fine on the ESP-01 (albeit, only two GPIO ports). I've ran Blink and the sample ESP WebServer.  I remember how excited I was when I first saw the Arduino blink.  I relived that moment when controlled an LED on the ESP from a web browser after changing two lines (Access point credentials) on the sample sketch. Amazing!

  Are you sure? yes | no

Hari Wiguna wrote 04/07/2015 at 05:45 point

I know... I was waiting to play with this IDE until I got my video editing done on my NodeJS + NodeMCU on the ESP8266 Youtube videos, but I finally could not wait any longer and had to try this new Arduino IDE for the ESP.  It is crazy simple!

  Are you sure? yes | no

davedarko wrote 04/07/2015 at 05:41 point

Awesome, I really have to start working with those - I have five of them waiting for me to do something.

  Are you sure? yes | no

davedarko wrote 04/28/2015 at 21:47 point

I've just downloaded the linux version to try it on a virtual machine, since the Mac OS stuff didn't work. It wanted Java7 but I'm still running 10.8.5 (I just have not found the time to update :D) - on linux I ran into another problem:

"OpenJDK Client VM warning: You have loaded library /home/esp8266/arduino-1.6.1/lib/libastylej.so which might have disabled stack guard. The VM will try to fix the stack guard now.

It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'."

I then ran:

sudo apt-get install libastylej-jni

and in the lib directory (cd lib)

sudo ln /usr/lib/jni/libastylej.so

And I was able to start the program. Yay. I thought I post it here, since this is the esp8266 arduino IDE project :) 

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates