From 90c9b6022122d696841814a80f309816e975db87 Mon Sep 17 00:00:00 2001 From: iansun2 Date: Sat, 8 Apr 2023 02:47:05 +0800 Subject: [PATCH] OTA support --- platformio.ini | 10 ++++++++++ src/main.cpp | 20 ++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/platformio.ini b/platformio.ini index 59f9dd4..2610293 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,4 +15,14 @@ framework = arduino lib_deps = ottowinter/ESPAsyncWebServer-esphome@^3.0.0 board_build.filesystem = littlefs upload_speed = 921600 +monitor_speed = 115200 + +[env:nodemcuv2_OTA] +platform = espressif8266 +board = nodemcuv2 +framework = arduino +lib_deps = ottowinter/ESPAsyncWebServer-esphome@^3.0.0 +board_build.filesystem = littlefs +upload_protocol = espota +upload_port = 192.168.4.1 monitor_speed = 115200 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 0c0a963..9dd5a25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include /*===== Define =====*/ /*[const]*/ @@ -10,11 +11,11 @@ /*[pin]*/ #define HEAT_GUN_FAN_PIN D2 -#define HEATER1_PIN D4 -#define HEATER2_PIN D4 -#define CONNECTION_LED_PIN D0 -#define HEATER1_LED_PIN D0 -#define HEATER2_LED_PIN D0 +#define HEATER1_PIN D0 +#define HEATER2_PIN D5 +#define CONNECTION_LED_PIN D5 +#define HEATER1_LED_PIN D4 +#define HEATER2_LED_PIN D5 #define HEATER1_THERMISTOR_PIN A0 #define HEATER2_THERMISTOR_PIN A0 @@ -210,6 +211,7 @@ void setup() { server.on("/main.css", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(LittleFS, "/main.css", "text/css"); }); //main css server.begin(); + ArduinoOTA.begin(); //ticker temp_reporter.attach(0.5, temp_report_handler); @@ -217,7 +219,9 @@ void setup() { } void loop() { - temp1_current = rand()%100; - temp2_current = rand()%100; - delay(100); + //temp1_current = rand()%100; + //temp2_current = rand()%100; + //delay(100); + ws.cleanupClients(); + ArduinoOTA.handle(); } \ No newline at end of file