Skip to content

Commit

Permalink
first parts of SCD30 calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
ricki-z committed Mar 29, 2024
1 parent 04186cf commit 4a93e78
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions airrohr-firmware/airrohr-cfg.h.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
String dnms_correction
String temp_correction
String height_above_sealevel
String last_calibration_scd30
Bool gps_read
Bool send2dusti
Bool ssl_dusti
Expand Down
35 changes: 34 additions & 1 deletion airrohr-firmware/airrohr-firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ namespace cfg
bool sps30_read = SPS30_READ;
bool bmp_read = BMP_READ;
bool bmx280_read = BMX280_READ;
char height_above_sealevel[8] = "0";
char height_above_sealevel[LEN_HEIGHT_ABOVE_SEALEVEL] = "0";
bool sht3x_read = SHT3X_READ;
bool scd30_read = SCD30_READ;
char last_calibration_scd30[LEN_LAST_CALIBRATION_SCD30] = "";
bool ds18b20_read = DS18B20_READ;
bool dnms_read = DNMS_READ;
char dnms_correction[LEN_DNMS_CORRECTION] = DNMS_CORRECTION;
Expand Down Expand Up @@ -622,6 +623,10 @@ unsigned long SPS30_read_error_counter = 0;
unsigned long SPS30_read_timer = 0;
bool sps30_init_failed = false;

bool scd30_calibration = 0;
unsigned long scd30_start_cal = 0;
unsigned long scd30_last_val_change = 0;

float last_value_PPD_P1 = -1.0;
float last_value_PPD_P2 = -1.0;
float last_value_SDS_P1 = -1.0;
Expand Down Expand Up @@ -2523,6 +2528,11 @@ static void webserver_status()
add_table_row_from_value(page_content, F("SCD30 measurement interval"), String(settingVal));
scd30.getTemperatureOffset(&settingVal);
add_table_row_from_value(page_content, F("SCD30 temperature offset"), String(settingVal));
if (scd30_calibration) {
add_table_row_from_value(page_content, F("SCD30 calibration running since", delayToString(millis() - scd30_start_cal));
} else {
add_table_row_from_value(page_content, F("SCD30 last calibration"), cfg::last_calibration_scd30);
}
}

page_content += FPSTR(EMPTY_ROW);
Expand Down Expand Up @@ -2765,6 +2775,29 @@ static void webserver_reset()
end_html_page(page_content);
}

/*****************************************************************
* Webserver start SCD30 calibration *
*****************************************************************/
static void webserver_scd30_calib() {
if (!webserver_request_auth())
{ return; }

String page_content;
page_content.reserve(512);

start_html_page(page_content, FPSTR(INTL_SCD30_CALIBRATION));
debug_outln_info(F("ws: start SCD30 calibration..."));

page_content += FPSTR(WEB_SCD30_CALIBRATION_CONTENT);

if (! scd30_calibration) {
scd30_calibration = true;
scd30_start_cal = millis();
}

end_html_page(page_content);
}

/*****************************************************************
* Webserver data.json *
*****************************************************************/
Expand Down
1 change: 1 addition & 0 deletions airrohr-firmware/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define LEN_DNMS_CORRECTION 8
#define LEN_TEMP_CORRECTION 8
#define LEN_HEIGHT_ABOVE_SEALEVEL 8
#define LEN_LAST_CALIBRATION_SCD30 20

#define LEN_SENSEBOXID 30

Expand Down

0 comments on commit 4a93e78

Please sign in to comment.