Тёмный

#332 

Andreas Spiess
Подписаться 483 тыс.
Просмотров 136 тыс.
50% 1

In this video, I would like to remind you of a handy ESP32 concept: Over the air or OTA update. A simple and efficient replacement of the Serial cable for devices which are not easily reachable, or for barebone ESP32 modules. And, as usual, I will add a few tricks and helpers.
In this video, we will:
Learn how to use ESP32 OTA
Create a basic sketch template for all our new projects
I will show you some tricks like remote debugging
If this simple OTA is not enough, I will show you other frameworks
And, as usual, I included a “one last thing”
I am a proud Patreon of GreatScott!, Electroboom, Electronoobs, EEVblog, and others.
Links:
Sketches: github.com/Sen...
ESP32 Dev board: s.click.aliexp... and s.click.aliexp...
Standard ESP32 Dev board: amzn.to/2Axh24B
ESP32 barebone PCB: s.click.aliexp...
Telnetstream: github.com/jan...
WiFiManager for ESP32 (and ESP8266): github.com/tza...
IOTappstory.com: iotappstory.com/
The links above usually are affiliate links which support the channel (no additional cost for you).
Supporting Material and Blog Page: www.sensorsiot.org
Github: www.github.com...
My Patreon Page: / andreasspiess
Discord: / discord
If you want to support the channel, please use the links below to start your shopping. No additional charges for you, but I get a commission (of your purchases the next 24 hours) to buy new stuff for the channel
My Amazon.com shop: www.amazon.com...
For Banggood bit.ly/2jAQEf4
For AliExpress: bit.ly/2B0yTLL
For Amazon.de: amzn.to/2r0ZCYI
For Amazon UK: amzn.to/2mxBaJf
For ebay.com: ebay.to/2DuYXBp
www.facebook.c...
/ spiessa
www.instructab...
Please do not try to Email me or invite me on LinkedIn. These communication channels are reserved for my primary job
As an Amazon Associate, I earn from qualifying purchases

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 642   
@georglinde3910
@georglinde3910 4 года назад
"It always sits in the in the first row!" - brilliant! :-D
@PranavSharma2504
@PranavSharma2504 4 года назад
@@nutsandguts2871 Maybe 17 other people (including me) get impressed easily too, then. Edit: 31 now
@gerdkah6064
@gerdkah6064 4 года назад
5:44 so OTA is also a subscriber ^v^
@systemofapwne
@systemofapwne 4 года назад
Or you just sort your projects differently and use a better IDE (like MS Visual Studio Code + Platform.io) instead of the limited Arduino IDE. Yet, I like his videos for being "always straight and basic" (which unfortunately implies to also fallback to arduino IDE)
@WistrelChianti
@WistrelChianti 4 года назад
@@PranavSharma2504 it was a great joke! (made me laugh anyhow =D)
@bowiejudah1617
@bowiejudah1617 3 года назад
i guess Im asking randomly but does anyone know a trick to get back into an Instagram account..? I was stupid lost my password. I appreciate any tricks you can offer me!
@tonyp4894
@tonyp4894 5 месяцев назад
Andreas, I spent over a week trying to get OTA Basic from the Examples to work with my ESP32 Cam. Finally, I gave up and used your OTA template and it worked the first time and every time since. I can't thank you enough for taking the time to help me and those less fortunate in electronics knowledge. You're a HERO. :))
@AndreasSpiess
@AndreasSpiess 5 месяцев назад
Glad I could help!
@VildanAkchurin
@VildanAkchurin Год назад
Copying and pasting from sketch example works right away! PuTTY debugging works as a charm. Thank you for the clear explanation and extended OTA debugging.
@AndreasSpiess
@AndreasSpiess Год назад
Glad it helped!
@PeterAlbronda
@PeterAlbronda 4 года назад
Again a wonderful presentation with much practical information in a short time. Each Sunday morning I am looking forward to your high value information, thank you!
@AndreasSpiess
@AndreasSpiess 4 года назад
You are welcome! And thank you for your nice words.
@AndrewDanne
@AndrewDanne 4 года назад
This is so cool. 1. I am just starting to learn morse code. 2. I am just getting my head around ESZP32 and 8266. 3. I am working on a battery-powered automation controlled relay and am searching for information on very very low power devices (which you have previously covered). I really enjoy your ideas and how you go about explaining them. OTA will really help with all these projects.
@AndreasSpiess
@AndreasSpiess 4 года назад
If you want to learn morse you have to have a look at my first videos. And if you are interested I have an updated version for the ESP32...
@gaanpagla8417
@gaanpagla8417 4 года назад
Brilliant video. Now I don't have to find my data cable which has a tendency to disappear whenever I need it . Thanks so much !
@AndreasSpiess
@AndreasSpiess 4 года назад
And you even do not have to find your ESP as long as it has Wi-Fi connection ;-)
@massimomalesci352
@massimomalesci352 4 года назад
Great video, Andreas, and very well explained!!!! Greetings from Italy! And I always sit in the first row!!!
@AndreasSpiess
@AndreasSpiess 4 года назад
Thank you!
@robertnickels1527
@robertnickels1527 3 года назад
Thank you for this great tutorial, subscribed immediately - although I suspect it's getting crowded in the first row! I have Telnet remote debugging working on the ESP-01, all that's needed is to add "#include TelnetStream" and add "TelnetStream.begin();" in Setup. And I've only been playing with ESP-01 for a few days ;-)
@AndreasSpiess
@AndreasSpiess 3 года назад
Welcome aboard of the channel!
@OldCurmudgeon3DP
@OldCurmudgeon3DP 4 года назад
Very useful video, sir. I'm happy to see more code taking advantage of the ESP32. Dev boards are close enough to the 8266 in price that it's worth using the 32s even for simple projects. The extra uart is nice for Nextion screens. ITead just needs to rework their editor to be a little more user friendly.
@AndreasSpiess
@AndreasSpiess 4 года назад
The ESP32 has many advantages. So there is no real benefit in investing into ESP8266.
@peerappel2012
@peerappel2012 4 года назад
Thanks very much! More information about RTOS would be great imo. Also cant the otahandle function be called every once in a while by a timer interrupt? Especially as it doesnt take to much time anyways.
@AndreasSpiess
@AndreasSpiess 4 года назад
Try it, maybe it will work. I do would not like this structure.
@michaeldreher1372
@michaeldreher1372 4 года назад
​@@AndreasSpiess Use another thread, not an interrupt.
@AndreasSpiess
@AndreasSpiess 4 года назад
Another task did not work :-(
@michaeldreher1372
@michaeldreher1372 4 года назад
​@Andreas Spiess : I tried it and also and had some problems, but I was able to fix them: 1. I had to reduce the sleep time between the calls to 5ms (10ms is too long) 2. I had to increase the stack size to at least 1900 byte, (1800 byte is not enough) call this in setup(): TaskHandle_t xOTATaskHandle = NULL; xTaskCreate( vOTATaskCode, "OTA", 2048, NULL, 1, &xOTATaskHandle); define the task function and remove the 'ArduinoOTA.handle()' call from loop(): void vOTATaskCode( void * pvParameters ) { for(;;) { sleep(5); ArduinoOTA.handle(); } }
@WistrelChianti
@WistrelChianti 4 года назад
@@michaeldreher1372 @Andreas Spiess I've managed to get this working slightly differently to Michael but had to change a few things. Mind if I send a pull request with the updates? (I'll have to do them in a tidy way first, currently code is full of debug prints)
@HimalayanPathik
@HimalayanPathik 2 года назад
Thank you so much for this awesome tute. I am now able to solve my year-old problem. Very accurate and informative tutorial. God bless you.
@AndreasSpiess
@AndreasSpiess 2 года назад
Glad it helped!
@jstro-hobbytech
@jstro-hobbytech 2 года назад
This is a great video. Best explanation on how to do it. I know I'm a little late but credit where credit is due. I use the wemos d1 and have never had to reset after an ota update. My only complaint is that espressif should've released a more powerful board by now. They're the best other than a pi zero or whatever the new wifi mini pi is called. Anything pi related in Canada that isn't a Pico is at least 115 dollars where as an esp32 is about 20 now. More program memory and a faster cpu like the teensy has been doing for years but the teensy is 60cad.
@AndreasSpiess
@AndreasSpiess 2 года назад
I most of the time use the ESP32 which is much stronger than the ESP8266 and not much more expensive...
@jstro-hobbytech
@jstro-hobbytech 2 года назад
@@AndreasSpiess the chip shortage has affected esp32 modules. Where you used to get 5 for 30 dollars, 2 for 30 is the going rate while the 8266 is now 5 for 50. It's made me realize (which is somewhat contradictory to what I said previously) the 8266 can do alot of the same things I need without any appreciable notice in lag for some of the devices I make. They're nothing special, just iot devices that do simple things usually lighting related. Haha. I've been doing alot more circuit stuff recently, like learning more about passive component along with digital logic ics, respectively. I have more of a software background than hardware and I find that more interesting learning wise.
@pcost
@pcost 4 года назад
Hello Andreas! I always wait anxiously for new videos from you, no matter the subject, I know that I will learn lots of things! Greetings from Canada! 🙌
@AndreasSpiess
@AndreasSpiess 4 года назад
During the last weeks you did not have to wait for too long ;-) It must be late in Canada...
@PranavSharma2504
@PranavSharma2504 4 года назад
Same here! Of all the RU-vidrs, @Andreas Spiess is my all-time favorite! A perfect mix of information, experimentation, and humor!
@krishnanov21
@krishnanov21 4 года назад
Just when I needed it! Thank you🙌
@AndreasSpiess
@AndreasSpiess 4 года назад
Perfect!
@Marc_Miller
@Marc_Miller 4 года назад
​@@AndreasSpiess I'm having trouble finding your video shown at 6:19 talking about using the FTDI board to read the serial connection. Which video was that in?
@Zalo29
@Zalo29 4 года назад
Good tricks Andreas. Creating a mock-up sketch with OTA&credentials , so smart I've been using remoteDebug to get a serial port when deployed, but recently I've got some troubles with websockets. I'll try your telnet suggestion. Thank you so much! BTW, I encourage you to dig into FreeRTOS as it gives you a lot more possibilities to manage many tasks concurrently
@AndreasSpiess
@AndreasSpiess 4 года назад
I also had problems with other remote debugging libraries together with OTA. This one worked.
@WacKEDmaN
@WacKEDmaN 4 года назад
funny that.. i was just setting up OTA on my ESP8266!... Great minds think alike!! :P nice info..as usual..Thanks Andreas :)
@AndreasSpiess
@AndreasSpiess 4 года назад
My pleasure!
@Retrocomputernerd
@Retrocomputernerd 4 года назад
@@AndreasSpiess This is awesome, will the example sketch work with an ESP8266 though? The video indicated it would need someone to contribute a compatible version. I am still working through how to include the #include libraries
@WacKEDmaN
@WacKEDmaN 4 года назад
@@Retrocomputernerd try this one i setup after watching.... i was using a version already in ESP_AsyncFSBrowser.. i just added esp8266s needed libs wrapped in #ifdef. the ArduinoOTA calls would complain during compile on esp8266 so i fixed them too.. github.com/WacKEDmaN/ESP32-OTA/blob/master/0TA_Template_Sketch/OTA.h
@stonecoldcnc
@stonecoldcnc 4 года назад
@@WacKEDmaN Thanks for that, seems to work fine on the Wemos D1 board but not on the ESP-07, [ERROR]: Bad Answer: ERR: ERROR[4]: Not Enough Space
@WacKEDmaN
@WacKEDmaN 4 года назад
@@stonecoldcnc make sure the partitions are set correct... im also guessing the low flash memory ESP (eg 512k/1Mb) chips wont be able to support OTA
@ZookeeperJohnG
@ZookeeperJohnG 6 месяцев назад
Super helpful, thank you!🥸
@AndreasSpiess
@AndreasSpiess 6 месяцев назад
You are welcome!
@drmocm
@drmocm 4 года назад
Very interesting. I also have a trick for when you use a battery driven device that sleeps a lot, e.g. a sensor like the bme680. In that case loop is never reached and the device goes to sleep very fast. So, I use a loop in the setup that looks for the bme680 and in that loop I add the OTA handle. All I have to do is disconnect the sensor and the device keeps looping and I can connect via OTA. You could use a switch or button to disconnect the sensor.
@AndreasSpiess
@AndreasSpiess 4 года назад
Great tip! Thanks!
@andreaswinter1400
@andreaswinter1400 4 года назад
Great stuff, as always. But one little remark: Usually you don't put any executable code into .h files. In almost all cases they only contain types, macros, defines, and function prototypes. But I'm not so familiar with the Arduino IDE so maybe this is the only way to split code into several files.
@AndreasSpiess
@AndreasSpiess 4 года назад
I also do not know. I assume you can give it another name if you want ;-)
@JustinShaedo
@JustinShaedo Год назад
(a bit late but...) .h files are headers eg for storing constant variables. .cpp are used for declarations (functions, classes, etc) This is just convention and 99% of the time the compiler won't care what you use BUT might add well do it 'properly'.
@ronproveniers3655
@ronproveniers3655 4 года назад
Nice, i can use this for the solar weatherstation ( with bme280 and pms50003) which i develop now One Question: how can we OTA the esp32 when we use deepsleep? Yes, RTOS is also very interesting subject , special when to use or not to use? Maybe just use a scheduler?? Maybe you should explain about lockups and not putting watchdog triggers in a seperate task! Thanks for your good work Ron
@DO7DH
@DO7DH 4 года назад
You could add a switch to manually switch off deepsleep mode, if you have access to the weather station. Otherwise configure 15 min. each day for flashing e.g. 12:00 to 12:15.
@ronproveniers3655
@ronproveniers3655 4 года назад
DO7H, good suggestion. It makes the program a bit more complicated, need exact time and have no internet connection? The idea is that weatherunit hangs somewhere remote at a pole.
@avieleliyahu6199
@avieleliyahu6199 4 года назад
Thank you, an educational and fun video as usual 😄
@AndreasSpiess
@AndreasSpiess 4 года назад
Glad you enjoyed it!
@alanesq1
@alanesq1 4 года назад
I have been very impressed using the OTA option to upload the bin file from a web browser rather than via the Arduino IDE. This is very handy if you have created a ESP project for someone else as you can send them the bin file and they can update it themselves. You can see how I use it here: github.com/alanesq/BasicWebserver
@Retrocomputernerd
@Retrocomputernerd 4 года назад
this also looks like a very cools solution, however Arduino IDE is rejecting the library zip file, even after renaming the subfolder. Any advise, or a tutorial link?
@alanesq1
@alanesq1 4 года назад
​@@Retrocomputernerd Hi, You need to manually unzip the file and copy the files to your arduino library folder. BTW - I have just noticed I give the wrong password in the instructions, it should be 12345678 I have just uploaded a newer version of the sketch which asks for a password to access OTA (Not very secure but a lot better than nothing)
@AndreasSpiess
@AndreasSpiess 4 года назад
@alanesq: This is where IOTappstory began...
@VladimirErmakov
@VladimirErmakov 4 года назад
Also small note about upload: image was uploaded to one of two partitions (free one), then if all ok and md5 match, bootloader would be told to switch to use that partition. So nothing to memmove. (i may be not accurate, digging into the code a few years ago to check what's wrong with http ota, and i don't know what is used for SPIFFS, because i only use it to store config.json).
@AndreasSpiess
@AndreasSpiess 4 года назад
I think you are right.
@temyraverdana6421
@temyraverdana6421 4 года назад
Mr. Andreas thanks, this video is amazing! Thanks!
@AndreasSpiess
@AndreasSpiess 4 года назад
You are welcome!
@Павел-ж1щ7л
@Павел-ж1щ7л 4 года назад
Thanks for tutorial! Also one note - better to disable all interrupts right in begining of on ArduinoOTA.onStart function. As I see on my sketch with Ticker library - OTA not likes if someone interrupts it while transmission ) So I called .detach commands in begining of OTA.onStart
@AndreasSpiess
@AndreasSpiess 4 года назад
If you do not attach interrupts it should not be a problem, I assume. But disabling them is for sure not wrong.
@harrytsang1501
@harrytsang1501 3 года назад
The use of delay() inside a task will cause busy waititng and makes your system less real-time. The task will not yield to lower priority tasks so vTaskDelay() is preferred over delay(). However, your time will delay in increments of 15 ms so you may want to also use millis() to make it tighter
@AndreasSpiess
@AndreasSpiess 3 года назад
You are right. I read somewhere that delay() is replaced with vTaskDelay() by the compiler (which would make sense). All my tests with RTOS showed that the ESP32 is way too fast for all tasks I created and had to wait most of the time anyway.
@santopino2546
@santopino2546 4 года назад
Excellent, finally something that I will surely personally use. Thank you.
@AndreasSpiess
@AndreasSpiess 4 года назад
Glad it was helpful!
@phinok.m.628
@phinok.m.628 4 месяца назад
I may be a little late to the party. But (5:39) well played... ;-)
@AndreasSpiess
@AndreasSpiess 4 месяца назад
Thank you!
@erwinkooi6669
@erwinkooi6669 4 года назад
Hi Andreas, great video as always! Do you know if this is also possible with VS Code and platformio? I completely switched over from the Arduino ide (which is great for starters, but not so much when you have large and diverse projects.
@AndreasSpiess
@AndreasSpiess 4 года назад
I think it is possible, too
@MasseyLee
@MasseyLee 4 года назад
@@AndreasSpiess Did you stop using PlatformIO and go back to Arduino IDE ?
@MennoLauwerens
@MennoLauwerens 4 года назад
Yes, it also works from platformIO. I use it all the time.
@ulwur
@ulwur 4 года назад
@@MennoLauwerens do you mind showing or explaining how you did the template stuff and how to do the wireless uploading?
@MennoLauwerens
@MennoLauwerens 4 года назад
@@ulwur Just set these options in platformio.ini: board_build.partitions = min_spiffs.csv ; See:github.com/espressif/arduino-esp32/tree/master/tools/partitions ;upload_port = COM5 upload_protocol = espota upload_port = 192.168.0.35 ; IP of the ESP32 The rest is identical to this video.
@kallereunanen1575
@kallereunanen1575 4 года назад
This video was useful! Thanks a lot for a very dense set of excellent tips!
@AndreasSpiess
@AndreasSpiess 4 года назад
Glad you can use it!
@leadeddeveloper9575
@leadeddeveloper9575 4 года назад
Thank you for your video, I like those ESP videos so much. Also, I'm planning to use ESP in my new project on my channel. It is a very exciting controller!
@AndreasSpiess
@AndreasSpiess 4 года назад
Go for it!
@kevinfine9303
@kevinfine9303 4 года назад
Hi Andreas, very useful video, as always. You've helped me a lot with my projects! I wanted to mention a correction to your description of OTA. It appears that the ESP32 maintains two areas of memory, OTA1 and OTA2. The Esspressif OTA mechanism always loads the new firmware in the unused portion, and, if successful, switches over the boot pointer to the new area of memory. Thus the previous firmware is not written over as implied in the video, and is available for a rollback. This from docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/ota.html Again, thanks for all your help, and also, Grüezi from Yverdon!
@AndreasSpiess
@AndreasSpiess 4 года назад
You are right. Because it happens on the background I did not want to make it more complicated than necessary.
@arifindobson
@arifindobson 4 года назад
I am proud to say that I am enrolling in an IoT program from ASIT (Andreas-Spiess-Institute-of-Technology). and "ASIT" in the first row. Love it, awesome as always~
@AndreasSpiess
@AndreasSpiess 4 года назад
Glad you think so! ASIT - I love it!
@arifindobson
@arifindobson 4 года назад
@@AndreasSpiess Thank you prof :D
@wjhoogervorst
@wjhoogervorst 4 года назад
Thanks, just what I needed. With my ESP8266 I use ESP8266HTTPUpdateServer, but on my ESP32 I could not get the ESP32 version of this functionality working properly. Now I will switch to this way of OTA update, until I get the Webupdate working.
@AndreasSpiess
@AndreasSpiess 4 года назад
Good plan!
@borishruby7131
@borishruby7131 4 года назад
Hello Andreas! I really love your videos and can't wait for another one. I like the way you do it. I didn't know something like this is possible in ESP32 at all! By the way, it works also on ESP8266 as I've just found out. Thanks a lot and keep up the great work! Greetings from Slovakia!
@jamesgoacher1606
@jamesgoacher1606 4 года назад
Very interesting but above my familiararity ? level at the moment. Will need to get back to this when I have done more.
@AndreasSpiess
@AndreasSpiess 4 года назад
This seems to be a good plan!
@originalni_popisovac
@originalni_popisovac Год назад
My name is Otakar, would someone be able to explain why my name shortcut is in the video title? this name ( Otakar ) is very unusual and it's a Czech name, and I don't know someone named Otakar like me.. tf...
@AndreasSpiess
@AndreasSpiess Год назад
Over the Air…
@eugenijusm
@eugenijusm 4 года назад
There are many issues with this. It's ok if you are learning stuff or playing around. If you want a real device running 24/7 it's good idea to put OTA stuff into separate code flow (e.g. enabled only if jumper/button is active on power up). What this gives you is that you don't litter your main code with ArduinoOTA.handle() and some security (accidental overwrite and/or resistance to malware abusing devices like this).
@AndreasSpiess
@AndreasSpiess 4 года назад
If you need more functionality maybe you have a look at IOTappstory.com?
@electronic7979
@electronic7979 4 года назад
It was a video with useful information. I liked it
@AndreasSpiess
@AndreasSpiess 4 года назад
Glad to hear that
@MrgnUTube
@MrgnUTube 4 года назад
Thank you so much for this vidéo Andreas :)
@AndreasSpiess
@AndreasSpiess 4 года назад
My pleasure!
@SandeepSolankis
@SandeepSolankis 4 года назад
Thanks for sharing. You resolve my broken microUSB problem. Appreciate it. One quick question - Why don't you make videos of development using ESP-IDF because i believe that building a production ready is more safer in esp-idf than arduino. Please comment.
@AndreasSpiess
@AndreasSpiess 4 года назад
Because only a few people use theeIDF and my channel would crash...
@bm830810
@bm830810 4 года назад
I've used OTA on both ESP8266 and ESP32 and don't remember any difference in the code, yours might just word without any modification on ESP8266, also why some episodes don't have the number at the beginning, I like the numbering a lot
@AndreasSpiess
@AndreasSpiess 4 года назад
The last 10 episodes or so never had numbers. I add them later for reference. The WiFi library for sure is different and maybe also some commands in the setup. I did not look into it.
@bm830810
@bm830810 4 года назад
@@AndreasSpiess The WIFI library needed by ArduinoOTA is encapsulated in its lib, it knows what is needs and will use that accordingly
@toddpichler8578
@toddpichler8578 4 года назад
Hello Andreas, Thank you for another great example. I finally got it working but I struggled a bit because I decided to use VSCode and PlatformIO (one of your other awesome videos). The part that stumped me was the way PlatformIO automatically selects the upload connection. Normally that is a good thing but I wanted to test the OTA connection. It turns out I needed to add a line to the platform.ini file like this "upload_port = " where "" is the value printed to the serial monitor. Maybe that will help someone else. Thanks again!
@AndreasSpiess
@AndreasSpiess 4 года назад
There were a few other comments about the same fact. So you are not the only ;-)
@Kaaputenen
@Kaaputenen 4 года назад
The automatic RU-vid captions said 'gritty RU-vidr' at the beginning of the video.
@AndreasSpiess
@AndreasSpiess 4 года назад
Google not yet understands Swiss German. Probably too hard ;-)
@nkronert
@nkronert 4 года назад
I assume that the OTA functionality doesn't time out when the device is set to sleep? And would it be possible to increase the timeout value?
@phillkelley7700
@phillkelley7700 4 года назад
Sleep on the ESP32 and ESP8266 kills OTA but sleep also implies a reboot so setup() runs again. If your device is only awake for a second or so, you don’t have time to send a sketch. You can solve this problem by adding a physical “keep awake” button which, if it is detected at setup() time, enables OTA and keeps the device awake for a couple of minutes. But it is generally easier to set up something like Node-Red to handle a “check for updates” and serve a new sketch when needed. I do that on TrigBoards (where adding a “keep awake” button would be tricky). The relay fires, the ESP8266 wakes up, it has to bring up WiFi anyway to send the “door opened” event via MQTT so it’s convenient to add a “check for updates” (HTTP protocol) at the same time. When I update my TrigBoard sketch, I put the binary where Node-Red (running in IOTstack) can find it, then walk around the house opening the doors that have TrigBoards attached. They self-update and go back to sleep.
@PranavSharma2504
@PranavSharma2504 4 года назад
@@phillkelley7700 Alternatively, if your board wakes up and talks to NodeRED or something, you can send back a flag in the response to your ESP and make it enable OTA and stay up for a few minutes.
@phillkelley7700
@phillkelley7700 4 года назад
@Pranav Sharma I had not thought of doing it that way. I settled on HTTP because the incoming query automatically includes the MD5 of the running sketch. The Node-Red flow looks for the youngest binary, computes its MD5 and if there’s a match, replies saying “no update”. If there’s a mismatch, it knows the TrigBoard is running a different sketch and returns the replacement binary. This scheme actually works equally well for “upgrade” as “downgrade” and it doesn’t rely on me incrementing a version number in the sketch. In practice, I don’t actually go and open the TrigBoard doors. I just assume the TrigBoards will self-update the next time they activate. I can see subscribing to an MQTT command and control topic working but if I have to visit the gizmo anyway to wake it up so it can get the “stay awake” after which I return to my desk, find it in the OTA sketch then download the new code then, on balance, the “self-update automatically next time you wake up normally” appeals to my lazy streak. One gotcha in all of this which Andreas didn’t really mention is that you have to be extremely careful with keeping your SPIFFS partition correct. Getting that wrong is a very good way to render your ESP inoperable, particularly so if your sketch depends on data stored in SPIFFS. This is true of both regular OTA or the HTTP query to Node-Red method. The only way to recover from that is to physically reconnect to the board over USB.
@AndreasSpiess
@AndreasSpiess 4 года назад
Or you go to IOTAppstory where everything is neatly solved. Worldwide, with HTTPS...
@foskolo
@foskolo 3 года назад
Grüezi Andreas, great video again! The sketches I dowloaded from your link are quite different from them of the video ("#define ESP32_RTOS " at the begin of the "0TA_Template_Sketch" for example ). Can I use them without changes with an ESP32 (except SSID and password of course)? Thank you!
@AndreasSpiess
@AndreasSpiess 3 года назад
I do not remember the details. I would just try it ;-)
@mradulbhardwaj4134
@mradulbhardwaj4134 3 года назад
How to *ota update* through internet ??
@AndreasSpiess
@AndreasSpiess 3 года назад
I only do it over the air
@WacKEDmaN
@WacKEDmaN 4 года назад
Andreas, heres your git forked with ESP8266 support :) github.com/WacKEDmaN/ESP32-OTA/blob/master/0TA_Template_Sketch/OTA.h
@AndreasSpiess
@AndreasSpiess 4 года назад
Great! Could you send me a pull request? Then you would be visible as the author...
@PhG1961
@PhG1961 4 года назад
Excellent and usefull !
@AndreasSpiess
@AndreasSpiess 4 года назад
Thank you!
@jenskaa4044
@jenskaa4044 4 года назад
Interesting as always Did you consider using a task for the ArduinoOTA.handle()? I think many projects could be structured in a much better way by using the FreeRtos that comes with the ESP32, so take a look into that area. Nearly all my projects uses tasks and queues/semaphores where the typically Arduino uses poll-this / poll-that in the main loop. "Ceterum censeo Arduino esse delendam" +1 for PlatformIO+IDF
@AndreasSpiess
@AndreasSpiess 4 года назад
Here it did not work outside loop. Maybe you are luckier?
@ezanchet
@ezanchet 4 года назад
Hi Andreas, thanks for your interesting videos. Have you ever tried using the IotWebConf library? I have been using it for a month on both ESP32 and ESP8266 and I find it very interesting.
@AndreasSpiess
@AndreasSpiess 4 года назад
No. It seems to be a similar thing as WiFimanager. But lately no more maintained? Do you use it?
@ezanchet
@ezanchet 4 года назад
@@AndreasSpiess I started using it a month ago and it seems to be working very well. It has some very interesting features: 1) you can create as many pages as you want using html and return json in the same way. 2) the configuration page is under basic authentication and supports the validation of the form. 3) supports both esp8266 and esp32. 4) OTA update directly from a web page. I have no idea if it is out of support or has achieved stability that no longer requires fixes or changes. In any case, I started a new project using it and in a few months I will see if it is reliable. I will only add TelnetStream as suggested in your video :-)
@bryanhickman7663
@bryanhickman7663 4 года назад
Loved this video. I have a bit of a side question. I didn't know how to get to your attention. "Andreas, I've been a fan for years, but this is the first time I have tried to contact you. After this Covid-19 got started, I've been trying to find a Maker way to insure killing it. (Have qualifications, but no need to discuss now.) I have built a home built UVC sterilizer, however, I am dissatisfied with the ways or the expense of measuring it. I currently use calculations to know how much UVC I am delivering to the target surface to kill the bug. Commercial UVC measuring devices are super expensive. Between $250 and $650 US. Do you think you can come up with an accurate, Maker version that won't break the bank. It needs to measure microWatts in order to calculate the microJoules necessary to kill bugs. There is a UVA/UVB sensor out there for about $6 US, and I have ordered it, but it will not "really" do the job, and calibrating it for UVC may not yield usable data. It is an analog sensor whose output is 1V. Available sometimes from Adafruit and on eBay. Search for "GUVA-S12SD-UV" I'm sure many of us could use something like this before the second wave of the disease strikes."
@listerdave1240
@listerdave1240 4 года назад
Thanks a lot for this tutorial. I had been wanting (and needing) to do OTA for a long time but always wrongly assumed it would be very difficult and had in fact tried a few times without success but after watching your video I got it working in a few minutes in one of my projects.
@AndreasSpiess
@AndreasSpiess 4 года назад
Glad I could help!
@jorgwende6314
@jorgwende6314 4 года назад
BTW - congrats to your 100th github project ....
@AndreasSpiess
@AndreasSpiess 4 года назад
I did not know. Thanks for mentioning!
@VladimirErmakov
@VladimirErmakov 4 года назад
Actually there are two versions of OTA: 1. Arduino OTA, where initiator is Arduino IDE, so you should be in the same network; 2. HTTP OTA, where you have to code trigger, but then device downloads image from http server (may be served as a static file, but better to use something that adds checksum headers, like mine esp-ota-server). That method used by Tasmota and TasmoAdmin to update devices.
@AndreasSpiess
@AndreasSpiess 4 года назад
I did not cover webOTA, because, if you need that, it is better to use IOTappstoy.com.
@WistrelChianti
@WistrelChianti 4 года назад
ah good to know this is there. I was wondering if there would be a way to dump an update somewhere online and have the board check/fetch from time to time. Will have a look. (although will maybe check Andreas' IOTappstory.com as an option)
@WistrelChianti
@WistrelChianti 4 года назад
feels like stage 2 though. Stage 1 is definitely just "avoidance of USB" for initial development work (as I'm getting close to "burying" the board)
@EpicLPer
@EpicLPer 4 года назад
I mean, not a bad tutorial and overview of OTA but first talking about broken USB connectors and then saying the first sketch has to be uploaded via USB/Serial is a bit misleading 😅
@AndreasSpiess
@AndreasSpiess 4 года назад
You can connect an external FTDI adapter to the serial pins for the first upload. That is how I do it for boards without USB
@justinmorrow2932
@justinmorrow2932 Год назад
Great instructional, worked fantastic. FYI mine still required "admin" as default password
@AndreasSpiess
@AndreasSpiess Год назад
Glad it helped!
@robottalks7312
@robottalks7312 4 года назад
Nice video, Can you do a video on LWM2M. It also contains features such as OTA
@AndreasSpiess
@AndreasSpiess 4 года назад
If it is not supported in the Arduino IDE it most probably will not appear on this channel.
@bbogdanmircea
@bbogdanmircea 4 года назад
EspHome has also debugging via OTA but I don't know how it does it ...
@efimovv
@efimovv 4 года назад
I suspect this handled via Platform IO.
@bbogdanmircea
@bbogdanmircea 4 года назад
@@efimovv Yes all the code is generated this way.
@Marc_Miller
@Marc_Miller 4 года назад
I'm having trouble finding the video shown at 6:19 talking about using the FTDI board to read the serial connection. Which video was that in?
@Jandodev
@Jandodev 3 года назад
The guy with the swiss accent!
@hygri
@hygri 4 года назад
Cool. I'd certainly like to see your take on RTOS, I've been using parts of it in my sketches and it looks incredibly powerful... A video from the guy with the Swiss accent would probably help many of us to get off the ground. Thanks!!
@AndreasSpiess
@AndreasSpiess 4 года назад
Maybe in the future, as I said...
@hygri
@hygri 4 года назад
@@AndreasSpiess Fingers crossed ;)
@dl8cy
@dl8cy 4 года назад
Good morning (today it's to early for a propper comment) )
@AndreasSpiess
@AndreasSpiess 4 года назад
Take your time ;-) Have a great Sunday.
@markjacksmarkjacks
@markjacksmarkjacks 3 месяца назад
Hi Andreas, I'm using the code but always getting the Error: "No response from device Failed uploading: uploading error: exit status 1" The ESP32 is showing up on line and it pings. 'Sorry do bother you with this. It seems I have had it working in the past. Could it be software updates? I'm using IDE 2.3.2. I've updated all of my libraries.
@AndreasSpiess
@AndreasSpiess 3 месяца назад
Maybe something changed in the meantime. I would try to use the newest examples in the Arduino IDE and check where it changed.
@angusfraser5562
@angusfraser5562 2 года назад
Andreas, did you ever do a video of how to take a raw, bare esp32 wroom module and flash a project to it. I have no hair left trying to figure this out. Given just a bare module what is the minimum that you need to be able to flash to it. Using ftdi I can see serial data from the module on reset but when I try to upload it hangs and reports: Serial port COM4 Connecting........_____....._____....._____....._____....._____....._____....._____ A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header *** [upload] Error 2 I connect ftdi 5v to 5v, rx to TX, gnd to gnd, en to gnd so that he module will be in load mode on power on? AGHHHH I wish I could have hair again.
@AndreasSpiess
@AndreasSpiess 2 года назад
To enter flash mode you have to keep GPIO0 to ground when exiting from reset. So you need to add two buttons (GPIO0 and Reset).
@AJMansfield1
@AJMansfield1 4 года назад
Instead of putting `ArduinoOTA.handle()` in your main loop, you should be able to set up an independant timer interrupt and have it run from there, as extra insurance in case `loop` (or for that matter, the rest of `setup`) crashes or delays or gets stuck in some way. edit: Actually you do address this briefly with your comment about setting up an RTOS task, which is probably a "more proper" way to do it than a raw interrupt.
@Joachim_S
@Joachim_S 4 года назад
I got the ESP-32 ota running on VSC. Unlike the Arduino IDE the port has to be defined differently. In VNC you can see the ports under platformio, home (bottom left the little house), Devices and then the tab Multicast DNS. Or you can search e.g. in your router for the IP of ESP. To use them you have to change the platformio.ini. Enter the current IP address of the ESP here. Example: upload_port = 192.168.10.119 If you want to use usb again, just put a in front of the upload_port.
@AndreasSpiess
@AndreasSpiess 4 года назад
Thanks for the explanation!
@SinanAkkoyun
@SinanAkkoyun 4 года назад
*Fortunately it is not part of the bootloader* or do you want someone to reflash your light bulb from within your network?
@AndreasSpiess
@AndreasSpiess 4 года назад
Do you give access to your network for everybody?
@treefrogclassics
@treefrogclassics 4 года назад
I prefer using WebUpdate for projects that have a web user interface. I tried the TelnetStream with WebUpdate instead of ArduinoOTA and could not get it to work. I just added the TelnetStream to the OTAWebUpdater example in the ESP32 Arduino board package. It put the ESP-32 in a boot loop. Is there a known incompatibility between the two libraries TelnetStream and Update?
@AndreasSpiess
@AndreasSpiess 4 года назад
Webupdate is best made with IOTappstory.
@themilkpirate
@themilkpirate 4 года назад
I really would love to see you make github.com/raburton/rboot more usable. For ppl who are not comfortable in dealing with linker scripts or makefiles. I would love to see this beeing Arduino compatible, because I already had to flash my ESP8622 serveral times after failing OTA updates with the standard solution :/
@AndreasSpiess
@AndreasSpiess 4 года назад
I have no issues with the current upload procedure, Never change a winning team ;-)
@AminShahsavar
@AminShahsavar 4 года назад
Great, now how to add this to Platform.io? :) (so you click just a button and upload the code, like you would do with serial upload)
@MennoLauwerens
@MennoLauwerens 4 года назад
Just set these options in platformio.ini: board_build.partitions = min_spiffs.csv ; See:github.com/espressif/arduino-esp32/tree/master/tools/partitions ;upload_port = COM5 upload_protocol = espota upload_port = 192.168.0.35 ; IP of the ESP32 The rest is identical to this video.
@DailyCakeSlice
@DailyCakeSlice 4 года назад
@@MennoLauwerens That worked perfectly, thank you!
@hurterbe
@hurterbe 3 года назад
Hi. I loaded your basic example for OTA which includes the Telnet stream and I am only printing "Hallo World" in the loop. If I use the serial monitor while connected to the ESP32 directly I see my message but via Telnet I only get the message "42 Loop". What am I missing here? Am I not suppose to see the same message in Telnet as on the serial monitor?
@AndreasSpiess
@AndreasSpiess 3 года назад
Telnet shows you what you print in TelnetStream.println(micros()-entry); TelnetStream.println("Loop"); which is a number and "Loop"
@frollard
@frollard 4 года назад
Finally giving this a try...after un/reinstalling everything several times, debug shows Start updating sketch abort() was called at PC 0x40136e85 on core 1 backtrace, lots Rebooting... starting to think it must be a faulty board because I've got everything else going. Might just need to stick with USB.
@AndreasSpiess
@AndreasSpiess 4 года назад
Maybe they also changed something in the ESP32 infrastructure of the Arduino. I did not use it recently.
@frollard
@frollard 4 года назад
@@AndreasSpiess perhaps... I may need to try visual studio instead
@DavidtheSwarfer
@DavidtheSwarfer 2 года назад
Thanks, I have looked at several OTA videos now and none of them (so far) has explained how I now use my OTA enabled sketch to do the http client stuff I need doing. I have an existing sketch that uses emonlib to read a CT and then an http.get to send the values to my server. Can I just use my existing code and add the OTA to it without any other modifications?
@AndreasSpiess
@AndreasSpiess 2 года назад
Maybe you try it? I do not know if it works.
@DavidtheSwarfer
@DavidtheSwarfer 2 года назад
@@AndreasSpiess , I had to remove the wifimulti references and change the .run() to .status() to check for a connection, otherwise it is the same, the OTA sets up the connection and I can use it for the httpclient .get() calls that I need
@efimovv
@efimovv 4 года назад
Great video! But looks like Platform IO not work well in your work... About security: as I can understand, anybody with access to WiFi network can re-flash controller. How about password protected OTA, which I saw in some frameworks?
@AndreasSpiess
@AndreasSpiess 4 года назад
I think you can use a password here, too
@santopino2546
@santopino2546 4 года назад
can ArduinoOTA.handle() be cyclically called in it's own task so that we can forget all about it? I haven't used OTA yet, but I'm quire sure I will try it soon.
@AndreasSpiess
@AndreasSpiess 4 года назад
Maybe you look at the library now. It shouls be included throug an addition of a viewer
@robk5969
@robk5969 4 года назад
are there any OTA options for updating esps over ESPNOW? obviously you would need a programming esp plugged into the computer for that, but has it been done before?
@AndreasSpiess
@AndreasSpiess 4 года назад
I do not know
@JohnJCouture
@JohnJCouture 4 года назад
Andreas, great job! Works like a charm. is there a way to SET the upload IP address? The IPAddress command doesn't seem to work. I suspect it has to do with the placement of the IPAddress command?
@AndreasSpiess
@AndreasSpiess 4 года назад
The IP address is usually given by your network.
@PetRatty
@PetRatty 4 года назад
yes setting up ArduinoOTA.handle(); on core 0 is pretty simple, you then need nothing in loop, same goes for the basic udp example, use netcat for the debugger as it doesn't disconnect like putty, minicom is another but haven't tried it
@AndreasSpiess
@AndreasSpiess 4 года назад
I have tried it and it crashed. On both cores :-(
@creator4X6YS
@creator4X6YS 3 года назад
Hallo Andreas, why it has to be called frequently? What if I am going for one day into sleep mode and only when ising a GPIO I would like to use the OTA? Is this possible?
@AndreasSpiess
@AndreasSpiess 3 года назад
It has to be called often when the process is started. You can sleep as long as you want before that.
@StefanoZamprogno
@StefanoZamprogno 3 года назад
i think it is unusable for project that require ESP32 to be in deep sleep and wakeup every XXX minutes to make a task that does not require the loop() function since all the code sits on the setup() function... ?
@AndreasSpiess
@AndreasSpiess 3 года назад
See here, for example: community.platformio.org/t/ota-and-deepsleep-mode/7235
@collinsabraham8590
@collinsabraham8590 Год назад
Hello Andreas, thanks a lot for the tutorial, I am new to microcontrollers and I have a little question. Please is it possible to link the Esp32 to the python IDE over the air just as you've done, but in a way that it sends data from a sensor, directly to the IDE so that I can manipulate the data with other blocks of code within the IDE?
@AndreasSpiess
@AndreasSpiess Год назад
You can use MicroPython with the ESP32.
@brainfornothing
@brainfornothing 4 года назад
I have no idea of morse, but I tried to decypher that in 01:11 and I got "sex slu kh rx..." I must be tottally wrong, Hehehe ! Thank you for sharing !
@AndreasSpiess
@AndreasSpiess 4 года назад
True. You have to practice a little more. But your imagination seems to be ok ;-)
@nerukoma
@nerukoma 3 года назад
Hello, I get connection refused when SSH'ing to ESP32, any ideas how to solve it?
@AndreasSpiess
@AndreasSpiess 3 года назад
The ESP32 do not support SSH without you writing code to do so. www.arduino.cc/reference/en/libraries/libssh-esp32/
@browaruspierogus2182
@browaruspierogus2182 4 года назад
Using Arduino for OTA is like trusting a hacker to spare your system. It's more complicated than few lame lines of code
@AndreasSpiess
@AndreasSpiess 4 года назад
You are right
@altamiradorable
@altamiradorable 3 года назад
Halo Andreas ! Guten tag ! Question for you ! Can OTA sketch, library coexist in a project with mesh communication without interference ? Will this be too much for the scheduler ? Danke meine freund !
@AndreasSpiess
@AndreasSpiess 3 года назад
You have to try it. I am not sure how your mesh works.
@JesusCendejas-uv1xr
@JesusCendejas-uv1xr 3 года назад
we can save the library in the epprom memory ? with this form we don’t need to use the library because we have in the bootlouder
@AndreasSpiess
@AndreasSpiess 3 года назад
You can do a lot of things if you want. Current C++ architecture compiles and links the libraries into one bin file.
@davidrathbone6978
@davidrathbone6978 3 года назад
You missed the whole advantage of boot,ota1,ota2 partition structure if you code it correct you do not need to keep calling your .h code. Just make a software call when update is required.
@AndreasSpiess
@AndreasSpiess 3 года назад
You are right.
@ngobduong8066
@ngobduong8066 5 месяцев назад
anyone there have some experience with ESP32 ethernet using OTA ? I speed 1 week on it but got nothing
@AndreasSpiess
@AndreasSpiess 5 месяцев назад
I never tried it :-(
@Jungmin_Seo
@Jungmin_Seo 4 года назад
wow.. The code works flawlessly. Thanks!
@AndreasSpiess
@AndreasSpiess 4 года назад
You're welcome!
@wess7390
@wess7390 Год назад
I can't seem to get the sketch to show up when I put it in the library directory. I'm using Arduino IDE 2.1, is there a trick to this?
@AndreasSpiess
@AndreasSpiess Год назад
I do not understand what you expect. My example files belong into the sketch directory. From there you can open it with the Arduino IDE
@AnimilesYT
@AnimilesYT 2 года назад
1:12 I have no idea what you're saying there. My adhd/autistic brain just can't focus on your words ':)
@AndreasSpiess
@AndreasSpiess 2 года назад
:-))
@necrodrucifver
@necrodrucifver Год назад
I am going to experiment setting the handler on the setup, expecting been able to upload code only when the bard is rebooted, thank you! Very nice videos, please consider a video to code read protection on esp32
@AndreasSpiess
@AndreasSpiess Год назад
As I like open source I have no need for code protection ;-)
@azbukaChisel
@azbukaChisel 4 года назад
Arduino? Really? Do you think about going to esp-idf???
@AndreasSpiess
@AndreasSpiess 4 года назад
No. Most of my viewers use Arduino IDE and it iw not focussed on espressif
@teddavis1840
@teddavis1840 4 года назад
Grüezi Andreas, thanks for the many hours you devote to your viewers. I appreciate your dry humour very much. I tried to find if you have created any videos on motors and actuators without success. Monitoring & control systems would seem a natural progression to your sensor projects - LoRa especially. Hopp Schwiiz!
@kecsrobi6854
@kecsrobi6854 Год назад
What about FreeRTOS anf running the OTA in another thread/task ? Also does the Telnetstream thing support bidirectional transmissions? Asking since you can type in the serial and thous send data to the ESP, and I was wandering if this can also be done via WIFI? Lastly does this OTA solution interfere with other WOFI tasks? asking since in a way it should be top task priority when downloading and low when checking , I think. ?
@AndreasSpiess
@AndreasSpiess Год назад
Good questions. I never tried it in different tasks. I think OTA just quickly uses WiFi as any other task to check if a new version is available. Only if it needs to download a new version, it blocks the whole program and only comes back with a success (or a failure) message.
@kecsrobi6854
@kecsrobi6854 Год назад
@@AndreasSpiess I was thinking of the OTA in another task as a fix for long delays and long deep sleep programs , lets say pin 13 triggers the OTA task start and it will run a few times. Then again you will need a WIFI/BT mutex. maybe it is built in already .
@gkeepleft
@gkeepleft 12 дней назад
I'm guessing you can't use ota if you have bluetooth enabled?
@AndreasSpiess
@AndreasSpiess 3 дня назад
I do not know :-(
@wm6h
@wm6h 4 года назад
I think I may have found the original morsetrainer video. And evidence it may , in fact, be historic (“..and a RU-vid legend was born”) in the comments: github.com/SensorsIot/Morse-Trainer
@AndreasSpiess
@AndreasSpiess 4 года назад
Yes, you found it...
@wm6h
@wm6h 4 года назад
Andreas Spiess Great, I’ll build it. Will you be updating that git with your RTOS timing mods?
@AndreasSpiess
@AndreasSpiess 4 года назад
I am currently porting it to the ESP32 and RTOS.
@KarthickRobo
@KarthickRobo 4 года назад
nice it works
@AndreasSpiess
@AndreasSpiess 4 года назад
Good to hear!
@0124akash
@0124akash Год назад
Sir, How to see your videos in hindi language for proper understanding.
@AndreasSpiess
@AndreasSpiess Год назад
AFAIK you can select "automatic translation" for the subtitles
Далее
🎙Пою РЕТРО Песни💃
3:05:57
Просмотров 1,3 млн
I Took An iPhone 16 From A POSTER! 😱📱 #shorts
00:18
Bizzare Shifter
18:04
Просмотров 289 тыс.
This isn't a normal mini PC... and I love it.
14:17
Просмотров 330 тыс.