messing with calibration check and default values

This commit is contained in:
Justin E. Mann 2024-11-27 17:05:55 -07:00
parent e1b49800ea
commit dd6f32688b

View File

@ -9,7 +9,7 @@ RAK12035VBSensor::RAK12035VBSensor() : TelemetrySensor(meshtastic_TelemetrySenso
int32_t RAK12035VBSensor::runOnce() int32_t RAK12035VBSensor::runOnce()
{ {
LOG_INFO("Init sensor: %s\n", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
} }
@ -20,14 +20,14 @@ int32_t RAK12035VBSensor::runOnce()
// Get sensor firmware version // Get sensor firmware version
uint8_t data = 0; uint8_t data = 0;
sensor.get_sensor_version(&data); sensor.get_sensor_version(&data);
LOG_INFO("Sensor Firmware version: %i\n", data); LOG_INFO("Sensor Firmware version: %i", data);
if ( data != 0) if ( data != 0)
{ {
LOG_DEBUG("RAK12035VBSensor Init Succeed\n"); LOG_DEBUG("RAK12035VBSensor Init Succeed");
status = true; status = true;
} else { } else {
LOG_ERROR("RAK12035VBSensor Init Failed\n"); LOG_ERROR("RAK12035VBSensor Init Failed");
status = false; status = false;
} }
return initI2CSensor(); return initI2CSensor();
@ -44,16 +44,26 @@ void RAK12035VBSensor::setup() {
sensor.get_wet_cal(&hundred_val); sensor.get_wet_cal(&hundred_val);
delay(100); delay(100);
if(zero_val == 0 || zero_val >= hundred_val){ if(zero_val == 0 || zero_val >= hundred_val){
LOG_COLOR_W("Dry calibration value is %d", zero_val);
LOG_COLOR_W("Wet calibration value is %d", hundred_val);
LOG_COLOR_W("This does not make sense. Youc can recalibrate this sensor using the calibration sketch included here: https://github.com/RAKWireless/RAK12035_SoilMoisture.");
LOG_COLOR_W("For now, setting default calibration value for Dry Calibration: %d", default_zero_val);
sensor.set_dry_cal(default_zero_val); sensor.set_dry_cal(default_zero_val);
sensor.get_dry_cal(&zero_val); sensor.get_dry_cal(&zero_val);
LOG_COLOR_W("Dry calibration reset complete. New value is %d", zero_val);
} }
if(hundred_val == 0 || hundred_val <= zero_val){ if(hundred_val == 0 || hundred_val <= zero_val){
LOG_COLOR_W("Dry calibration value is %d", zero_val);
LOG_COLOR_W("Wet calibration value is %d", hundred_val);
LOG_COLOR_W("This does not make sense. Youc can recalibrate this sensor using the calibration sketch included here: https://github.com/RAKWireless/RAK12035_SoilMoisture.");
LOG_COLOR_W("For now, setting default calibration value for Wet Calibration: %d", default_hundred_val);
sensor.set_wet_cal(default_hundred_val); sensor.set_wet_cal(default_hundred_val);
sensor.get_wet_cal(&hundred_val); sensor.get_wet_cal(&hundred_val);
LOG_COLOR_W("Wet calibration reset complete. New value is %d", hundred_val);
} }
delay(100); delay(100);
LOG_INFO("Dry calibration value is %d\n", zero_val); LOG_INFO("Dry calibration value is %d", zero_val);
LOG_INFO("Wet calibration value is %d\n", hundred_val); LOG_INFO("Wet calibration value is %d", hundred_val);
} }
bool RAK12035VBSensor::getMetrics(meshtastic_Telemetry *measurement) bool RAK12035VBSensor::getMetrics(meshtastic_Telemetry *measurement)