flow sensor calibration

This commit is contained in:
interfisch 2023-05-03 02:55:12 +02:00
parent fe6d4e98fa
commit 3f62820e22
2 changed files with 44 additions and 6 deletions

View File

@ -20,7 +20,7 @@ void flow_setup() {
} }
void flow_loop(unsigned long loopmillis) { void flow_loop(unsigned long loopmillis) {
if (loopmillis>=last_read_flow+READINTERVAL_FLOW) { if (loopmillis>=last_read_flow+READINTERVAL_FLOW) {
flow=flow_counter*1000.0/(loopmillis-last_read_flow)/2.0; //Frequency [Hz] flow=flow_counter*1000.0/(loopmillis-last_read_flow)/2.0; //Frequency [Hz]
flow/=flow_factor; //[L/min] flow/=flow_factor; //[L/min]

View File

@ -85,18 +85,19 @@ void loop() {
flag_print=false; flag_print=false;
ec_loop(loopmillis);
//ec_loop(loopmillis);
temperature_loop(loopmillis); //temperature_loop(loopmillis);
waterlevel_loop(loopmillis); //waterlevel_loop(loopmillis);
flow_loop(loopmillis); flow_loop(loopmillis);
sm_loop(loopmillis); //sm_loop(loopmillis);
static bool getReading=false; static bool getReading=false;
@ -108,8 +109,42 @@ void loop() {
digitalWrite(PIN_LED,HIGH); digitalWrite(PIN_LED,HIGH);
} }
static bool started=false;
static bool ended=false;
static unsigned long started_time=0;
static unsigned long ended_time=0;
if (loopmillis>last_print+2000) {
if (flow_counter_sum>10 && !started && !ended) { //start
started=true;
started_time=millis();
Serial.println("Started!");
}
static uint32_t last_flow_counter_sum=0;
if (loopmillis>last_print+1000) { //test check
last_print=loopmillis;
if (started && !ended) {
Serial.println(flow_counter_sum-last_flow_counter_sum);
if (flow_counter_sum-last_flow_counter_sum<=2){ //stopped
ended=true;
ended_time=millis();
Serial.println("Ended!");
}
last_flow_counter_sum=flow_counter_sum;
}
if (ended) {
Serial.println("counts,time");
Serial.print(flow_counter_sum);
Serial.print(",");
Serial.print((ended_time-started_time)/1000.0);
Serial.println();
delay(10000);
}
}
if (loopmillis>last_print+2000 && 1==2) {
//if (ec_flag_measurement_available && getReading) { //if (ec_flag_measurement_available && getReading) {
if (ec_flag_measurement_available) { if (ec_flag_measurement_available) {
last_print=loopmillis; last_print=loopmillis;
@ -119,6 +154,7 @@ void loop() {
Serial.print(millis()/1000.0,2); Serial.print(","); Serial.print(millis()/1000.0,2); Serial.print(",");
/*
Serial.print(getMeanf(tempCmean_reservoir,TEMPMEAN_SIZE)); Serial.print(","); Serial.print(getMeanf(tempCmean_reservoir,TEMPMEAN_SIZE)); Serial.print(",");
//Serial.print(getMean(sm_mean,SM_SIZE)); Serial.print(","); //Serial.print(getMean(sm_mean,SM_SIZE)); Serial.print(",");
@ -127,6 +163,8 @@ void loop() {
Serial.print(ec_adc_adjusted); //Serial.print(","); Serial.print(ec_adc_adjusted); //Serial.print(",");
//Serial.print(ec); Serial.print(","); //Serial.print(ec); Serial.print(",");
//Serial.print(ec25); //Serial.print(ec25);
*/
Serial.println(); Serial.println();