Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WifiManager hangs setup after successful configuration save #948

Open
3 of 7 tasks
afagard opened this issue Sep 24, 2019 · 5 comments
Open
3 of 7 tasks

WifiManager hangs setup after successful configuration save #948

afagard opened this issue Sep 24, 2019 · 5 comments
Labels
DEV Help Wanted Developer Needs Help Question User Question member to member support

Comments

@afagard
Copy link

afagard commented Sep 24, 2019

Basic Infos

Hardware

WiFimanager Branch/Release:

  • Master
  • Development

Esp8266/Esp32:

  • ESP8266
  • ESP32

Hardware: ESP-12e, esp01, esp25
Lolin D1 mini pro

ESP Core Version: 2.4.0, staging

  • 2.3.0
  • 2.4.0
  • staging (master/dev)

Description

On first run, with clear memory, the device starts and I can go to the configuration portal to modify the wifi credentials and save it. On save, and over serial, the device immediately spits out:

*WM: WiFi save
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
(few seconds later)
connected with XXXX, channel 1
dhcp client start...
ip:10.0.0.236,mask:255.255.255.0,gw:10.0.0.1
*WM: Connection result:
*WM: 3
station: c0:ee:fb:de:08:61 leave, AID = 1
rm 1
bcn 0
del if1
pm open,type:2 0
mode : sta(84:0d:8e:8f:4e:2e)

And stops. Then, after about a minute and a half, my own setup begins and everything goes on normally.

pm open,type:2 0
mode : sta(84:0d:8e:8f:4e:2e)
[CONFIG] There was an error opening config.json for reading. This is normal on first-run startup.
[CONFIG] Failed to read file. Using default configuration. This is normal on first-run startup.
[WIFI] mDNS responder started
[WIFI] TCP server started
[DS] Locating Dallas temperature sensors...[DS] Found 2 sensor(s).
[DS] Added temp sensor.
[DS] Added temp sensor.
[BME] Locating BME280...
[BME] Found sensor.
[IRRIGATION] Pump off.
[IRRIGATION] Pump on.
[IRRIGATION] Pump off.
[IRRIGATION] Pump on.
*WM: freeing allocated params!
[RAINFALL] Attempting to save rainfall data...
[RAINFALL] rainfall.txt does not exist. At startup this is expected.
[RAINFALL] File was written.
[IRRIGATION] Running routine...
[RAINFALL] Tip count from memory: 0

What exactly is happening during this timeperiod? Is this normal? Because as the serial prints suggest, the device has successfully connected after the credentials were correctly entered then the delay. Without wifimanager, and using hard-coded configuration variables, there is no delay.

Please note: after initial configuration, if I restart the device everything happens within 10-15 seconds:

connected with 113OceanPines, channel 1
dhcp client start...
ip:10.0.0.236,mask:255.255.255.0,gw:10.0.0.1
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 10.0.0.236
[CONFIG] There was an error opening config.json for reading. This is normal on first-run startup.
[CONFIG] Failed to read file. Using default configuration. This is normal on first-run startup.
[WIFI] mDNS responder started
[WIFI] TCP server started
[DS] Locating Dallas temperature sensors...[DS] Found 2 sensor(s).
[DS] Added temp sensor.
[DS] Added temp sensor.
[BME] Locating BME280...
[BME] Found sensor.
[IRRIGATION] Pump off.
[IRRIGATION] Pump on.
[IRRIGATION] Pump off.
[IRRIGATION] Pump on.
*WM: freeing allocated params!
[RAINFALL] Attempting to save rainfall data...
[RAINFALL] Tip count from memory: 0
[RAINFALL] File was written.
[IRRIGATION] Running routine...
[RAINFALL] Tip count from memory: 0
pm open,type:2 0

Settings in IDE

Module: NodeMcu, Wemos D1

Additional libraries:

Sketch

My sketch is about 1000 lines:

https://pastebin.com/Jn6eZq43

But this is my basic setup:

void setup(void)
{
  Serial.begin(115200);
  pinMode(WIFI_STATUS_LED, OUTPUT);
  pinMode(ERROR_LED, OUTPUT);
  pinMode(PUMP_RELAY, OUTPUT);
  digitalWrite(PUMP_RELAY, LOW);
  digitalWrite(WIFI_STATUS_LED, LOW);
  digitalWrite(ERROR_LED, LOW); // inverse for some reason...
  WiFiManager wifiManager;
  wifiManager.autoConnect("IrrigationStationWifiSetup", "XXXX");
  wifiManager.setDebugOutput(true);
  //wifiManager.setSTAStaticIPConfig(staticIP, gateway, subnet);
  if (!SPIFFS.begin()) {
    enableErrorLed();
    Serial.println("Failed to mount the file system!");
    while (1);
  }
  resetRtc();
  createErrorsArray();
  getConfig(config); // first thing to serial print see: [CONFIG] in output above
  deviceStarted = millis();
  serverDefs();
  //initWifi();
  initWifi();
  initRtc(); // must be called after wifi
  initDs();
  initBme();
  initRg();
  relayTest();
  runner.init();
  runner.addTask(t1);
  runner.addTask(t2);
  t1.enable();
  t2.enable();
  ota();
}

void initWifi() {
  WiFi.persistent(false);
  WiFi.mode(WIFI_STA);
  // start mdns
  if (!MDNS.begin("station")) {
    Serial.println("[WIFI] Error setting up MDNS responder!");
    while (1) {
      digitalWrite(WIFI_STATUS_LED, HIGH);
      delay(500);
      digitalWrite(WIFI_STATUS_LED, LOW);
      delay(500);
    }
  }
  Serial.println("[WIFI] mDNS responder started");
  // Start TCP (HTTP) server
  server.begin();
  Serial.println("[WIFI] TCP server started");
  // Add service to MDNS-SD
  MDNS.addService("http", "tcp", 80);
  digitalWrite(WIFI_STATUS_LED, HIGH); // signify connection started
}

Libraries:

#include <OneWire.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <DallasTemperature.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include <RTClib.h>
#include <ArduinoJson.h>
#include <ACS712.h>
#include <ESP8266WebServer.h>
#include <FS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <WiFiManager.h>
#include <DNSServer.h>
@ermaya
Copy link

ermaya commented Oct 5, 2019

Have you read the first line of the AutoConnectWithFSParameters example?
Maybe it helps.
#include <FS.h> //this needs to be first, or it all crashes and burns...

@afagard
Copy link
Author

afagard commented Oct 13, 2019

Have you read the first line of the AutoConnectWithFSParameters example?
Maybe it helps.
#include <FS.h> //this needs to be first, or it all crashes and burns...

But it doesn't crash... Will try it out nevertheless.

@tablatronix
Copy link
Collaborator

I would guess this infinite loop ?
while (1);

@afagard
Copy link
Author

afagard commented Oct 13, 2019

I would guess this infinite loop ?
while (1);

within the confines of the if it isn't an issue as those things are abs required for everything else to work. in any case, it doesn't crash or print anything to the serial (as you can see all these have nested serial prints) to show those conditionals are triggered.

@tablatronix
Copy link
Collaborator

Those do not look like logs from development branch

@tablatronix tablatronix added DEV Help Wanted Developer Needs Help Question User Question member to member support labels Oct 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV Help Wanted Developer Needs Help Question User Question member to member support
Projects
None yet
Development

No branches or pull requests

3 participants