# step by step guide __start with [ArduinoOTA basic example](https://github.com/esp8266/Arduino/blob/master/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino)__ ```cpp void setup() { WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.waitForConnectResult() != WL_CONNECTED) { delay(5000); ESP.restart(); /* reload application */ } /* register callbacks for OTA events */ ArduinoOTA.onStart([]() { /* ... */ }); ArduinoOTA.onEnd ([]() { /* ... */ }); ArduinoOTA.onError([](ota_error_t error) { /* ... */ }); /* setup OTA for listening on default UDP-port 8266 */ ArduinoOTA.begin(); } void loop() { /* check for incoming OTA update */ ArduinoOTA.handle(); } ``` ___ modify __platformio.ini__ ```ini ; example platformio.ini [env:esp01_1m] platform = espressif8266 board = esp01_1m framework = arduino upload_port = COM6 monitor_speed = 74880 ``` ___ __open serial port to esp8266 and reset__ ```bash # example output after reset ets Jan 8 2013,rst cause:2, boot mode:(3,7) # load binary load 0x4010f000, len 3460, room 16 tail 4 chksum 0xcc load 0x3fff20b8, len 40, room 4 tail 4 chksum 0xc9 csum 0xc9 v00040b70 ~ld ``` ___ __Boot Messages and Modes, see also [detailed documentation](https://github.com/esp8266/Arduino/blob/master/doc/boards.rst)__ at startup the ESP prints out the current boot mode example: ``` rst cause:2, boot mode:(3,6) ``` | rst cause| Description | |----------|------------------| | 0 | unknown | | 1 | normal boot | | 2 | reset pin | | 3 | software reset | | 4 | watchdog reset | ``` boot mode:(x,y) ``` | x | GPIO15 | GPIO0 | GPIO2 | Mode | |----------|----------|---------|---------|-------------| | 1 | 0V | 0V | 3.3V | Uart | | 3 | 0V | 3.3V | 3.3V | Flash | __note:__ __y__ represents the position of the boot file ___ __Upload compiled binary via uart__ __note__: close serial port ```bash $ pio run -t upload # or use upload button in vscode ``` __open serial port to esp8266 and check Wi-Fi connection__ monitor output: ```bash Ready IP address: 192.168.10.108 ``` __modify platformio.ini accordingly__ ```ini ; new platformio.ini for OTA [env:esp01_1m] platform = espressif8266 board = esp01_1m framework = arduino upload_protocol = espota upload_port = 192.168.10.108 monitor_speed = 74880 ``` ___ Process of updating ![ota flash layout](ota_flash.png) code for updating