Closed Fyfth closed 4 months ago
for
loop for(;;);
in your code.Thanks! I figured it out. The problem was the for(;;) Thx
On Fri, Jul 19, 2024 at 14:06 Ayush Sharma @.***> wrote:
- There's an infinite for loop for(;;); in your code.
- Have you tried ElegantOTA bare example without any modifications? If that works well, then it's probably something in your code messing up WiFi connections. Honestly, ElegantOTA doesn't have anything to do with WiFi connection.
- You can try using NetWizard https://github.com/ayushsharma82/NetWizard - It will handle the WiFi connections and setup for you.
— Reply to this email directly, view it on GitHub https://github.com/ayushsharma82/ElegantOTA/issues/209#issuecomment-2239830107, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2CKBGVHJTWBSYLYOHRYOOLZNFISZAVCNFSM6AAAAABLE3JYASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZZHAZTAMJQG4 . You are receiving this because you authored the thread.Message ID: @.***>
ESP 32 C6
Code: /*
ElegantOTA - Demo Example
Skill Level: Beginner
This example provides with a bare minimal app with ElegantOTA functionality.
Github: https://github.com/ayushsharma82/ElegantOTA WiKi: https://docs.elegantota.pro
Works with following hardware:
RP2040 (with WiFi) (Example: Raspberry Pi Pico W)
Important note for RP2040 users:
If using bare RP2040, it requires WiFi module like Pico W for ElegantOTA to work.
Upgrade to ElegantOTA Pro: https://elegantota.pro
*/
if defined(ESP8266)
include
include
include
elif defined(ESP32)
include
include
include
elif defined(TARGET_RP2040)
include
include
endif
include
const char ssid = "1"; const char password = "12345678"; int S1= 4; int S2=5;
if defined(ESP8266)
ESP8266WebServer server(80);
elif defined(ESP32)
WebServer server(80);
elif defined(TARGET_RP2040)
WebServer server(80);
endif
unsigned long ota_progress_millis = 0;
void onOTAStart() { // Log when OTA has started Serial.println("OTA update started!"); //
}
void onOTAProgress(size_t current, size_t final) { // Log every 1 second if (millis() - ota_progress_millis > 1000) { ota_progress_millis = millis(); Serial.printf("OTA Progress Current: %u bytes, Final: %u bytes\n", current, final); } }
void onOTAEnd(bool success) { // Log when OTA has finished if (success) { Serial.println("OTA update finished successfully!"); } else { Serial.println("There was an error during OTA update!"); } //
}
void setup(void) { Serial.begin(115200); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); Serial.println(""); pinMode(S1, OUTPUT); pinMode(S2,OUTPUT);
// Wait for connection while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP());
server.on("/", []() { server.send(200, "text/plain", "Hi! This is ElegantOTA Demo."); });
ElegantOTA.begin(&server); // Start ElegantOTA // ElegantOTA callbacks ElegantOTA.onStart(onOTAStart); ElegantOTA.onProgress(onOTAProgress); ElegantOTA.onEnd(onOTAEnd);
server.begin(); Serial.println("HTTP server started"); }
void loop(void) { server.handleClient(); ElegantOTA.loop(); for (int i = 0; i <= 3; i++) { digitalWrite(S1, HIGH);// Solenoid is effective digitalWrite(S2, LOW);// Solenoid is effective delay(350); digitalWrite(S1, LOW);// Solenoid is effective digitalWrite(S2, HIGH);// Solenoid is effective delay(400); digitalWrite(S1, HIGH);// Solenoid is effective digitalWrite(S2, LOW);// Solenoid is effective delay(350); digitalWrite(S1, LOW);// Solenoid is effective digitalWrite(S2, HIGH);// Solenoid is effective delay(400); } digitalWrite(S1, LOW);// Solenoid is effective digitalWrite(S2, LOW);// Solenoid is effective
for(;;);
}