Advertisement
pleasedontcode

ESP32 OTA code

Aug 6th, 2024
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 0.67 KB | Source Code | 0 0
  1. #include <WiFi.h>
  2. #include <ArduinoOTA.h>
  3.  
  4. const char* ssid = "Your_SSID";
  5. const char* password = "Your_PASSWORD";
  6.  
  7. void setup() {
  8.   Serial.begin(115200);
  9.  
  10.   // Connect to Wi-Fi
  11.   WiFi.begin(ssid, password);
  12.   while (WiFi.status() != WL_CONNECTED) {
  13.     delay(1000);
  14.     Serial.println("Connecting to WiFi...");
  15.   }
  16.   Serial.println("Connected to WiFi");
  17.  
  18.   // Start OTA
  19.   ArduinoOTA.begin();
  20.   Serial.println("OTA Ready");
  21.  
  22.   // Optional: Set Hostname and Password
  23.   // ArduinoOTA.setHostname("esp32-ota");
  24.   // ArduinoOTA.setPassword("admin");
  25. }
  26.  
  27. void loop() {
  28.   // Handle OTA Updates
  29.   ArduinoOTA.handle();
  30.  
  31.   // Your code here (e.g., blink an LED)
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement