You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/ota_updates/ota_updates.md
+35Lines changed: 35 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ title: OTA Update
12
12
*[Application Example](#application-example)
13
13
*[Classic OTA](#classic-ota)
14
14
*[ArduinoOTA](#arduinoota)
15
+
*[Password Protection](#password-protection)
15
16
*[Troubleshooting](#troubleshooting)
16
17
*[Web Browser](#web-browser)
17
18
*[Requirements](#requirements-1)
@@ -228,6 +229,40 @@ IP address: 192.168.1.100
228
229
**Note:** To be able to upload your sketch over and over again using OTA, you need to embed OTA routines inside. Please use BasicOTA.ino as an example.
229
230
230
231
232
+
#### Password Protection
233
+
234
+
Protecting your OTA uploads with password is really straightforward. All you need to do, is to include the following statement in your code:
235
+
236
+
```cpp
237
+
ArduinoOTA.setPassword((constchar *)"123");
238
+
239
+
```
240
+
241
+
Where ``` 123 ``` is a sample password that you should replace with your own.
242
+
243
+
Before implementing it in your sketch, it is a good idea to check how it works using *BasicOTA.ino* sketch available under *File > Examples > ArduinoOTA*. Go ahead, open *BasicOTA.ino*, uncomment the above statement that is already there, and upload the sketch. To make troubleshooting easier, do not modify example sketch besides what is absolutely required. This is including original simple ``` 123 ``` OTA password. Then attempt to upload sketch again (using OTA). After compilation is complete, once upload is about to begin, you should see prompt for password as follows:
244
+
245
+

246
+
247
+
Enter the password and upload should be initiated as usual with the only difference being ``` Authenticating...OK ``` message visible in upload log.
248
+
249
+

250
+
251
+
You will not be prompted for a reentering the same password next time. Arduino IDE will remember it for you. You will see prompt for password only after reopening IDE, or if you change it in your sketch, upload the sketch and then try to upload it again.
252
+
253
+
Please note, it is possible to reveal password entered previously in Arduino IDE, if IDE has not been closed since last upload. This can be done by enabling *Show verbose output during: upload* in *File > Preferences* and attempting to upload the module.
254
+
255
+

256
+
257
+
The picture above shows that the password is visible in log as it is passed to *espota.py* upload script.
258
+
259
+
Another example below shows situation when password is changed between uploads.
260
+
261
+

262
+
263
+
When uploading, Arduino IDE used previously entered password, so the upload failed and that has been clearly reported by IDE. Only then IDE prompted for a new password. That was entered correctly and second attempt to upload has been successful.
264
+
265
+
231
266
#### Troubleshooting
232
267
233
268
If OTA update fails, first step is to check for error messages that may be shown in upload window of Arduino IDE. If this is not providing any useful hints try to upload again while checking what is shown by ESP on serial port. Serial Monitor from IDE will not be useful in that case. When attempting to open it, you will likely see the following:
0 commit comments