issue with WifiManager

Hi,

With the below code used in a Sonoff, the led and relay stay on at power up and during the setup procedure (about 15 seconds).

Based on the captured debug text, the problem is related to the WifiManager library. I’m saying that because the relay and led go off right after this line: *WM: freeing allocated params!

How do I fix it?
TIA

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println("---> Starting setup <---");

  pinMode(dhtPin , INPUT);
  pinMode(buttonPin, INPUT);
  pinMode(relayPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(relayPin, HIGH);
  digitalWrite(ledPin, LOW);

  WiFiManager wifiManager;

  //set static ip
  IPAddress _ip = IPAddress(192, 168, 0, 150);
  IPAddress _gw = IPAddress(192, 168, 0, 1);
  IPAddress _sn = IPAddress(255, 255, 255, 0);

  wifiManager.setSTAStaticIPConfig(_ip, _sn, _gw);

  //fetches ssid and pass from eeprom and tries to connect

  wifiManager.autoConnect("SONOFF");
  delay(100);

  Serial.println("connected...yeey :)");

  //start DHT
  dht.setup(dhtPin );

  // Setup a function to be called every 6 minutes
  timer.setInterval(360000, getExtIP);  //get IP from web
  timer.setInterval(10000, getTemp);  //get temp & humidity

  //web pages
  server.on("/", handleRoot);
  server.on("/led", handle_led);
  server.on("/login", handleLogin);
  server.on("/inline", []() {
    server.send(200, "text/plain", "this works without need of authentification");
  });

  server.onNotFound(handleNotFound);
  
  //here the list of headers to be recorded
  const char * headerkeys[] = {"User-Agent", "Cookie"} ;
  size_t headerkeyssize = sizeof(headerkeys) / sizeof(char*);
  
  //ask server to track these headers
  server.collectHeaders(headerkeys, headerkeyssize );
  
  server.begin();
  Serial.println("HTTP server started");

  getExtIP();
  Serial.println("--> Ended setup <--");

  void loop() {}

debug text:

17:14:34.166 -> --> Starting setup <--
17:14:34.166 -> *WM: 
17:14:34.166 -> *WM: AutoConnect
17:14:34.166 -> *WM: Connecting as wifi client...
17:14:34.166 -> *WM: Custom STA IP/GW/Subnet
17:14:34.199 -> *WM: 192.168.0.150
17:14:34.199 -> *WM: Using last saved values, should be faster
17:14:37.997 -> *WM: Connection result: 
17:14:37.997 -> *WM: 3
17:14:37.997 -> *WM: IP Address:
17:14:37.997 -> *WM: 192.168.0.150
17:14:38.098 -> connected...yeey :)
17:14:38.098 -> HTTP server started
17:14:49.251 -> --> Ended setup <--
17:14:49.251 -> *WM: freeing allocated params!

you are setting your relay HIGH and led LOW before any of this is happening. Depending on your wiring, that may put them in the ON state. Only you know for sure.

Have you tried changing them?