How to fix ArduinOTA issues

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to a new video in my home automation series and today i want to talk about arduino ota and how you can make this work and if you are looking at this video you probably have tried arduino ota and for some reason it doesn't work on your sketch well if it works on your sketch well happy for you but i wanted to explain what was the issue for me and it took me well quite a lot of testing and reading and trying to actually figure out what has gone wrong so i want to talk about a couple of different things um here in this video the first one is what you should do or what you can try if you included the arduino ota in your sketch but you don't see the network port because that could be an issue so that is something in the arduino ide the other thing is what you should do or what will be what are the issues when you are trying to do an update but you are getting uh different messages so you could be getting a message which says no response from the device and that message is probably related to firewall settings so for example for me even though i created a custom rule in my firewall that it should allow these ota traffic through it is not doing that so what i ended up doing is actually i disable the firewall just for the time well just for the period when i do this uh update i probably need to you know do some more tweaking on my firewall to to you know fine-tune that rules because you know disabling the firewall has the issue that you know what happens if you don't um enable it back and of course while the firewall is disabled so that shouldn't really happen so that's one of the issue and that was another similar problem is um i was also getting an error message which said no answer so here he came back with a message no answer and that that was an issue related to the fact that the arduino ota actually started but during the ota process the esp short dumped and that issue was related to the fact that in my code the arduino or the esp was doing an interrupt timer interrupt so when the ota was happening it was also doing some of my code and that basically caused the conflict and i could resolve this issue by disabling the timer when the ota starts and re-enabling it when the ota ends and with this small modification the ota started working for me so first of all let's talk about what happens if you don't see this network board um well it could be many different reasons i've read post where somebody said they just reinstalled the arduino ota ide and it started working for me the issue was that in my house i have a couple of different routers just because one doesn't have enough wi-fi coverage and i don't have some fences set up basically i just have the main router which is provided by by my isp and in the garage i have a separate one which is configured as a bridge but still works as an access point so i can see the traffic and there is there is no separate subnet on the other wi-fi router but it just creates a different ssid and a password and what seems to be the issue is that the devices that are connected to the other router they don't appear in the network board so what i what i did as a workaround is um whenever i want to do ota i just change my wifi settings so i connect to that router with my laptop as well and then all of a sudden these devices all you know show up in the network board and again it might depend on the on on your router you might have a separate setup you don't have this issue sometimes you can have this issue if you have a separate router for 5 gigahertz and 2.4 gigahertz the esps are obviously connected to 2.4 gigahertz so again you should be using the same wi-fi network as your esp devices if you have this type of issues so these are the things that you should you know try out if you are not seeing your devices the next issue as i said is when you get a no response from remote message when you try to do so what you know once you see the network board you select it you um you know click on upload and you see or you get a no response from device but based on the different discussions that is most probably a firewall issue as i said um i tried setting up some special rules in my firewall but it didn't help so what i'm doing for the time while for the period when i i'm doing the sketch updates i disable my firewall and i upload and then i re-enable the firewall just make sure that you re-enable the firewall the other thing uh you can do i mean you know if you want to set up this fireball rules properly then what you can do is if you look at the sketch how the arduino ota looks like there is a definition here which is in the stand in the example it's commented out which is setting the port for the ota and by default it's 8266 so you can change it to a random port and then configure that in your firewall rules just make sure that all of your arduino ota sketch uses the same board or you configure port 8266 and the third issue is when you are getting a message here you see it says no response from device so that's what i just mentioned but sometimes you get a message which says no answer and i was getting these messages and then as i said the issue well the reason or sorry the root cause of that message was that when the ota started actually my esp sure dumped and there is a way how to find this out and as you can see uh i'm doing that right here now so the way for you to check what your esp is doing when it's doing the ota is you go into tools and in the board definition you select the debug level um actually you set it to ota and you see selected the debug port of serial and then one you know when you open up the serial monitor you will see messages you you see your regular messages but you also see messages that are sent by the um by the debug level so for example you know these state changes is not something that is included in my code but it is there because of the uh of the debug level so your your set your code and you know your sketch to this debug level and the port and then you flash it using the port so you flash a version which creates all these extra debug messages and then you use a a terminal program which is not arduino id which is not the arduino so for example you do putty oops i did twice and then com port it's com9 for me and you you can change the speed i mean i usually set 115 200 and you open and then you use this to monitor the your esp i mean your esp at this point is still connected to you using you know just a usb cable and now you can initiate an ota using arduino id but now in this time the port the network port so you just basically do whatever you normally do you upload and then you also monitor in the com port and what you should see is um i mean normally what you will see is that the sketch is getting uploaded here but you also see the progress in the com port as well so in the serial monitor as well so this is how it should look like and what i noticed previously is that whenever the progress started or in between the progress my esp was short dumping and that's the only way you can see this if you are you know monitoring it externally not from the arduino ide and then reading different issues on github i realized that the reason this is the short amp is happening because uh i have an even callback in my code so i created a timer while i actually i'm using this timer in most of my esp codes and if you haven't used a timer it is really easy to set up because you create a function in this style well in my case i've created a function called timer callback and i set up this well as specified this function for this timer or and then i armed the timer saying that it should call this callback function every 1000 milliseconds so all i needed to do is i needed to go back to my code above where i do the ota definition or actually the ota even callbacks and so on the arduino ota onstart uh by default it just says serial print start and i included this line so os timer disarm and and end my timer so i disarm the timer when the ota starts and then when the ota finishes i just restart the timer to you know whatever was before whatever i normally have it in the setup so technically you know when the ota happens i don't want esp to do anything what you know timer and processor related so this is all i had to do and how do you know ota started running and since we talked about the arduino ota i just wanted to add a few of my comments and how i'm using it at the moment so first of all i don't know if it really makes any difference or not but in one of the issues they said that the arduino ota definition should be right after the wi-fi setup so the wi-fi connection so previously i had it further down in the code so i just moved it above so you know wherever i have all the wi-fi begin and you know checking that i'm connected to the wi-fi i set up the ota right in the beginning so first is i already talked about the port so you know maybe you can just pick a different port other than the default 8266 so you can just have you know that setting the firewall settings uh by the way since we are talking about a firewall i think i've done testing so i'm just going to re-enable my firewall also you have these hostname for the arduino ota and by default it's going to esp8266 and a chip id and you know that is fine but if you have multiple devices then you wouldn't really tell you know which one is which so what you can set you can set it to just a fixed value but if you have multiple esp devices that are going to be running the same firmware what i have done i've created this few lines of code which is going to use a client id which i usually define in the in the global variables uh because i'm using that client id for the mqtt client id as well and i just add the last couple of digits from the mac id so and that's what i set in the hostname so if you look at the system you can see that my um you know port is now called the current so that's the client id and then you know b5 a c sorry 8c so again if i'm using multiple of these then i would say you know current something and then current something but if i have another sketch that would be you know something else so it just makes it easier to identify the different devices you don't have multiple devices with the same name so i think that is helpful as well and of course something which i haven't done in this particular code as well but probably it's a good idea that you also set a password for the ota so once you set up a password and you click on upload once it goes to the actual upload then it's going to ask for the password so that could also prevent accidental firmware update so i think that would be all for today it was a good learning for me but at least i know how to use arduino ota when you are also using timers in your esp code thanks for watching and hopefully see you in the next video
Info
Channel: Csongor Varga
Views: 2,500
Rating: undefined out of 5
Keywords: arduinota, over the air update, update, sketch, arduino ide, firewall, programming, esp8266, esp32
Id: z_btZfxrS48
Channel Id: undefined
Length: 13min 20sec (800 seconds)
Published: Sun Nov 28 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.