Browse Source

light_sleep with geiger cnt

main
Hendrik Langer 7 years ago
parent
commit
b9493b747d
  1. 6
      README.md
  2. 31
      src/main.cpp

6
README.md

@ -44,9 +44,9 @@ CAD files (OpenSCAD) and source code included.
RSV (0)D3 -- BMP_SDA .---- GND
RSV (2)D4 -- BMP_SCL | ...
RSV 3V3 -- BMP_VCC | .--- 5V
RSV GND -- BMP_GND | | ...
GND D5 | | ...
3V3 D6 ------------. | |
RSV .-GND -- BMP_GND | | ...
GND =C= D5 | | ...
3V3 '- D6 ------------. | |
GND D7 -- DHT_DATA \ +-| --------- GND
3V3 D8 \ | +---------- 5V
EN RX '- | ----------- VIN

31
src/main.cpp

@ -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?
}

Loading…
Cancel
Save