From 7868ef96b94d8925d96f9a12d16e257dcb57c2f3 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Wed, 7 Mar 2018 15:53:36 +0100 Subject: [PATCH] subtract own radiation --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 1aaa2d5..7e40fd5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,6 +58,7 @@ static constexpr uint8_t SDS_RX = D2; static constexpr uint8_t GEIGER_PIN = D6; static constexpr float CONV_FACTOR = 0.008120; +static constexpr float OWN_BACKGROUND_CPS = 0.2; static constexpr unsigned long logging_period_ms = 60000; ADC_MODE(ADC_VCC); @@ -114,9 +115,10 @@ void ICACHE_FLASH_ATTR sendValues() { float radiationValue = -1; if (millis() - geiger_previousMillis > logging_period_ms) { cpm = geiger_counts * 60000 / (millis() - geiger_previousMillis); + unsigned long constexpr own_cpm = OWN_BACKGROUND_CPS * 60; geiger_previousMillis = millis(); geiger_counts = 0; - radiationValue = cpm * CONV_FACTOR; + radiationValue = (cpm - own_cpm) * CONV_FACTOR; // Serial.println(cpm); } else { // Serial.println("Geiger Counter: no new value");