|
|
@ -92,6 +92,7 @@ SDS011 sds; |
|
|
|
volatile unsigned long geiger_counts = 0; |
|
|
|
unsigned long geiger_previousMillis; |
|
|
|
unsigned long last_dhcp = 0; |
|
|
|
unsigned long previousMillis = 0; |
|
|
|
IPAddress ip, dns, gateway, subnet; |
|
|
|
char ssid[64]; |
|
|
|
char password[64]; |
|
|
@ -123,7 +124,7 @@ void fpm_wakup_cb_func1(void) { |
|
|
|
//ESP.wdtFeed();
|
|
|
|
//wifi_fpm_do_wakeup();
|
|
|
|
wifi_fpm_close(); |
|
|
|
//geiger_counts++;
|
|
|
|
geiger_counts++; |
|
|
|
} |
|
|
|
|
|
|
|
void lightsleep() { |
|
|
@ -163,7 +164,7 @@ void ICACHE_FLASH_ATTR sendValues() { |
|
|
|
|
|
|
|
// sds.sleep();
|
|
|
|
|
|
|
|
if (rtcMillis() - geiger_previousMillis > 60000) { |
|
|
|
if (rtcMillis() - geiger_previousMillis > 10000) { |
|
|
|
sd.cpm = geiger_counts * 60000 / (rtcMillis() - geiger_previousMillis); |
|
|
|
geiger_previousMillis = rtcMillis(); |
|
|
|
geiger_counts = 0; |
|
|
@ -367,10 +368,11 @@ void ICACHE_FLASH_ATTR sendValues() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ICACHE_RAM_ATTR ISR_geiger_impulse() { |
|
|
|
// geiger event when gpio pulled low (called vin on board)
|
|
|
|
/*void ICACHE_RAM_ATTR ISR_geiger_impulse() {
|
|
|
|
geiger_counts++; |
|
|
|
} |
|
|
|
DEBUG_MSG("X"); |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
void setup() { |
|
|
@ -381,6 +383,8 @@ void setup() { |
|
|
|
pinMode(LED_BUILTIN, OUTPUT); |
|
|
|
digitalWrite(LED_BUILTIN, HIGH); // turn OFF board led
|
|
|
|
|
|
|
|
//wifi_status_led_uninstall();
|
|
|
|
|
|
|
|
sds.begin(SDS_TX, SDS_RX); |
|
|
|
sds.mode_mon_300(); |
|
|
|
|
|
|
@ -392,14 +396,27 @@ void setup() { |
|
|
|
dht.begin(); |
|
|
|
|
|
|
|
pinMode(GEIGER_PIN, INPUT); |
|
|
|
attachInterrupt(digitalPinToInterrupt(GEIGER_PIN), ISR_geiger_impulse, FALLING); |
|
|
|
//attachInterrupt(digitalPinToInterrupt(GEIGER_PIN), ISR_geiger_impulse, FALLING);
|
|
|
|
|
|
|
|
geigeraverage.clear(); |
|
|
|
|
|
|
|
previousMillis = millis(); |
|
|
|
|
|
|
|
DEBUG_MSG("ready.\n"); Serial.flush(); |
|
|
|
} |
|
|
|
|
|
|
|
void loop() { |
|
|
|
unsigned long currentMillis = rtcMillis(); |
|
|
|
if ((currentMillis - previousMillis) >= postingInterval) { |
|
|
|
previousMillis = currentMillis; |
|
|
|
DEBUG_MSG("sending values... previousMillis:%u, millis():%u, difference:%d\n", previousMillis, currentMillis, currentMillis-previousMillis); |
|
|
|
sendValues(); |
|
|
|
delay(postingInterval); |
|
|
|
DEBUG_MSG("resetting geiger counts. was: %d\n", geiger_counts); |
|
|
|
geiger_previousMillis = rtcMillis(); |
|
|
|
geiger_counts = 0; |
|
|
|
} |
|
|
|
DEBUG_MSG("sleeping now... (%u)\n", currentMillis); |
|
|
|
delay(10); |
|
|
|
lightsleep(); |
|
|
|
delay(10); // debounce?
|
|
|
|
} |
|
|
|