Advertisement
mikroavr

update_ota

Jan 17th, 2023
1,196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   Rui Santos
  3.   Complete project details
  4.    - Arduino IDE: https://RandomNerdTutorials.com/esp32-ota-over-the-air-arduino/
  5.    - VS Code: https://RandomNerdTutorials.com/esp32-ota-over-the-air-vs-code/
  6.  
  7.   This sketch shows a Basic example from the AsyncElegantOTA library: ESP32_Async_Demo
  8.   https://github.com/ayushsharma82/AsyncElegantOTA
  9. */
  10.  
  11. #include <Arduino.h>
  12. #include <WiFi.h>
  13. #include <AsyncTCP.h>
  14. #include <ESPAsyncWebServer.h>
  15. #include <AsyncElegantOTA.h>
  16.  
  17. const char* ssid = "REPLACE_WITH_YOUR_SSID";
  18. const char* password = "REPLACE_WITH_YOUR_PASSWORD";
  19.  
  20. AsyncWebServer server(80);
  21.  
  22. void setup(void) {
  23.   Serial.begin(115200);
  24.   WiFi.mode(WIFI_STA);
  25.   WiFi.begin(ssid, password);
  26.   Serial.println("");
  27.  
  28.   // Wait for connection
  29.   while (WiFi.status() != WL_CONNECTED) {
  30.     delay(500);
  31.     Serial.print(".");
  32.   }
  33.   Serial.println("");
  34.   Serial.print("Connected to ");
  35.   Serial.println(ssid);
  36.   Serial.print("IP address: ");
  37.   Serial.println(WiFi.localIP());
  38.  
  39.   server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
  40.     request->send(200, "text/plain", "Hi! I am ESP32.");
  41.   });
  42.  
  43.   AsyncElegantOTA.begin(&server);    // Start ElegantOTA
  44.   server.begin();
  45.   Serial.println("HTTP server started");
  46. }
  47.  
  48. void loop(void) {
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement