Arduino Tutorial: ESP8266 OTA. Update the WeMOS D1 Over the Air (OTA).

Home/Arduino Projects/Arduino Tutorial: ESP8266 OTA. Update the WeMOS D1 Over the Air (OTA).

Arduino Tutorial: ESP8266 OTA. Update the WeMOS D1 Over the Air (OTA).

In this video we are going to see how to wirelessly update the code of our Arduino project, using the WeMOS D1 ESP8266 based board. We are going to perform an update to the ESP8266 OTA. This is an impressive, and very useful feature. If you want to see how to update your ESP8266 board over the air, keep reading.

A few weeks ago, we took a first look at the very promising new board, the WeMos D1. You can watch that video by clicking in the card here. The Wemos D1 is an ESP8266 based board which resembles the Arduino Uno board but it offers a lot more. Huge processing power, large memory and WiFi at a very low cost, less the 8$! You can find a link for the board in the description of the video.



1. WeMOS D1:

2. Powerbank :

3. Resistor:

4. Mini Breadboard:

5. Wires:

6. LED:



Among the other features one thing caught my eye recently! We can load programs to this board not only using the usb cable, but also wirelessly! We can update the ESP8266 OTA. Check this out: I have loaded the standard blink program to the board. The led turns on and off every second. I have now modified the Blink program to flash the LED quicker, every 200ms. I am now going to press upload and load the new program to the board wirelessly. The board is not attached to the computer, it is powered by this powerbank. We wait for a few seconds and as you can see, the new program is loaded. The LED flashes very fast! We managed to program the Wemos D1 board wirelessly! Cool, isn’t it? I think this feature is very useful as well. But now let’s see how to achieve that.

First of all we have to download and install Python 2.7 in our computer. Next we load the Arduino IDE. Please use the latest version of it. If you haven’t already set-up the Wemos Board in your Arduino IDE, please watch my previous tutorial in order to see how to do it. Next we load the BasicOTA program which is available Under File -> Examples -> ArduinoOTA. We then update the SSID and password inside the program so the board can join our WiFi network. Then we select our board and we upload the program to it using the Serial port and the usb cable. After that, we open the Serial monitor, and we can see that the board is connected to the WiFi network. Only if the module is connected to the network, after a couple of seconds, the esp8266-ota port will show up in the Arduino IDE. If the port does not show up, restart your Arduino IDE and it will appear. Now we can load any program to the board wirelessly if we set the port to the OTA port. I load the Blink program and I press upload. After a few seconds the program will be loaded to the board. That’s it! But what if we want to upload a new program to the board. We can’t do it any more since the BasicOTA program in not loaded anymore and the Arduino IDE can’t connect to the board wirelessly. In order to update the program over and over again wirelessly, we have to enter the commands from the BasicOTA program to our programs. So, I updated the blink program and it now uses the OTA commands. If we upload the program again to Arduino, we can now update it wirelessly as many times as we want, as the program will connect the WiFi network at startup.  That’s it! If you need to update your programs wirelessly from now on, just add a few lines of code to it and you are ready. You can find the code of the project in a link in the description of the video.

As you can see with some simple step we can enable the wireless update feature to our projects. Updating the ESP8266 OTA is so easy! Such functionality is extremely useful in case of limited or no physical access to the board. I am going to use this feature a lot in the feature. I can deploy a project to its final position and then update the code and add new functionality to it without touching the project at all. It will be very easy and practical. What do you think about this feature? Do you find it useful? Please post any comments or ideas in the comments section below. Thank you!









Never miss a video: Subscribe to



  1. Daniel May 14, 2016 at 4:21 am

    Hi Nick, I got a problem with this, every time I try to connect remotely or use the serial monitor Arduino software ask me for the board password, but I haven’t set any pass in the sketch. Please help!!

  2. Arvind Shenoy May 26, 2016 at 6:53 pm

    it says D10 was not declared in this scope. How do I proceed now. I have jutst copied and pasted your code and just modified the wifi details and it connect etc. But only this doesnt seem to work.

    • Arvind Shenoy May 26, 2016 at 6:54 pm

      Also, how is the Python thing being used in this ccode? I am not sure.

  3. jimmy June 16, 2016 at 8:24 pm

    i cant see the serialport olso after restart the ide
    help plz

  4. PRobert July 28, 2016 at 11:34 pm

    Dear Nick, as I had some trials & errors up getting the final result, that is, making the Wemos D1 R2 working in a good and controlled way, I would like to share my experience with those that follow your postings. As my first exercise, after loading the recommended libraries, I’ ve loaded (using the serial cable connected to the PC) your sketch named WiFiTest.ino (initially aimed to ESP8266 modules). After doing the proper changes for my environment, it worked without troubles.

    Then I’ve tried the OTA sketch. I spent some time trying to make it work, but, at last I did it. My main troubles were: (1) I had to uncomment some command lines referring to OTA; (2) This was my fault…I did’nt read the sketch password for OTA utilization: ==> “123”. After these blunders, at last I understood the whole thing. Python is used just to open an windows to provide the “123” password…

  5. Gavin August 7, 2016 at 12:58 am

    To Fix the D10 not declared issue


    #define D0 16
    #define D1 5 // I2C Bus SCL (clock)
    #define D2 4 // I2C Bus SDA (data)
    #define D3 0
    #define D4 2 // Same as “LED_BUILTIN”, but inverted logic
    #define D5 14 // SPI Bus SCK (clock)
    #define D6 12 // SPI Bus MISO
    #define D7 13 // SPI Bus MOSI
    #define D8 15 // SPI Bus SS (CS)
    #define D9 3 // RX0 (Serial console)
    #define D10 1 // TX0 (Serial console)

    void setup() {

  6. Markus Rohner October 3, 2016 at 6:03 am

    Cool video, thanks. I have a question though.
    While OTA is running on the D1 can I use Wifi to connect to other hosts or is the D1 wifi adapter waiting for a new program to be loaded?


  7. George September 7, 2017 at 3:53 pm

    i always get that one:

    warning: espcomm_sync failed
    error: espcomm_open failed
    error: espcomm_upload_mem failed
    error: espcomm_upload_mem failed

Comments are closed.