Step by step guide
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.5KB

2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. # step by step guide
  2. __start with [ArduinoOTA basic example](https://github.com/esp8266/Arduino/blob/master/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino)__
  3. ```cpp
  4. void setup() {
  5. WiFi.mode(WIFI_STA);
  6. WiFi.begin(ssid, password);
  7. while (WiFi.waitForConnectResult() != WL_CONNECTED) {
  8. delay(5000);
  9. ESP.restart(); /* reload application */
  10. }
  11. /* register callbacks for OTA events */
  12. ArduinoOTA.onStart([]() { /* ... */ });
  13. ArduinoOTA.onEnd ([]() { /* ... */ });
  14. ArduinoOTA.onError([](ota_error_t error) { /* ... */ });
  15. /* setup OTA for listening on default UDP-port 8266 */
  16. ArduinoOTA.begin();
  17. }
  18. void loop() {
  19. /* check for incoming OTA update */
  20. ArduinoOTA.handle();
  21. }
  22. ```
  23. ___
  24. modify __platformio.ini__
  25. ```ini
  26. ; example platformio.ini
  27. [env:esp01_1m]
  28. platform = espressif8266
  29. board = esp01_1m
  30. framework = arduino
  31. upload_port = COM6
  32. monitor_speed = 74880
  33. ```
  34. ___
  35. __open serial port to esp8266 and reset__
  36. ```bash
  37. # example output after reset
  38. ets Jan 8 2013,rst cause:2, boot mode:(3,7)
  39. # load binary
  40. load 0x4010f000, len 3460, room 16
  41. tail 4
  42. chksum 0xcc
  43. load 0x3fff20b8, len 40, room 4
  44. tail 4
  45. chksum 0xc9
  46. csum 0xc9
  47. v00040b70
  48. ~ld
  49. ```
  50. ___
  51. __Boot Messages and Modes, see also [detailed documentation](https://github.com/esp8266/Arduino/blob/master/doc/boards.rst)__
  52. at startup the ESP prints out the current boot mode example:
  53. ```
  54. rst cause:2, boot mode:(3,6)
  55. ```
  56. | rst cause| Description |
  57. |----------|------------------|
  58. | 0 | unknown |
  59. | 1 | normal boot |
  60. | 2 | reset pin |
  61. | 3 | software reset |
  62. | 4 | watchdog reset |
  63. ```
  64. boot mode:(x,y)
  65. ```
  66. | x | GPIO15 | GPIO0 | GPIO2 | Mode |
  67. |----------|----------|---------|---------|-------------|
  68. | 1 | 0V | 0V | 3.3V | Uart |
  69. | 3 | 0V | 3.3V | 3.3V | Flash |
  70. __note:__ __y__ represents the position of the boot file
  71. ___
  72. __Upload compiled binary via uart__
  73. __note__: close serial port
  74. ```bash
  75. $ pio run -t upload
  76. # or use upload button in vscode
  77. ```
  78. __open serial port to esp8266 and check Wi-Fi connection__
  79. monitor output:
  80. ```bash
  81. Ready
  82. IP address: 192.168.10.108
  83. ```
  84. __modify platformio.ini accordingly__
  85. ```ini
  86. ; new platformio.ini for OTA
  87. [env:esp01_1m]
  88. platform = espressif8266
  89. board = esp01_1m
  90. framework = arduino
  91. upload_protocol = espota
  92. upload_port = 192.168.10.108
  93. monitor_speed = 74880
  94. ```
  95. ___
  96. Process of updating
  97. ![ota flash layout](ota_flash.png)
  98. code for updating