Browse Source

try and fix freeze

main
Hendrik Langer 6 years ago
parent
commit
af526bdca6
  1. 21
      src/main.cpp

21
src/main.cpp

@ -37,7 +37,7 @@ const char* mqttusername PROGMEM = "esp-weatherstation";
const char* mqttpassword PROGMEM = PWD_MQTT;
constexpr unsigned int postingInterval = 60000; //Uploadintervall in Millisekunden
constexpr unsigned int dhcp_interval = 3*60*1000;
constexpr unsigned int dhcp_interval = 60*60*1000;
uint32_t loop_count = 0;
@ -88,6 +88,10 @@ ADC_MODE(ADC_VCC);
ESP8266WiFiMulti wifiMulti;
HTTPClient httpclient;
WiFiClientSecure net;
MQTTClient mqttclient(MQTT_MAX_PACKET_SIZE);
os_timer_t Timer1;
RunningAverage geigeraverage(10);
@ -333,7 +337,6 @@ void ICACHE_FLASH_ATTR sendValues() {
int httpCode = 0;
for (int tries=0; tries<3 && httpCode != HTTP_CODE_CREATED; tries++) {
HTTPClient httpclient;
char url[100];
sprintf(url, "http://%s/boxes/%s/data", server, SENSEBOX_ID);
@ -357,9 +360,6 @@ void ICACHE_FLASH_ATTR sendValues() {
}
WiFiClientSecure net;
MQTTClient mqttclient(MQTT_MAX_PACKET_SIZE);
net.setInsecure();
mqttclient.begin(mqttserver, 8883, net);
int tries = 0;
@ -400,10 +400,10 @@ 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++;
DEBUG_MSG("X");
}*/
//DEBUG_MSG("X\n");
}
void setup() {
@ -428,11 +428,10 @@ void setup() {
dht.begin();
pinMode(GEIGER_PIN, INPUT);
//attachInterrupt(digitalPinToInterrupt(GEIGER_PIN), ISR_geiger_impulse, FALLING);
geigeraverage.clear();
//WiFi.persistent(false); // don't load and save credentials to flash
WiFi.persistent(false); // don't load and save credentials to flash
WiFi.mode(WIFI_STA);
wifiMulti.addAP("nether.net", PWD_NETHERNET);
wifiMulti.addAP("LNet", PWD_LNET);
@ -444,6 +443,7 @@ void setup() {
}
void loop() {
attachInterrupt(digitalPinToInterrupt(GEIGER_PIN), ISR_geiger_impulse, FALLING);
unsigned long currentMillis = rtcMillis();
if ((currentMillis - previousMillis) >= postingInterval) {
previousMillis = currentMillis;
@ -457,6 +457,7 @@ void loop() {
DEBUG_MSG("heap: %d\n", ESP.getFreeHeap());
delay(10);
detachInterrupt(digitalPinToInterrupt(GEIGER_PIN));
lightsleep();
delay(10); // debounce?
}

Loading…
Cancel
Save