diff --git a/db/src/main.go b/db/src/main.go index 926bc59..867bbb8 100644 --- a/db/src/main.go +++ b/db/src/main.go @@ -146,13 +146,19 @@ func main() { } } - // If CO2PPM value is present and over 1000000000 delete the field + // If CO2PPM value is present and over 1,000,000,000 delete the field, it's calibration value values := dp.GetValues() if values.CO2PPM > 1000000000 { - log.Printf("[Main] Warning: CO2PPM value %d is over threshold, setting to 0\n", values.CO2PPM) + log.Printf("[Main] Warning: CO2PPM value %d is calibrating, setting to 0\n", values.CO2PPM) values.CO2PPM = 0 } + // Still too high value, something wrong, dropping datapoint + if values.CO2PPM > 10000 { + log.Printf("[Main] Error: CO2PPM value %d is over threshold, dropping Datapoint\n", values.CO2PPM) + return + } + translatedDp := provenceMeasurement.CreateDataPoint(influxTags, values, dp.Timestamp()) if err := influxGateway.AddDatapoint(&translatedDp); err != nil {