|
@ -91,6 +91,7 @@ Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085); |
|
|
DHT dht(DHT22_PIN, DHTTYPE); |
|
|
DHT dht(DHT22_PIN, DHTTYPE); |
|
|
SDS011 sds; |
|
|
SDS011 sds; |
|
|
volatile unsigned long geiger_counts = 0; |
|
|
volatile unsigned long geiger_counts = 0; |
|
|
|
|
|
unsigned long geiger_previousMillis; |
|
|
unsigned long last_wifi_activity = 0; |
|
|
unsigned long last_wifi_activity = 0; |
|
|
unsigned long last_dhcp = 0; |
|
|
unsigned long last_dhcp = 0; |
|
|
IPAddress ip, dns, gateway, subnet; |
|
|
IPAddress ip, dns, gateway, subnet; |
|
@ -169,8 +170,13 @@ void ICACHE_FLASH_ATTR sendValues() { |
|
|
|
|
|
|
|
|
// sds.sleep();
|
|
|
// sds.sleep();
|
|
|
|
|
|
|
|
|
sd.radioactivity = -1; |
|
|
if (millis() - geiger_previousMillis > 60000) { |
|
|
sd.cpm = geigeraverage.getAverage()*10; |
|
|
sd.cpm = geiger_counts * 60000 / (millis() - geiger_previousMillis); |
|
|
|
|
|
geiger_previousMillis = millis(); |
|
|
|
|
|
geiger_counts = 0; |
|
|
|
|
|
geigeraverage.addValue(sd.cpm); |
|
|
|
|
|
} |
|
|
|
|
|
//geiger_runningaverage = geigeraverage.getAverage()*10;
|
|
|
float constexpr own_cpm = OWN_BACKGROUND_CPS * 60; |
|
|
float constexpr own_cpm = OWN_BACKGROUND_CPS * 60; |
|
|
sd.radioactivity = (sd.cpm - own_cpm) * CONV_FACTOR; |
|
|
sd.radioactivity = (sd.cpm - own_cpm) * CONV_FACTOR; |
|
|
|
|
|
|
|
@ -374,13 +380,6 @@ void ICACHE_RAM_ATTR ISR_geiger_impulse() { |
|
|
geiger_counts++; |
|
|
geiger_counts++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// will be called every 6 seconds
|
|
|
|
|
|
void timerCallback(void *pArg) { |
|
|
|
|
|
//DEBUG_MSG("running average counts: %d average: %6.2f\n", geiger_counts, geigeraverage.getAverage());
|
|
|
|
|
|
geigeraverage.addValue(geiger_counts); |
|
|
|
|
|
geiger_counts = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup() { |
|
|
void setup() { |
|
|
#ifdef USERDEBUG |
|
|
#ifdef USERDEBUG |
|
@ -404,9 +403,6 @@ void setup() { |
|
|
attachInterrupt(digitalPinToInterrupt(GEIGER_PIN), ISR_geiger_impulse, FALLING); |
|
|
attachInterrupt(digitalPinToInterrupt(GEIGER_PIN), ISR_geiger_impulse, FALLING); |
|
|
|
|
|
|
|
|
geigeraverage.clear(); |
|
|
geigeraverage.clear(); |
|
|
geigeraverage.addValue(2); |
|
|
|
|
|
os_timer_setfn(&Timer1, timerCallback, NULL); |
|
|
|
|
|
os_timer_arm(&Timer1, 6000, true); |
|
|
|
|
|
|
|
|
|
|
|
DEBUG_MSG("ready.\n"); Serial.flush(); |
|
|
DEBUG_MSG("ready.\n"); Serial.flush(); |
|
|
} |
|
|
} |
|
|