Browse Source

timing

tags/v0.1.0
Simon Schmidt 2 years ago
parent
commit
e10f061eb8
2 changed files with 27 additions and 3 deletions
  1. 2
    0
      README.md
  2. 25
    3
      src/main.cpp

+ 2
- 0
README.md View File

@@ -1,5 +1,7 @@
### Steps to run it

https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html

##### create "include/wifi_credentials.h"

```cpp

+ 25
- 3
src/main.cpp View File

@@ -98,11 +98,15 @@ void setup_webserver() {
}





void setup() {
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed! Rebooting...");
delay(5000);
@@ -112,10 +116,7 @@ void setup() {
// setup OTA
ArduinoOTA.setPort(8266);
ArduinoOTA.setHostname("ESP_Treppenlicht");

// No authentication by default
ArduinoOTA.setPassword("admin");

// Password can be set with it's md5 value as well
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
@@ -160,10 +161,31 @@ void setup() {
}

unsigned long i = 0;

unsigned long a = 0;
unsigned long s = 0;
float ard_ota_time = 0;
float server_handle = 0;

void loop() {
a = micros();
ArduinoOTA.handle();
ard_ota_time += micros()-a;
s = micros();
server.handleClient();
server_handle += micros()-s;

if(++i >= 10000) {
Serial.print("Mittlere Laufzeit\tOTA: ");
Serial.print(ard_ota_time/10000.0);
Serial.print("µs\tHTTP: ");
Serial.print(server_handle/10000.0);
Serial.println("µs");

ard_ota_time = 0;
server_handle = 0;
i = 0;
}
}

Loading…
Cancel
Save