WifiManager not working



  • This is my first project using a wemos D1 mini.
    I have written a sketch for door entry exit system running on a wemos D1 mini that now runs as I want it to.
    I am trying to add wifimanager auto connect, if I upload the sketches one at a time both work fine. If I merge the two, the sketch uploads fine, however just hangs. There is no web server AP or anything.

    Please can anyone see anything that jumps out below that would cause the auto connect not to function.

    Thanks in advance.

    #include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
    #include <DNSServer.h>
    #include <ESP8266WebServer.h>
    #include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
    #include <Keypad.h>
    #include <Password.h>

    String newPasswordString; //hold the new password
    char newPassword[6]; //charater string of newPasswordString
    boolean stringComplete = false;

    Password password = Password( "1234" );//initialize password to 1234

    byte maxPasswordLength = 6;
    byte currentPasswordLength = 0;
    const byte ROWS = 4; // Four rows
    const byte COLS = 4; // Four columns

    //Define the keymap
    char keys[ROWS][COLS] = {
    {'1', '2', '3', 'A'},
    {'4', '5', '6', 'B'},
    {'7', '8', '9', 'C'},
    {'*', '0', '#', 'D'}
    };

    byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad
    byte colPins[COLS] = {4, 3, 2, 1};//connect to the column pinouts of the keypad

    // Create the Keypad
    Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

    void setup() {
    // put your setup code here, to run once:
    Serial.begin(115200);

    //WiFiManager
    //Local intialization. Once its business is done, there is no need to keep it around
    WiFiManager wifiManager;
    //reset saved settings
    //wifiManager.resetSettings();
    
    //set custom ip for portal
    //wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
    
    //fetches ssid and pass from eeprom and tries to connect
    //if it does not connect it starts an access point with the specified name
    //here  "AutoConnectAP"
    //and goes into a blocking loop awaiting configuration
    wifiManager.autoConnect("CynthiaGate");
    //or use this for auto generated name ESP + ChipID
    //wifiManager.autoConnect();
    
    
    //if you get here you have connected to the WiFi
    Serial.println("connected...yeey :)");
    

    }

    void loop() {
    char key = keypad.getKey();
    if (key != NO_KEY) {
    delay(60);
    switch (key) {
    case 'A': break;
    case 'B': break;
    case 'C': break;
    case 'D': changePassword(); break;
    case '*': checkPassword(); break;
    case '#': resetPassword(); break;
    default: processNumberKey(key);
    }
    }
    }

    void processNumberKey(char key) {
    Serial.print(key);
    currentPasswordLength++;
    password.append(key);
    if (currentPasswordLength == maxPasswordLength) {
    checkPassword();
    }
    }

    void checkPassword() {
    if (password.evaluate()) {
    Serial.println(" OK.");
    } else {
    Serial.println(" Wrong passwowrd!");
    }
    resetPassword();
    }

    void resetPassword() {
    password.reset();
    currentPasswordLength = 0;
    }

    void changePassword() {

    newPasswordString.toCharArray(newPassword, newPasswordString.length() + 1); //convert string to char array
    password.set(newPassword);
    resetPassword();
    Serial.print("Password changed to ");
    Serial.println(newPasswordString);

    // Read serial input:
    while (Serial.available() > 0) {
    int inChar = Serial.read();
    if (isDigit(inChar)) {
    // convert the incoming byte to a char
    // and add it to the string:
    newPasswordString += (char)inChar;
    }
    // if you get a newline, print the string,
    // then the string's value:
    if (inChar == '#') {

      if (inChar == '*') {  // If carriage return
        stringComplete = true;
    
      }
    }
    

    }

    }



  • @andi968

    When including code for people to review create a new line and enter three backticks. (The backtick is the key above the 'Tab' key.) On the next line, paste your code. Then on a new blank line, place three more backticks to end the code segment.

    // This is code because its preceded and followed by three backticks e.g. ```
    

Log in to reply
 

Looks like your connection to WEMOS Forum was lost, please wait while we try to reconnect.