change tof sensor and new calibration
This commit is contained in:
parent
14134f1e32
commit
8249bfb79f
6 changed files with 54 additions and 20 deletions
|
@ -2,6 +2,8 @@
|
|||
#define _EC_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
extern bool eccalibrationoutput;
|
||||
/*
|
||||
mqttValueTiming timing_ec_adc;
|
||||
mqttValueTiming timing_ec_calibadc;
|
||||
|
@ -62,7 +64,8 @@ float ec; //ec value after adjustment for reference (at current temperature)
|
|||
float ec25; //ec value but temperature adjusted for 25 degC
|
||||
|
||||
float ec_tempadjust_alpa=0.02;
|
||||
float ec_reference_adc=6016.88; //adc reference value for the calibration resistor measurement.
|
||||
float ec_reference_adc=EC_REFERENCE_ADC; //adc reference value for the calibration resistor measurement.
|
||||
|
||||
//EC short circuit adc value: 17497, 17861.4 (for connection resistance testing)
|
||||
//EC open circuit adc value: 738, 730, 737.27
|
||||
|
||||
|
@ -152,7 +155,7 @@ void ec_loop(unsigned long loopmillis) {
|
|||
switch (ecstate) {
|
||||
case IDLE:
|
||||
|
||||
if (loopmillis>last_measurement_ec+EC_MEASUREMENT_INTERVAL || force_ec_measurement) { //start measurement if idle
|
||||
if ( (loopmillis>last_measurement_ec+EC_MEASUREMENT_INTERVAL && eccalibrationoutput) || force_ec_measurement) { //start measurement if idle
|
||||
//Serial.println("DEBUG: Start measurement");
|
||||
last_measurement_ec=loopmillis;
|
||||
force_ec_measurement=false;
|
||||
|
|
|
@ -106,12 +106,14 @@ void temperature_setup() {
|
|||
|
||||
void temperature_loop(unsigned long loopmillis) {
|
||||
|
||||
static unsigned long last_read_ds18b20;
|
||||
static unsigned long last_read_ds18b20=0;
|
||||
static bool flag_requestTemperatures=false;
|
||||
if (loopmillis>last_read_ds18b20+READINTERVAL_DS18B20) {
|
||||
if (loopmillis>last_read_ds18b20+READINTERVAL_DS18B20*10) { //timeout
|
||||
Serial.println("Warn: Request Temperatures Timeout!");
|
||||
publishInfo("error/temperature","Warn: Request Temperatures Timeout!");
|
||||
if (mqtt) {
|
||||
publishInfo("error/temperature","Warn: Request Temperatures Timeout!");
|
||||
}
|
||||
flag_requestTemperatures=false;
|
||||
last_read_ds18b20=loopmillis;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
#define _WATERLEVEL_H_
|
||||
|
||||
#include <Wire.h>
|
||||
#include <VL53L0X.h> //pololu/VL53L0X@^1.3.1
|
||||
#ifdef WATERLEVELSENSOR_VL53L0X
|
||||
//#include <VL53L0X.h> //pololu/VL53L0X@^1.3.1
|
||||
#endif
|
||||
#ifdef WATERLEVELSENSOR_VL53L1X
|
||||
#include <VL53L1X.h> //pololu/VL53L1X@^1.3.1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -19,7 +24,13 @@
|
|||
|
||||
|
||||
// +++++++++++++++ VL53L0X +++++++++++++++
|
||||
#ifdef WATERLEVELSENSOR_VL53L0X
|
||||
VL53L0X tofsensor;
|
||||
#endif
|
||||
#ifdef WATERLEVELSENSOR_VL53L1X
|
||||
VL53L1X tofsensor;
|
||||
#endif
|
||||
|
||||
|
||||
// Uncomment this line to use long range mode. This
|
||||
// increases the sensitivity of the sensor and extends its
|
||||
|
@ -152,6 +163,10 @@ void waterlevel_setup() {
|
|||
tofsensor.setMeasurementTimingBudget(200000);
|
||||
#endif
|
||||
|
||||
#if defined ROISIZE_WIDTH
|
||||
tofsensor.setROISize(ROISIZE_WIDTH,ROISIZE_HEIGHT); //default/maximum is 16x16
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import matplotlib.pyplot as plt
|
|||
from pandas import *
|
||||
|
||||
# reading CSV file
|
||||
data = read_csv("20240423_EC_Calibration.csv")
|
||||
|
||||
data = read_csv("2025/20250415_db_2025_B.csv")
|
||||
|
||||
# converting column data to list
|
||||
solutionAdded = data['solutionAdded'].tolist() #in ml
|
||||
tempReservoir = data['tempReservoir'].tolist() #in C
|
||||
|
|
|
@ -26,6 +26,8 @@ build_flags=
|
|||
-D EC_CALIBRATION_LINEARIZE_BELOW_ADC=2000
|
||||
-D EC_CALIBRATION_LINEAR_LOWADC=728
|
||||
-D EC_CALIBRATION_LINEAR_LOWEC=0
|
||||
-D EC_REFERENCE_ADC=6016.88
|
||||
|
||||
-D FLOW_PIN=16
|
||||
-D ONE_WIRE_BUS_PIN=18
|
||||
-D THERMOMETER_ADDR_RESERVOIR={0x28,0xFF,0x6F,0x19,0x72,0x16,0x05,0x44}
|
||||
|
@ -36,6 +38,8 @@ build_flags=
|
|||
-D WATERLEVEL_FACTOR=-1.0
|
||||
-D RES_AREA=20*20*3.1416
|
||||
|
||||
-D WATERLEVELSENSOR_VL53L0X
|
||||
|
||||
lib_deps =
|
||||
https://github.com/milesburton/Arduino-Temperature-Control-Library/
|
||||
https://github.com/emilv/ArduinoSort/
|
||||
|
@ -50,7 +54,7 @@ platform = platformio/espressif32@^6.7
|
|||
board = esp32-s3-devkitm-1
|
||||
;Devboard is ESP32-S3-DevKitC-1 (N16R8). board=esp32-s3-devkitm-1 works fine
|
||||
framework = arduino
|
||||
monitor_port = /dev/ttyACM1
|
||||
monitor_port = /dev/ttyACM0
|
||||
|
||||
monitor_speed = 115200
|
||||
|
||||
|
@ -63,10 +67,11 @@ build_flags=
|
|||
-D EC_PIN_RELAY_PROBE=35
|
||||
-D EC_PIN_FREQ=38
|
||||
|
||||
-D EC_CALIBRATION_POLYNOM={8.718380956513695,-0.026463423062356713,3.425216464107108e-05,-4.069826379094172e-09,2.478900495960682e-13}
|
||||
-D EC_CALIBRATION_LINEARIZE_BELOW_ADC=2000
|
||||
-D EC_CALIBRATION_LINEAR_LOWADC=728
|
||||
-D EC_CALIBRATION_POLYNOM={66.39669240599893,-0.09954956470655674,5.934040501689804e-05,-8.587883382454424e-09,4.448631030971983e-13}
|
||||
-D EC_CALIBRATION_LINEARIZE_BELOW_ADC=3600
|
||||
-D EC_CALIBRATION_LINEAR_LOWADC=465.97
|
||||
-D EC_CALIBRATION_LINEAR_LOWEC=0
|
||||
-D EC_REFERENCE_ADC=5908
|
||||
|
||||
-D FLOW_PIN=17
|
||||
-D ONE_WIRE_BUS_PIN=18
|
||||
|
@ -79,13 +84,16 @@ build_flags=
|
|||
-D WATERLEVEL_OFFSET=315.0
|
||||
-D WATERLEVEL_FACTOR=-1.0
|
||||
-D RES_AREA=37*56
|
||||
-D WATERLEVELSENSOR_VL53L1X
|
||||
-D ROISIZE_WIDTH=8
|
||||
-D ROISIZE_HEIGHT=8
|
||||
|
||||
lib_deps =
|
||||
https://github.com/milesburton/Arduino-Temperature-Control-Library/
|
||||
https://github.com/emilv/ArduinoSort/
|
||||
robtillaart/ADS1X15@^0.3.9
|
||||
256dpi/MQTT@^2.5.2
|
||||
pololu/VL53L0X@^1.3.1
|
||||
pololu/VL53L1X@^1.3.1
|
||||
adafruit/Adafruit NeoPixel
|
||||
|
||||
|
||||
|
@ -109,10 +117,11 @@ build_flags=
|
|||
-D EC_PIN_RELAY_PROBE=35
|
||||
-D EC_PIN_FREQ=38
|
||||
|
||||
-D EC_CALIBRATION_POLYNOM={8.718380956513695,-0.026463423062356713,3.425216464107108e-05,-4.069826379094172e-09,2.478900495960682e-13}
|
||||
-D EC_CALIBRATION_LINEARIZE_BELOW_ADC=2000
|
||||
-D EC_CALIBRATION_LINEAR_LOWADC=728
|
||||
-D EC_CALIBRATION_POLYNOM={93.96528045244023,-0.1442265098262804,8.016698711210758e-05,-1.1609651235703859e-08,5.945632995842434e-13}
|
||||
-D EC_CALIBRATION_LINEARIZE_BELOW_ADC=3600
|
||||
-D EC_CALIBRATION_LINEAR_LOWADC=452.71
|
||||
-D EC_CALIBRATION_LINEAR_LOWEC=0
|
||||
-D EC_REFERENCE_ADC=5782.9
|
||||
|
||||
-D FLOW_PIN=17
|
||||
-D ONE_WIRE_BUS_PIN=18
|
||||
|
@ -125,11 +134,14 @@ build_flags=
|
|||
-D WATERLEVEL_OFFSET=500.0
|
||||
-D WATERLEVEL_FACTOR=-1.0
|
||||
-D RES_AREA=20*20*3.1416
|
||||
-D WATERLEVELSENSOR_VL53L1X
|
||||
-D ROISIZE_WIDTH=8
|
||||
-D ROISIZE_HEIGHT=8
|
||||
|
||||
lib_deps =
|
||||
https://github.com/milesburton/Arduino-Temperature-Control-Library/
|
||||
https://github.com/emilv/ArduinoSort/
|
||||
robtillaart/ADS1X15@^0.3.9
|
||||
256dpi/MQTT@^2.5.2
|
||||
pololu/VL53L0X@^1.3.1
|
||||
pololu/VL53L1X@^1.3.1
|
||||
adafruit/Adafruit NeoPixel
|
10
src/main.cpp
10
src/main.cpp
|
@ -8,7 +8,7 @@ unsigned long last_check=0;
|
|||
|
||||
#include "wifi_functions.h"
|
||||
|
||||
bool debug=false; //print Serial information
|
||||
bool debug=true; //print Serial information
|
||||
bool mqtt=false;
|
||||
bool eccalibrationoutput=true; //serial output for ec calibration
|
||||
/* Write to file with:
|
||||
|
@ -90,6 +90,7 @@ void setup() {
|
|||
pixels.show();
|
||||
delay(250);
|
||||
pixels.clear();
|
||||
pixels.show();
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -155,7 +156,8 @@ void setup() {
|
|||
|
||||
Serial.print(i); Serial.print(","); Serial.print(_ec); Serial.println();
|
||||
}
|
||||
delay(100000);
|
||||
Serial.println("Waiting 10 seconds because eccalibrationoutput is enabled");
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
|
||||
|
@ -171,13 +173,13 @@ void loop() {
|
|||
|
||||
|
||||
ec_loop(loopmillis);
|
||||
|
||||
|
||||
temperature_loop(loopmillis);
|
||||
|
||||
if (!ec_measurementRunning()){ //skip tof read when ec measurement running, because vlxx sensor reading takes quite long per cycle
|
||||
waterlevel_loop(loopmillis);
|
||||
}
|
||||
|
||||
|
||||
flow_loop(loopmillis);
|
||||
|
||||
//sm_loop(loopmillis);
|
||||
|
|
Loading…
Add table
Reference in a new issue