Tech Note 025 - ESP8266 OTA Sketch Updating

แชร์
ฝัง

ความคิดเห็น • 81

  • @paveld2593
    @paveld2593 7 ปีที่แล้ว

    Great video, through this video, I finally understood how to modify my project to the OTA Sketch Updating.

  • @craigrosier523
    @craigrosier523 6 ปีที่แล้ว

    One thing I should say, after trying more than 10 other solutions to OTA. This is easily the most elegant, simple and understandable, as well as the most compact routine / code that I have come across to date. Thank you for the clarity of the video.

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว

      It's pleasure, good to hear you have it running OK.

  • @zingo1010
    @zingo1010 6 ปีที่แล้ว

    Very good. Worked like a charm. Thanks a lot for putting this up

  • @boyeselectrical
    @boyeselectrical 6 ปีที่แล้ว

    awesome so much simpler than all the other videos i have tried thanks.

  • @G6EJD
    @G6EJD  7 ปีที่แล้ว +1

    To my surprise because it worked, I've just tried an OTA of a webserver that uses 192.168.0.24 as it's base address, the same address used by the OTA process and it works flawlessly, so it serves out web pages and if I request an OTA that gets a response too and I can upload a new version. I did not expect that to happen, so OTA gets even better.

  • @ka-ce
    @ka-ce 7 ปีที่แล้ว

    Litlle long but best explained!
    Thanks

    • @G6EJD
      @G6EJD  7 ปีที่แล้ว +1

      The audience is wide and varied from beginner to advanced, so I have to cover as much as possible for the beginner.

  • @craigrosier523
    @craigrosier523 6 ปีที่แล้ว

    G6EJD. Thank you for the prompt reply

  • @grizzbeeuno2242
    @grizzbeeuno2242 7 ปีที่แล้ว

    Thanks for the great video.
    Just a suggestion on another video using the WeMos D1 "PRO" compatibility with your various projects.

    • @G6EJD
      @G6EJD  7 ปีที่แล้ว +1

      +Grizzbee Uno Thank you. I do have the Wemos D1 Pro and apart from the extra memory (not RAM which is more important IMO) it compiles all the projects and works OK. One of the problems is integration with the IDE has not been completed and whilst there is a boards.txt file available it is more specialised for most people. Nonetheless I will try to use it more. Out of interest, using the 4M ESP8266, I have still not exceeded 35% usage of that device and I understand there is a limitation with the 16M version (Pro) in that the extra storage cannot be used by e.g. SPIFFS, so the product concept is good, but access to its full potential is limited.

  • @HaiTHaMKoBeIssI
    @HaiTHaMKoBeIssI 5 ปีที่แล้ว

    wooow, super easy , thank you.

  • @rodneytapit5636
    @rodneytapit5636 ปีที่แล้ว

    Just an additional note on this good tutorial. ArduinoOTA does not work when using timers or PWM. For anyone trying to do OTA updates with projects using timer interrupts the following code may save you a headache.
    // Disable timer1 ready for OTA firmware update
    // You can also disable timer0.
    void ICACHE_FLASH_ATTR hw_timer_disable(void)
    {
    ETS_FRC1_INTR_DISABLE();
    TM1_EDGE_INT_DISABLE();
    TIMER_REG_WRITE(FRC1_CTRL_ADDRESS, 0);
    }
    // OTA Callback, disable all PWM and stop all running timers
    ArduinoOTA.onStart([]()
    hw_timer_disable();
    analogWrite(LIGHT_PIN, 0); // stop PWM
    });
    // Set timer1 as interrupt timer example code
    timer1_isr_init();
    timer1_attachInterrupt(onTimerISR);
    timer1_enable(TIM_DIV16, TIM_EDGE, TIM_LOOP);
    timer1_write(clockCyclesPerMicrosecond() / 16 * 50000); // 50000uS = 20Hz = 50mS
    Ref: www.esp8266.com/viewtopic.php?p=34411

  • @nabarnes
    @nabarnes 7 ปีที่แล้ว

    Watched this through and couldn't work out why the blink was being uploaded OTA. It was only when I stepped through frame by frame and saw at 6:38 that the port was changed. Bit of a fundamental part of the process and it's shown in only a couple of frames for a fraction of a second.

    • @G6EJD
      @G6EJD  7 ปีที่แล้ว

      Hi Nicholas, well I do say at 6:06 that the loader sketch is being uploaded by the serial port and then at 06:44 just before the Blink sketch upload that the board is connected to the new network port at 192.168.0.24 so the OTA can take place. I tried to cover the fundamentals in the introductory section. It's worth reading the IDE guidance on OTA too as it explains the process, I hope this helps you understand. esp8266.github.io/Arduino/versions/2.0.0/doc/ota_updates/ota_updates.html

  • @cw_uk
    @cw_uk 7 ปีที่แล้ว

    thanks :)

  • @FrancisZerbib
    @FrancisZerbib 5 ปีที่แล้ว

    Excellent tutorial.
    Is it possible to lock the bootloader area to prevent any future mistaken programming to erase it?
    Thank you

    • @G6EJD
      @G6EJD  5 ปีที่แล้ว

      github.com/espressif/esptool/wiki/espefuse shows how to burn a fuze so that the device can no-longer be written to.

    • @FrancisZerbib
      @FrancisZerbib 5 ปีที่แล้ว

      Thank you for your prompt reply.
      I won't use it but good to know it exists. I expected something more "soft"

    • @G6EJD
      @G6EJD  5 ปีที่แล้ว

      The good thing is it’s relatively hard to download code from an ESP

  • @craigrosier523
    @craigrosier523 6 ปีที่แล้ว

    Just to be clear. It still works fine if I modify the sketch and upload OTA. This is merely for my own understanding.

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว

      That's the idea providing you switched over to the network port? and ideally run it remote from your PC, or disconnect the USB port.

  • @caroman6761
    @caroman6761 7 ปีที่แล้ว

    On my Installation of Python in my Win7X64 PC I got an interrupt:
    "There is a problem with this Windows Installer Package. A program required for this install to complete could not be run ..."
    Do you have any Idea, why?

    • @G6EJD
      @G6EJD  7 ปีที่แล้ว

      There's some documentation on Python installs, but what I would try is download the 2.7.13 package to your desktop, then when complete right-click it and run as administrator. Is your account an administrator. If you Google win 7 Python install problems there are many solutions offered, but each will depend on your particular PC setup. I would try overriding the privileges s first then try one of the other solutions. My system is win10 and it installs without any issues and my account is a system administrator.

  • @chuxxsss
    @chuxxsss 7 ปีที่แล้ว

    I added this to my sketch the first time it worked, but kept saying booting. Then I downgraded my Sketch Ardiuno IDE now it doesn't work. 1.6.5 I think is the verson. Thank you for doing this video as well. If I upgrade I best move my working Sketches. Other wise I lose them.

    • @G6EJD
      @G6EJD  7 ปีที่แล้ว +1

      Yes I agree, using the latest IDE is a challenge with older designs especially libraries that are not being maintained, so 1.6.5 is a good compromise. I'm using 1.8 and that works OK as does 1.6.12 or 1.6.13. glad you like the video my aim is to spread knowledge and help people.

  • @craigrosier523
    @craigrosier523 6 ปีที่แล้ว

    I am a little confused When you hit the upload of the BasicOTA (at 6.00 minutes) your screen appears to switch over to "esp8266_OTA_Bootloader" while my IDE just loads Basic OTA. Have you missed a step or have I installed your files incorrectly? I'm sorry that Newbies, like myself, are such a Pain in the A.

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว

      I'm showing that the initial upload has to be via the serial port, then I move over to the network port. I've done a later video for the ESP32 which is identical an identical process and code is about the same, perhaps have a watch of that.

  • @mikelemon5109
    @mikelemon5109 7 ปีที่แล้ว

    Had that OTA handling function been implamented into the ESP's boot loader already?

    • @G6EJD
      @G6EJD  7 ปีที่แล้ว

      Michael It was only included in IDE 1.6.5 and has since been deprecated in favour of a user added library approach as demonstrated here.

    • @mikelemon5109
      @mikelemon5109 7 ปีที่แล้ว

      Why not develop it further as this is the future of programming I already have a project where that this is a must. think about how useful that would be for robotics! if you know FIRST all the micro controllers there (Roborio) use OTA uploading since the robots are dynamic and it wouldn't be convenient to hook up a long cable to the robots there.

  • @sblantipodi
    @sblantipodi 5 ปีที่แล้ว

    Is it possible to read the serial.print() if the esp is not connected to the pc? I use ota because esp devices are far from my pc, is there a way to read the serial print even without a connection to the pc?

    • @G6EJD
      @G6EJD  5 ปีที่แล้ว +1

      Davide, it is possible to do this but the method is complex and requires a lot of experience and knowledge to do it, sorry. What are you trying to do? When you use OTA your serial port is already remote check your IDE you should see the ESP port number with its IP address so data on that port if you select it should be visible.

    • @sblantipodi
      @sblantipodi 5 ปีที่แล้ว

      @@G6EJD thanks for the reply and the great channel. I'm using serial.println() to debug my code. In my ide Incan see the devices I uoloaded the OTA sketch and I can reupload sketches via ota but the ide tell me the ip address of that devices but not the serial port. Devices are not connected to the pc. So what is the right port to connect via putty serial?

    • @G6EJD
      @G6EJD  5 ปีที่แล้ว +1

      Davide, in the IDE do you see the port (ip address) of your board? That is the IP address. The ESP does not have a process running that can respond to an IP connection on a given port, as I say it’s not as easy as you might think. If you use the Espressif IDE you can redirect the serial port to use telnet as a transport protocol and then on your PC you can install and use telnet to get a remote UART connection. There are notes that explain how to do this.

    • @sblantipodi
      @sblantipodi 5 ปีที่แล้ว

      @@G6EJD This channel is amazing, congrats. I'm using Platformio for mi C++ sketches and I don't want to leave Platformio + Visual Studio Code at the moment. So I think that I'm out of lack. Thanks anyway :)

  • @boyeselectrical
    @boyeselectrical 6 ปีที่แล้ว

    Is there a way to use serial monitor for debug info through telnet or something regards dan.

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว

      There a few libraries that are easy to use and can do that: github.com/JoaoLopesF/RemoteDebug

    • @boyeselectrical
      @boyeselectrical 6 ปีที่แล้ว

      G6EJD thanks

  • @zeeshanhaider3925
    @zeeshanhaider3925 6 ปีที่แล้ว

    no network port is shown on ide.
    what can be solution to that?
    i've tried disabling the firewall,restarting the id and rebooting esp8266 but still the problem persists.
    please help

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว

      zeeshan haider Usualky this is because the OTA support is not installed correctly or try installing it again and restart the PC and IDE.

  • @stahelpeter
    @stahelpeter 6 ปีที่แล้ว

    Hi Great video. When I try to upload the blink sketch via OTA I always get the error [ERROR]: No response from device.
    Did you make any changes on the router, firewall ect.
    Any idea what the issue could be?
    Thank you in advance.

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว

      Have you tried the sketch I supplied on Github? I made no changes to my router and I'd expect most Routers to allows allow a LAN connections and assuming you don't have any issues connecting a new Wi-Fi device to your network then that's should not be a problem. Does the ? ESP8266 connect to your router ordinarily?Are you seeing a network port in the IDE something like 192.168.0.70 that should appear when the ESP8266 has been running a while. Sometimes you have to restart the IDE so that it can detect the requesting ESP8266 / ports. If the ESP8266 is not requesting an OTA the port does not appear.Sometimes a reinstall of Python 2.7 reinstates the port detection elements.

    • @stahelpeter
      @stahelpeter 6 ปีที่แล้ว

      I have just reinstalled Python 2.7.14 and I execute these steps:
      1. Use your ESP8266_OTA_Bootloader.ino and upload via serial cable.
      2. Restart IDE and press reset on the esp8266 board.
      3. Disconnect esp8266 board and start it with a power bank.
      4. Use your ESP8266_OTA_Blink.ino and choose port esp8266_ip_xxx
      5. Upload the sketch, I pass the authentication step successfully but then receive the error " [ERROR]: No response from device"
      In my opinion esp8266 is properly connected in my WLAN / router.
      Any idea what the issue could be?
      Thank you in advance.

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว

      When the upload completes the ESP8266 is reset and disconnected from the network, so initially I'd expect the network port used to programme it to disappear. So I take it that a simple LED blink routine does not blink as expected, if so then let's think through some diagnostic steps, have you maintained the serial connection to watch the serial port output as that will give you an indication of any possible errors and you could add more diagnostic prints to your programme to see where it stops issuing them. My guess is it will be something straightforward perhaps a typo somewhere. The ESP8266 OTA is a stable process, are you using the latest IDE for the ESP8266 2.3 and not 2.4rc1?

  • @submarine.7seas
    @submarine.7seas 6 ปีที่แล้ว

    A+++ Thanks

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว +1

      Pleased you like it. If your network port disappears on a PC, then a 'repair' option of the Python 2.7.14 solves this. I don't know why this happens, the OTA elements of the ESP range have not been refreshed/updated for a long time.

  • @MPElectronique
    @MPElectronique 6 ปีที่แล้ว

    G6EJD, i see the esp8266 in the Bonjour browser, but no port shown in serial in arduino ide? :( what do you suggest?
    Thank you so much! :)
    Marc.

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว

      What networks do you see? The default port, you can set it to your requirement, is wait for it 8266

    • @MPElectronique
      @MPElectronique 6 ปีที่แล้ว

      the problem is that i don't see it in the arduino ide serial port?! :( only in bonjour browser in 8266 ports.

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว

      So there’s no USB connection then, this can be a really difficult problem to solve, do you get any connection acknowledgement like sound or when you look at connected devices do you see it?

    • @MPElectronique
      @MPElectronique 6 ปีที่แล้ว

      I can only program it through COM port, there's no serial OTA showing up! :(
      thanks.
      Marc.

    • @G6EJD
      @G6EJD  6 ปีที่แล้ว

      Another common problem, have you tried restarting / reinstalling the java environment that handles the OTA aspects. In terms of sequence no virtual port will be seen initially by the JAVA device/port scanning, then you upload via the COM port a programme that supports OTA (that means the ESP actively checks for an OTA request let's say every 10-secs and if it does responds with an 'available for OTA' response) then it can take perhaps a minute or more or an IDE restart to see the new port (the remote ESP), after which you can disconnect the COM port and programme the device via the virtual IP port. BUT your uploaded programme has to keep checking for an OTA request or it won't OTA again and require it to be programmed via the COM Port again.

  • @selvaaai
    @selvaaai 7 ปีที่แล้ว

    Can i do the OTA from anywhere in the world?
    For Ex :Programmer in US and ESP8266 or node MCU in INDIA.IS it possible with the above

    • @G6EJD
      @G6EJD  7 ปีที่แล้ว

      Should be, I have not examined the Library that sets the IP address e.g. 192.168.0.24 in my example. Clearly it works on a LAN but a WAN would need your remote router to allow traffic through from the WAN IP to the ESP8266-IP with a rule that looked something like this:
      WAN-IP:8266 to LAN-IP(192.168.0.24:8266) allow TCP/UDPthe connection would be WAN-IP of the remote site e.g. 151.64.234.67:8266/ and that is where the Arduino IDE would need to have access to, so there would need to be a way of changing 192.168.0.24 to in my example 151.64.234.67 so that the remote programming can be done.I checked the documentation and there is a Web Updater process too, so you could use that over a WAN. See here:esp8266.github.io/Arduino/versions/2.0.0/doc/ota_updates/ota_updates.html

    • @selvaaai
      @selvaaai 7 ปีที่แล้ว

      In the link the requirement given is "It needs to be in the same network"....Mean that we cannot do a update from anywhere...is it?

    • @G6EJD
      @G6EJD  7 ปีที่แล้ว

      Yes it does, but in the section above copy:"HTTP Server ESPhttpUpdate class can check for updates and download a binary file from HTTP web server. It is possible to download updates from every IP or domain address on the network or Internet."It clearly states 'internet' and I think it can be done, but never tried it. It looks like the documentation needs to be reviewed as it's ambiguous.

    • @G6EJD
      @G6EJD  7 ปีที่แล้ว

      Joe Anon Indeed but afaik there is no support for that approach and the two devices ESP and updating device must be on the same network.

  • @karanbirsoin9983
    @karanbirsoin9983 ปีที่แล้ว

    I am getting error that there is no answer from the device

    • @G6EJD
      @G6EJD  ปีที่แล้ว

      Is it connected or connecting to your network? Are you polling on the update device for a connection?

    • @karanbirsoin9983
      @karanbirsoin9983 ปีที่แล้ว

      @@G6EJD it is connected to the network.

    • @G6EJD
      @G6EJD  ปีที่แล้ว

      So in normal operation you can see the IP address of the ESP, then when you run the update process you see no response, this indicates that your ESP code is missing the check for an update service request. You can either use my example or the example in the Arduino IDE for OTA as they are identical. It’s most likely to be a coding error, you need to check your code on the remote device.

    • @karanbirsoin9983
      @karanbirsoin9983 ปีที่แล้ว

      @@G6EJD yes it is listed under tools>port in the ide in addition to the com port. update service request, can you give me a hint what this code is?

    • @G6EJD
      @G6EJD  ปีที่แล้ว

      @@karanbirsoin9983 go to examples OTA