add wemos d1 mini
This commit is contained in:
parent
fb80090d1b
commit
e7a3953b22
|
@ -14,5 +14,5 @@ do
|
||||||
printf "%c" "."
|
printf "%c" "."
|
||||||
done
|
done
|
||||||
printf "\n%s\n" "Device is online"
|
printf "\n%s\n" "Device is online"
|
||||||
pio run -t upload --upload-port $1
|
pio run -t upload -e d1_mini-ota --upload-port $1
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
|
||||||
[env:lolin32]
|
[env:lolin32]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = lolin32
|
board = lolin32
|
||||||
|
@ -15,5 +16,47 @@ framework = arduino
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
|
|
||||||
|
|
||||||
|
build_flags =
|
||||||
|
-D ESP32
|
||||||
|
|
||||||
|
[env:lolin32-ota]
|
||||||
|
platform = espressif32
|
||||||
|
board = lolin32
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
upload_speed = 921600
|
||||||
|
upload_protocol = espota
|
||||||
|
|
||||||
|
build_flags =
|
||||||
|
-D ESP32
|
||||||
|
|
||||||
|
upload_flags =
|
||||||
|
--auth=MCH2022OTA
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[env:d1_mini]
|
||||||
|
platform = espressif8266
|
||||||
|
board = d1_mini
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
upload_speed = 921600
|
||||||
|
|
||||||
|
build_flags =
|
||||||
|
-D ESP8266
|
||||||
|
|
||||||
|
[env:d1_mini-ota]
|
||||||
|
platform = espressif8266
|
||||||
|
board = d1_mini
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
upload_speed = 921600
|
||||||
|
upload_protocol = espota
|
||||||
|
|
||||||
|
|
||||||
|
build_flags =
|
||||||
|
-D ESP8266
|
||||||
|
|
||||||
upload_flags =
|
upload_flags =
|
||||||
--auth=MCH2022OTA
|
--auth=MCH2022OTA
|
|
@ -19,13 +19,16 @@ void setup() {
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
if (loopOTA()) {
|
if (loopOTA()) {
|
||||||
|
#ifndef OTA_CONTINUOUS
|
||||||
return; //just wait for ota
|
return; //just wait for ota
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long last_print=0;
|
static unsigned long last_print=0;
|
||||||
if (millis()-last_print>1000) {
|
if (millis()-last_print>1000) {
|
||||||
last_print=millis();
|
last_print=millis();
|
||||||
Serial.println("Loop");
|
Serial.print("Loop ");
|
||||||
|
Serial.println(last_print);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,7 @@ bool initOTA() {
|
||||||
|
|
||||||
ArduinoOTA.setPassword((const char *)OTA_PASSWORD);
|
ArduinoOTA.setPassword((const char *)OTA_PASSWORD);
|
||||||
|
|
||||||
ArduinoOTA
|
ArduinoOTA.onStart([]() {
|
||||||
.onStart([]() {
|
|
||||||
otaMode = UPDATING;
|
otaMode = UPDATING;
|
||||||
String type;
|
String type;
|
||||||
if (ArduinoOTA.getCommand() == U_FLASH)
|
if (ArduinoOTA.getCommand() == U_FLASH)
|
||||||
|
@ -47,16 +46,16 @@ bool initOTA() {
|
||||||
|
|
||||||
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
|
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
|
||||||
Serial.println("Start updating " + type);
|
Serial.println("Start updating " + type);
|
||||||
})
|
});
|
||||||
.onEnd([]() {
|
ArduinoOTA.onEnd([]() {
|
||||||
Serial.println("\nEnd");
|
Serial.println("\nEnd");
|
||||||
})
|
});
|
||||||
.onProgress([](unsigned int progress, unsigned int total) {
|
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||||
int prog = (progress / (total / 100));
|
int prog = (progress / (total / 100));
|
||||||
Serial.printf("Progress: %u%%\r", prog);
|
Serial.printf("Progress: %u%%\r", prog);
|
||||||
|
|
||||||
})
|
});
|
||||||
.onError([](ota_error_t error) {
|
ArduinoOTA.onError([](ota_error_t error) {
|
||||||
Serial.printf("Error[%u]: ", error);
|
Serial.printf("Error[%u]: ", error);
|
||||||
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
|
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
|
||||||
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
|
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
|
||||||
|
@ -77,6 +76,8 @@ bool loopOTA() {
|
||||||
if (otaMode != NONE) {
|
if (otaMode != NONE) {
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef OTA_CONTINUOUS
|
||||||
if(otaMode == WAITING) {
|
if(otaMode == WAITING) {
|
||||||
static long mil = millis();
|
static long mil = millis();
|
||||||
static boolean huehott = false;
|
static boolean huehott = false;
|
||||||
|
@ -92,6 +93,7 @@ bool loopOTA() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,14 +2,24 @@
|
||||||
#define simpleota_h
|
#define simpleota_h
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#ifdef ESP32
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ESP8266
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <ESP8266mDNS.h>
|
||||||
|
#include <WiFiUdp.h>
|
||||||
|
#include <ArduinoOTA.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define OTA_WIFI_SSID "Chaos-West temp alternative"
|
#define OTA_WIFI_SSID "ssid"
|
||||||
#define OTA_WIFI_PASSWORD ""
|
#define OTA_WIFI_PASSWORD "password"
|
||||||
#define OTA_WAIT_TIMEOUT 20 // in 0.1s increments -> 10s
|
#define OTA_WAIT_TIMEOUT 100
|
||||||
#define OTA_PASSWORD "MCH2022OTA" //password needed for ota flashing
|
#define OTA_PASSWORD "MCH2022OTA"
|
||||||
|
|
||||||
|
#define OTA_CONTINUOUS
|
||||||
|
|
||||||
void checkOTA();
|
void checkOTA();
|
||||||
bool initOTA();
|
bool initOTA();
|
||||||
|
|
Loading…
Reference in New Issue