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