From 32069f042407408c2dbe5b607eef9a0c90eaa229 Mon Sep 17 00:00:00 2001 From: Luis Rodil-Fernandez Date: Tue, 15 Feb 2022 01:13:54 +0100 Subject: [PATCH] improved the calibration process --- src/atomizer.h | 11 ++++++----- src/main.cpp | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/atomizer.h b/src/atomizer.h index 5dd73cc..4d02689 100644 --- a/src/atomizer.h +++ b/src/atomizer.h @@ -32,26 +32,27 @@ class Atomizer { void calibrate() { int reading; - float s; - int i, j; + int wait = 200; LOG("Calibrating atomizer actuation..."); LOG_NEW_LINE - for(i = 0; i < 5; i++) { + for(int i = 1; i < 5; i++) { LOG("Calibration loop "); LOG(i); LOG_NEW_LINE // do some readings on current state - for(int i = 0; i < 10; i++) { + for(int j = 0; j < 10; j++) { reading = analogRead(pinSensor); minmax.put( reading ); + delay(wait); } toggle(); // change state // do some more readings - for(int i = 0; i < 10; i++) { + for(int k = 0; k < 10; k++) { reading = analogRead(pinSensor); minmax.put( reading ); + delay(wait); } toggle(); // change state again diff --git a/src/main.cpp b/src/main.cpp index cc67a71..c76a253 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,7 @@ #include + +#define LOG_ENABLED + #include #include #include @@ -49,12 +52,12 @@ void setup() { Serial.println("Brace! Brace! trying to continue without wifi..."); } - fog.calibrate(); - mqtt_init(); Serial.println("Initializing DHT sensor..."); dht.begin(); + + fog.calibrate(); } void dht_report_reading(tDHTReading &r) {