It's been a while since I tried to do OTA updates on a board, but I pulled an older MKR1010 Wifi out of the drawer. I tried to find the ArduinoOTA Basic example, but don't see it in the list. So I loaded the Wifi101_OTA example from within the ArduinoOTA examples, and added my ssid & pass. Uploading the sketch to the MKR via USB, the Serial Monitor seems to indicate that it connects, it says the IP it's got, and when I check my router I can see it there. Cool!
But if I disconnect the MKR from my computer, and plug it into power only on the desk next to me, I can still see it on the router, so it should be there, but the Arduino IDE doesn't seem to have a "network ports" section, and instead just shows a greyed out "COM4" port.
What am I missing here?
IDE Ver. 2.3.6
Hi @Tumerboy. Unfortunately the discovery of the "network" protocol ports produced by the ArduinoOTA library can be quite finnicky. In the case where you are not able to get Arduino IDE to discover the port, you can use the workaround described here:
https://github.com/JAndrassy/ArduinoOTA#ota-upload-from-ide-without-network-port
Thanks. I had found that and was trying to decipher it but didn't make any real progress last night beyond finding the proper folder. I think what it's actually saying is to download the files from my_boards project, and then put those into the Arduino15 folderstructure?
I'll give it another go tonight. Either way, just knowing this is a common issue, and not something I screwed up, is helpful. Thanks.
That is one way to do it. However, I don't think it is ideal in this situation since the "my_boards" project only contains a board definition for the Arduino M0 board:
Even if the M0 is technically equivalent to the MKR WiFi 1010, I still think this could be confusing. So I will recommend the alternative approach of modifying the configuration of the "Arduino SAMD Boards (32-bits ARM Cortex-M0+)" platform that adds support to Arduino IDE for the MKR WiFi 1010. I'll provide instructions for that approach:
A. Add OTA Programmer to "Arduino SAMD Boards (32-bits ARM Cortex-M0+)" Platform
- If Arduino IDE is running, select File > Quit from the Arduino IDE menus.
All Arduino IDE windows will close.
- Open the file at the following path in any text editor:
C:\Users\<username>\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\programmers.txt
(where <username> is your Windows username)
If looking for it with your file manager or command line, note that the AppData folder is hidden by default. On Windows "File Explorer", you can make it visible by opening the "View" menu, then checking the box next to "☐ Hidden items".
- Add the following lines to the top of the file:
arduinoOTA1.name=ArduinoOTA
arduinoOTA1.program.tool=arduino_ota
arduinoOTA1.program.tool.default=arduino_ota
arduinoOTA1.program.ip=<IP address>
arduinoOTA1.program.password=password
- Replace the
<IP address> placeholder in line 3 with the IP address you see for the MKR WiFi 1010 in the Arduino IDE Serial Monitor, or in the router interface when the board is running the "Wifi101_OTA" example sketch.
For example, if it showed the IP address was 192.168.1.104, line 3 should look like:arduinoOTA1.program.ip=192.168.1.104
- If you modified the password for OTA uploads that is configured via the 3rd argument to the
ArduinoOTA.begin call in the "Wifi101_OTA" example sketch, replace the password value in line 4 with the password you set.
For example, if you have this line in the sketch program that is running on your MKR WiFi 1010:ArduinoOTA.begin(WiFi.localIP(), "Arduino", "correcthorsebatterystaple", InternalStorage);
line 4 should look like:arduinoOTA1.program.password=correcthorsebatterystaple
- Save the file.
- Create a new text file in the text editor.
- Add the following content to the new text file:
tools.arduino_ota.program.pattern="{cmd}" -address "{program.ip}" -port 65280 -username arduino -password "{program.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b {arduinoota.extraflags}
- Save the file with the name
platform.local.txt in the folder at the following path:C:\Users\<username>\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\programmers.txt
(where <username> is your Windows username)
B. Using the OTA Programmer
- Start Arduino IDE.
- Make sure the MKR WiFi 1010 is running the "Wifi101_OTA" example sketch and is powered.
- Open the sketch you want to upload to the MKR WiFi 1010 over the network.
Note that you must always implement the OTA upload capability (as is done in the "Wifi101_OTA" example) in each sketch you upload. If you don't, the sketch will upload and run as expected, but the next time you try to upload to the board, it will fail.
- Select Tools > Board > Arduino SAMD Boards (32-bits ARM Cortex-M0+) > Arduino MKR WiFi 1010 from the Arduino IDE menus.
- Select Tools > Reload Board Data from the Arduino IDE menus.
- Wait until a "Board data reloaded." notification appears at the bottom right corner of the Arduino IDE window.
- Select Tools > Programmer > ArduinoOTA from the Arduino IDE menus.
- Select Sketch > Upload Using Programmer from the Arduino IDE menus.
The sketch should now compile and upload over the network to the MKR WiFi 1010 successfully.
Are you using Windows? If so, mark your WiFi as a private network.
Thanks for this. This did get it working. . . ish. I was able to update OTA sometimes, at least. But it still seemed finnicky and prone to breakage. I seemed to have to bring the MKR back over to reinstall the base OTA program, then put it back out on wifi, and try updating with my actual code, sometimes.
In the end, I'm just frustrated with the process and broke out the 16' USB cable. I had been hoping to avoid it, but I'd rather get things done than futz with this more.
Thank you for the help tho.
I'm sorry you were not able to get it working reliably. If you decide to give it another try later, just let us know and we'll try to provide further assistance. Without any details, I could only make a guess that something in the program you uploaded to the board broke or interfered with the OTA capability provided by the library. This will cause the failure of subsequent uploads.
For example, it is essential that your code does not stop ArduinoOTA.poll from being called frequently. It is common for Arduino users to write "blocking" code (e.g., the use of delay) that prevents the frequent execution of the loop function.
Have you tried the older IDE version 1.8.19 ?
Version 2.x.x has a bug that makes at least some of the network ports not show up.
For me ESP32 boards show up, but ESP8266 boards don't for some reason, i don't know if that extends to the board you are using but i would say that it is at least worth a go and not much of a complicated thing to do. Just download and install the older IDE version and they can exist side by side.
Ah, yeah, that seems a likely culprit then. I might mess with it more, but the OTA update was just going to be a convenience, not a necessity.
I appreciate all the help regardless.
@Deva_Rishi, I haven't tried the older IDE, but I'll give that a go if @ptilliisch's point about delay() doesn't do the trick.