Having problems with ESP2866 keeps restarting while using AP/WIFI and firebase

Hello I'm new to Arduino and esp2866. I'm building a wireless controlled relay through nodemcu v3 with esp2866, I'm using fire base as my database. I wanted to add a schedule functionality where I can set time shutdown or power on. Unfortunately when I add this date ( DateTimeCheck() ) code it just keeps tripping.

Here my code:

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <WiFiManager.h>
#include <NTPClient.h>
#include <WiFiUdp.h>  //wifimanager by tzapu ver 2.0
#include <time.h>
// esp8266 ver 2.7.4
// ntpclient ver 3.2.1
// ArduinoJSON ver 5.13.4
// Firebase Arduino Client Library - mobiz - 4.2.6 - https://github.com/mobizt/Firebase-ESP-Client
// CHECK https://www.youtube.com/watch?v=8ZSjrvJL3dY&t=159s TO CONFIGURE CONNECTION
// https://www.instructables.com/NodeMCU-ProjectButton-Control-LED/ LED SWITCH
// https://dronebotworkshop.com/wifimanager/ WIFI MANAGER
#define FIREBASE_HOST ""
#define FIREBASE_AUTH ""
#define RELAY_PIN_1 D2
#define SWITCH_1 D1
#define LED_GREEN D6
int buttonState = 0;
int monthDay = 0;
int currentYear = 0;
int currentMonth = 0;
int timeout = 120;

unsigned long lastMillis;
String IOTSPPDVName = "IOTSPPDV001";
String FBrelaystatus = "";
String FBCurrentDate = "";
String FBCurrentTime = "";
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org");
//Week Days
//String weekDays[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
void setup() {

  WiFi.mode(WIFI_STA);  // explicitly set mode, esp defaults to STA+AP
  // it is a good practice to make sure your code sets wifi mode how you want it.

  // 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 wm;

  // reset settings - wipe stored credentials for testing
  // these are stored by the esp library
  //wm.resetSettings();

  // Automatically connect using saved credentials,
  // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
  // if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect())
  // then goes into a blocking loop awaiting configuration and will return success result

  bool res;
  // res = wm.autoConnect(); // auto generated AP name from chipid
  // res = wm.autoConnect("AutoConnectAP"); // anonymous ap
  res = wm.autoConnect("IOTSPPDV001");  // password protected ap

  if (!res) {
    Serial.println("Failed to connect");
    // ESP.restart();
  } else {
    //if you get here you have connected to the WiFi
    Serial.println("connected...yeey :)");
    Serial.println(WiFi.localIP());
    Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
    pinMode(RELAY_PIN_1, OUTPUT);
    pinMode(LED_GREEN, OUTPUT);
  }
  pinMode(SWITCH_1, INPUT);
  timeClient.begin();
  timeClient.setTimeOffset(28800);
  timeClient.update();  // utc +8
 // DateTimeCheck();
  //rescheck
  int resStat = Firebase.getInt(IOTSPPDVName + "/rescheck");
  resStat = resStat + 1;
  Firebase.setInt(IOTSPPDVName + "/rescheck", resStat);
}

int n = 0;

void loop() {


  buttonState = digitalRead(SWITCH_1);  // put your main code here, to run repeatedly:
  if (buttonState == 1) {
    Serial.println("1:)");
    delay(200);
    Serial.println("EXECUTE AP RESET");
    WiFiManager wm;
    //reset settings - for testing
    wm.resetSettings();
    ESP.restart();
  }
  FBrelaystatus = Firebase.getString(IOTSPPDVName + "/Relay_status");  // get ld status input from firebase
  if (FBrelaystatus == "ON") {                                         // compare the input of led status received from firebase
    //Serial.println("Led Turned ON");
    RelaySwitch(1);
  } else if (FBrelaystatus == "OFF") {  // compare the input of led status received from firebase
    //Serial.println("Led Turned OFF");
    RelaySwitch(0);
    // make external led OFF
  } else {
    Serial.println("Command Error! Please send ON/OFF");
    Serial.println(FBrelaystatus);
  }
  if (millis() - lastMillis >= 1 * 60 * 1000UL) {
    lastMillis = millis();  //get ready for the next iteration
     // DateTimeCheck();
  }
}
void RelaySwitch(int SwitchMode) {
  if (SwitchMode == 1) {
    digitalWrite(RELAY_PIN_1, LOW);
    digitalWrite(LED_GREEN, HIGH);
    Firebase.setString(IOTSPPDVName + "/Relay_status", "ON");
  } else {
    digitalWrite(RELAY_PIN_1, HIGH);
    digitalWrite(LED_GREEN, LOW);
    Firebase.setString(IOTSPPDVName + "/Relay_status", "OFF");
  }
}
/*void DateTimeCheck()
      {
      timeClient.update();
      time_t epochTime = timeClient.getEpochTime();
      struct tm *ptm = gmtime((time_t *)&epochTime);
      monthDay = ptm->tm_mday;
      currentMonth = ptm->tm_mon + 1;
      currentYear = ptm->tm_year + 1900;
      String formattedDate = String(currentYear) + String(currentMonth) + String(monthDay);

      String FBCurrentDate = Firebase.getString(IOTSPPDVName + "/Schedule/0/Date");
      String FBCurrentTime = Firebase.getString(IOTSPPDVName + "/Schedule/0/Time");
      String FBSchedSwitch = Firebase.getString(IOTSPPDVName + "/Schedule/0/Switch");
      String isFBExecuted = Firebase.getString(IOTSPPDVName + "/Schedule/0/Executed");

      if (formattedDate == FBCurrentDate && isFBExecuted == "0") {
        String formattedTime = String(timeClient.getHours());
        formattedTime = formattedTime + ":" + String(timeClient.getMinutes()) + ":00";

        Serial.println(formattedTime);
        if (formattedTime == FBCurrentTime) {
          Serial.print("time and date the samee");
          if (FBSchedSwitch == "true") {
            RelaySwitch(1);
            Firebase.setString(IOTSPPDVName + "/Schedule/0/Executed", "1");
          } else {
            RelaySwitch(0);
            Firebase.setString(IOTSPPDVName + "/Schedule/0/Executed", "1");
          }
        }
        Serial.println("samedate");
      } else {
        Serial.print("Not the same date");
      }
    }

here the error/

Exception (9):
epc1=0x40217198 epc2=0x00000000 epc3=0x00000000 excvaddr=0x3a39466e depc=0x00000000

stack>>>

ctx: cont
sp: 3ffff9c0 end: 3fffffc0 offset: 0190
3ffffb50: 00000000 00000001 3ffffc14 3ffef158
3ffffb60: 0000000b 3ffef120 3fff0450 4020fbb0
3ffffb70: 3ffe8894 000001bb 3fff0450 40210a70
3ffffb80: 3ffe8943 0000003b 3fff0450 40210e98
3ffffb90: 0000003b 3ffef120 0000002e 402046d4
3ffffba0: 3ffffbe8 0000003b 3ffffbd0 40212498
3ffffbb0: 3ffef11c 3ffffbd0 3ffe8943 3ffffc50
3ffffbc0: 3ffef11c 3ffffc14 3fff044c 4020600f
3ffffbd0: 3fff0734 003b003f 00fffc14 3fff0614
3ffffbe0: 0051005f 00ff0064 3fff0694 0028002f
3ffffbf0: 00fe88de 3ffef118 3fff0081 3ffffc50
3ffffc00: 3ffef11c 3ffe88c5 3fff05ec 40203d10
3ffffc10: 3ffeff14 3fff06d8 3ffffcc0 3ffef020
3ffffc20: 3ffffcc0 3ffffc50 3ffe88de 40204698
3ffffc30: 3ffffc58 3ffffc70 3ffffc70 3ffef020
3ffffc40: 3ffffcc0 3fff05ec 3ffef118 40204f89
3ffffc50: 3ffef158 3fff0098 3ffffcc0 4021244f
3ffffc60: 3fffdad0 3ffef118 3ffffcf0 4020501a
3ffffc70: 00000001 3fff0064 3ffffcc0 40212498
3ffffc80: 3ffeff14 3ffef0b4 3ffffcc0 3ffef020
3ffffc90: 3fffdad0 3ffef118 3ffffcc0 40212aca
3ffffca0: 3ffe86ff 3ffffcc0 3ffef0b4 402122d4
3ffffcb0: 3fffdad0 3ffef118 3ffef0b4 40201217
3ffffcc0: 3fff0064 001d001f 00000683 32323000
3ffffcd0: 00353231 80fffd00 3f003200 3ffef2b8
3ffffce0: 80ffdad0 32323000 00000000 80100a67
3ffffcf0: 00000000 4bc6a7f0 de76c8b4 39333a31
3ffffd00: 0030303a 87000000 32323032 00353231
3ffffdb0: 00000000 00000000 feefef03 00000000
3ffffdc0: 00000000 00000000 00000046 feefef35
3ffffdd0: 6e2d6f00 fe007465 80efeffe feefef00
3ffffde0: feefeffe 80efeffe feefef00 feefeffe
3ffffdf0: 80efeffe feefef00 feefeffe 80efeffe
3ffffe00: feefef00 feefeffe 80efeffe feefef00
3ffffe10: feefeffe 80efeffe 00000000 00000000
3ffffe20: 00000000 00000001 00505300 feefeffe
3ffffe30: 80efeffe 000007d0 01000100 feefef00
3ffffe40: 00000000 0050ef00 07010101 ffffffff
3ffffe50: 00000000 00000000 01000001 00010101
3ffffe60: 01010001 01010001 00000000 00040000
3ffffe70: 80000000 3ffe88de 3ffe88de feefef00
3ffffe80: 00000000 00000000 0000001f 40100198
3ffffe90: 80efeffe feefef01 3fffc228 401051a1
3ffffea0: 4000050c 2c9f0300 8000050c 00000000
3ffffeb0: 402137bc 00000030 00000010 ffffffff
3ffffec0: 402137bc 0000c8ed 0000ea5f 00000000
3ffffed0: 00004bc6 00000000 000007b3 000000b3
3ffffee0: 00000250 3fffc6fc 00000000 3ffef278
3ffffef0: 00000000 3fffdad0 3ffef2b8 00000030
3fffff00: 00000000 3fffdad0 3ffef2b8 00000000
3fffff10: feefeffe feefeffe feefeffe 00000000
3fffff20: feefeffe feefeffe feefeffe 00000000
3fffff30: feefeffe feefeffe feefeffe 00000000
3fffff40: feefeffe feefeffe feefeffe 00000000
3fffff50: feefeffe feefeffe feefeffe 00000000
3fffff60: 007a1200 3afc1174 feefef00 00000000
3fffff70: 00000000 3fff0000 0014001f 80efeffe
3fffff80: 00000000 00000000 00000001 40100198
3fffff90: 3fffdad0 3fff2c00 0018001f 801001b9
3fffffa0: 3fffdad0 00000000 3ffef278 402137bc
3fffffb0: feefeffe feefeffe 3ffe8580 40100d79
<<<stack<<<

With ESP, you have to feed the output to the exception decoder.

What part of your code is the "this date code" that you say introduces the error? Why is there a huge commented out section? What are we supposed to think about that?

sorry about that, I pasted this from my sketch, I added a comment to isolate that specific function.

I tried installing the decoder from in the ide, it wont show in the tools menu.

I tried troubleshooting the program to isolate the problematic code. I notice that when I add DateTimeCheck() function which I added a comment, the board restarts.

Is it watchdogging ?
Needing to implement a yield(); ?

I don't know if this is useful information, but when I downgrade to esp 2.3.0 without the DateTimeCheck() it doesn't trip. The only reason why I'm not using it because is outdated.

Is there are way to know?

All information is useful. You are advised to share it in the first post, next time you create a topic.

a way to know
if it's staying in a function or waiting for something that keeps it from getting back to the top of the loop (approx 2.5 secs ??) then it will watchdog.
It will show up in the Crash Log as "wdt reset".

Update it seems that the problem is not just on DateTimeCheck() function, I tried running the program overnight on esp8266 ver 2.7.4, it restarts every 30-40 mins. Now I'm confused. Maybe its the firebase that is the problem? Downloading older ide to open decoder.

That would result in a different error.

Refers to an alignment issue, the 4 byte addresses need to be aligned. I have had this error, but not recently.

i think your issue might be with this

#include <time.h>

as i understood it, you don't need that on an esp8266.

Hi everyone I manage to get decodes the error, I honestly don't understand what this means. My hunch is the wifi manager /ap manager. any idea how to implement a better ap/wifi functionality? thank you.

Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address
Decoding 24 results
0x40211a14: EspClass::getCpuFreqMHz() at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Esp.cpp line 499
0x4020afe0: WiFiManager::wifiConnectDefault() at C:\Users\marla\OneDrive\Documents\Arduino\libraries\WiFiManager-master/WiFiManager.cpp line 3244
0x4020be9c: WiFiManager::waitForConnectResult(unsigned int) at C:\Users\marla\OneDrive\Documents\Arduino\libraries\WiFiManager-master/WiFiManager.cpp line 3244
0x4020c2c8: WiFiManager::processConfigPortal() at C:\Users\marla\OneDrive\Documents\Arduino\libraries\WiFiManager-master/WiFiManager.cpp line 3244
0x40204278: WiFiClientSecure::_connectSSL(char const*) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClientSecure.cpp line 517
0x4020cf0c: WiFiManager::handleWifi(unsigned char) at C:\Users\marla\OneDrive\Documents\Arduino\libraries\WiFiManager-master/WiFiManager.cpp line 3244
0x40205bb3: std::string::assign(char const*, unsigned int) at c:\users\marla\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 732
0x402038b4: WiFiClient::~WiFiClient() at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClient.cpp line 149
0x4020423c: SSLContext::connect(ClientContext*, char const*, unsigned int) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClientSecure.cpp line 517
:  (inlined by) WiFiClientSecure::_connectSSL(char const*) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClientSecure.cpp line 279
0x40204b2d: UdpContext::UdpContext() at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiUdp.cpp line 283
0x4020cec3: WiFiManager::handleWifi(unsigned char) at C:\Users\marla\OneDrive\Documents\Arduino\libraries\WiFiManager-master/WiFiManager.cpp line 3244
0x40204bbe: WiFiUDP::beginPacketMulticast(IPAddress, unsigned short, IPAddress, int) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiUdp.cpp line 283
0x4020cf0c: WiFiManager::handleWifi(unsigned char) at C:\Users\marla\OneDrive\Documents\Arduino\libraries\WiFiManager-master/WiFiManager.cpp line 3244
0x4020d53a: DEBUG_WM  at C:\Users\marla\OneDrive\Documents\Arduino\libraries\WiFiManager-master/WiFiManager.cpp line 3244
:  (inlined by) WiFiManager::debugSoftAPConfig() at C:\Users\marla\OneDrive\Documents\Arduino\libraries\WiFiManager-master/WiFiManager.cpp line 3348
0x402012dd: delay at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/core_esp8266_wiring.c line 45
0x40212120: Print::println(String const&) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Print.cpp line 64
0x40212120: Print::println(String const&) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Print.cpp line 64
0x40212120: Print::println(String const&) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Print.cpp line 64
0x40212120: Print::println(String const&) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Print.cpp line 64
0x40212120: Print::println(String const&) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Print.cpp line 64
0x40212120: Print::println(String const&) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Print.cpp line 64
0x401001b1: umm_assimilate_down at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266\umm_malloc/umm_malloc.c line 1187
0x4020e1a4: WiFiManager::handleUpdate() at C:\Users\marla\OneDrive\Documents\Arduino\libraries\WiFiManager-master/WiFiManager.cpp line 3244
0x40100d71: __adddf3 at d:\ivan\projects\arduinoesp\toolchain\dl\gcc-xtensa\build-2\xtensa-lx106-elf\libgcc/../../../libgcc/config/xtensa/ieee754-df.S line 283

Another decoded exception. This time I added the DateTimeCheck() function, updated the espboard to 2.7.4, and removed <time.h>. It seems to have a problem with the wifi manager and data regarding firebase. Do you have any clue how to fix it?

Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address
Decoding 40 results
0x402172dc: HTTPClient::connected() at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.cpp line 475
0x4020fc18: HTTPClient::disconnect(bool) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.cpp line 434
0x40210b38: HTTPClient::end() at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.cpp line 425
0x40210f64: HTTPClient::begin(String, unsigned short, String, String) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.cpp line 379
0x40204700: std::string::_Rep::_M_destroy(std::allocator  const&) at c:\users\marla\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 452
0x40212574: String::copy(char const*, unsigned int) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/WString.cpp line 214
0x4020603b: FirebaseHttpClientEsp8266::begin(std::string const&, std::string const&) at C:\Users\marla\OneDrive\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseHttpClient_Esp8266.cpp line 51
0x40203d3c: FirebaseRequest::sendRequest(std::string const&, std::string const&, char*, std::string const&, std::string const&) at C:\Users\marla\OneDrive\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.cpp line 73
0x402046c4: std::basic_string  , std::allocator  >::basic_string(char const*, std::allocator  const&) at c:\users\marla\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 218 (discriminator 2)
0x40204fb5: FirebaseArduino::getRequest(String const&) at C:\Users\marla\OneDrive\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.cpp line 101
0x4021252b: String::reserve(unsigned int) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/WString.cpp line 146
0x40205046: FirebaseArduino::getString(String const&) at C:\Users\marla\OneDrive\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.cpp line 132
0x40212574: String::copy(char const*, unsigned int) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/WString.cpp line 214
0x40212ba6: operator+(StringSumHelper const&, char const*) at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/WString.cpp line 417 (discriminator 2)
0x402123b0: String::~String() at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/WString.cpp line 125
0x40201217: DateTimeCheck() at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/WString.h line 324
:  (inlined by) DateTimeCheck() at C:\Users\marla\OneDrive\Documents\Arduino\FirebaseDemo_ESP8266 - FIREBASE CONECTION_v2-20221204T102749Z-001\FirebaseDemo_ESP8266 - FIREBASE CONECTION_v2\old ide\sketch_dec05a/sketch_dec05a.ino line 135
0x40201072: _Z11RelaySwitchi$part$1 at C:\Users\marla\OneDrive\Documents\Arduino\FirebaseDemo_ESP8266 - FIREBASE CONECTION_v2-20221204T102749Z-001\FirebaseDemo_ESP8266 - FIREBASE CONECTION_v2\old ide\sketch_dec05a/sketch_dec05a.ino line 122
0x402015d6: loop at C:\Users\marla\OneDrive\Documents\Arduino\FirebaseDemo_ESP8266 - FIREBASE CONECTION_v2-20221204T102749Z-001\FirebaseDemo_ESP8266 - FIREBASE CONECTION_v2\old ide\sketch_dec05a/sketch_dec05a.ino line 111
0x402179f8: WiFiServer::_s_discard(void*, ClientContext*) at ?? line ?
0x402179f8: WiFiServer::_s_discard(void*, ClientContext*) at ?? line ?
0x402179f8: WiFiServer::_s_discard(void*, ClientContext*) at ?? line ?
0x402179f8: WiFiServer::_s_discard(void*, ClientContext*) at ?? line ?
0x402179f8: WiFiServer::_s_discard(void*, ClientContext*) at ?? line ?
0x402179f8: WiFiServer::_s_discard(void*, ClientContext*) at ?? line ?
0x402179f8: WiFiServer::_s_discard(void*, ClientContext*) at ?? line ?
0x40104825: lmacTxFrame at ?? line ?
0x4010440a: lmacMSDUAged at ?? line ?
0x40103c75: lmacRecycleMPDU at ?? line ?
0x4010430d: lmacMSDUAged at ?? line ?
0x40104586: lmacProcessCtsTimeout at ?? line ?
0x401028cb: wDev_ProcessFiq at ?? line ?
0x40100198: ets_post at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/core_esp8266_main.cpp line 177
0x40102584: wDev_ProcessFiq at ?? line ?
0x402015e4: loop at C:\Users\marla\OneDrive\Documents\Arduino\FirebaseDemo_ESP8266 - FIREBASE CONECTION_v2-20221204T102749Z-001\FirebaseDemo_ESP8266 - FIREBASE CONECTION_v2\old ide\sketch_dec05a/sketch_dec05a.ino line 111
0x40213898: loop_wrapper() at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/core_esp8266_main.cpp line 197
0x40100198: ets_post at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/core_esp8266_main.cpp line 177
0x40213898: loop_wrapper() at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/core_esp8266_main.cpp line 197
0x40100d55: esp8266::polledTimeout::timeoutTemplate   >::expiredRetrigger() at C:\Users\marla\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/PolledTimeout.h line 237

I never use wifimanager, because it doesn't provide me with a server on both AP & STA (AP is used only to set the STA credentials)
You can serve a page to enter and load credentials if that is a requirement for your project, and store them in EEPROM.
As for a ready made setup. WiFiManager is the only one that i know of, but you can of course attempt to contact the Author on github and see if there is information there (or open an issue)

Possibly, but i don't want to disable my ad-blocker to read that.
you can post the code here and then i'll have a look.
It is not hugely complicated to do.

oh sorry about that

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
#include <EEPROM.h>
 
//Variables
int i = 0;
int statusCode;
const char* ssid = "text";
const char* passphrase = "text";
String st;
String content;
 
 
//Function Decalration
bool testWifi(void);
void launchWeb(void);
void setupAP(void);
 
//Establishing Local server at port 80 whenever required
ESP8266WebServer server(80);
 
void setup()
{
 
  Serial.begin(115200); //Initialising if(DEBUG)Serial Monitor
  Serial.println();
  Serial.println("Disconnecting previously connected WiFi");
  WiFi.disconnect();
  EEPROM.begin(512); //Initialasing EEPROM
  delay(10);
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.println();
  Serial.println();
  Serial.println("Startup");
 
  //---------------------------------------- Read EEPROM for SSID and pass
  Serial.println("Reading EEPROM ssid");
 
  String esid;
  for (int i = 0; i < 32; ++i)
  {
    esid += char(EEPROM.read(i));
  }
  Serial.println();
  Serial.print("SSID: ");
  Serial.println(esid);
  Serial.println("Reading EEPROM pass");
 
  String epass = "";
  for (int i = 32; i < 96; ++i)
  {
    epass += char(EEPROM.read(i));
  }
  Serial.print("PASS: ");
  Serial.println(epass);
 
 
  WiFi.begin(esid.c_str(), epass.c_str());
  if (testWifi())
  {
    Serial.println("Succesfully Connected!!!");
    return;
  }
  else
  {
    Serial.println("Turning the HotSpot On");
    launchWeb();
    setupAP();// Setup HotSpot
  }
 
  Serial.println();
  Serial.println("Waiting.");
  
  while ((WiFi.status() != WL_CONNECTED))
  {
    Serial.print(".");
    delay(100);
    server.handleClient();
  }
 
}
void loop() {
  if ((WiFi.status() == WL_CONNECTED))
  {
 
    for (int i = 0; i < 10; i++)
    {
      digitalWrite(LED_BUILTIN, HIGH);
      delay(1000);
      digitalWrite(LED_BUILTIN, LOW);
      delay(1000);
    }
 
  }
  else
  {
  }
 
}
 
 
//-------- Fuctions used for WiFi credentials saving and connecting to it which you do not need to change 
bool testWifi(void)
{
  int c = 0;
  Serial.println("Waiting for Wifi to connect");
  while ( c < 20 ) {
    if (WiFi.status() == WL_CONNECTED)
    {
      return true;
    }
    delay(500);
    Serial.print("*");
    c++;
  }
  Serial.println("");
  Serial.println("Connect timed out, opening AP");
  return false;
}
 
void launchWeb()
{
  Serial.println("");
  if (WiFi.status() == WL_CONNECTED)
    Serial.println("WiFi connected");
  Serial.print("Local IP: ");
  Serial.println(WiFi.localIP());
  Serial.print("SoftAP IP: ");
  Serial.println(WiFi.softAPIP());
  createWebServer();
  // Start the server
  server.begin();
  Serial.println("Server started");
}
 
void setupAP(void)
{
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0)
    Serial.println("no networks found");
  else
  {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i)
    {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
      delay(10);
    }
  }
  Serial.println("");
  st = "<ol>";
  for (int i = 0; i < n; ++i)
  {
    // Print SSID and RSSI for each network found
    st += "<li>";
    st += WiFi.SSID(i);
    st += " (";
    st += WiFi.RSSI(i);
 
    st += ")";
    st += (WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*";
    st += "</li>";
  }
  st += "</ol>";
  delay(100);
  WiFi.softAP("how2electronics", "");
  Serial.println("softap");
  launchWeb();
  Serial.println("over");
}
 
void createWebServer()
{
 {
    server.on("/", []() {
 
      IPAddress ip = WiFi.softAPIP();
      String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
      content = "<!DOCTYPE HTML>\r\n<html>Hello from ESP8266 at ";
      content += "<form action=\"/scan\" method=\"POST\"><input type=\"submit\" value=\"scan\"></form>";
      content += ipStr;
      content += "<p>";
      content += st;
      content += "</p><form method='get' action='setting'><label>SSID: </label><input name='ssid' length=32><input name='pass' length=64><input type='submit'></form>";
      content += "</html>";
      server.send(200, "text/html", content);
    });
    server.on("/scan", []() {
      //setupAP();
      IPAddress ip = WiFi.softAPIP();
      String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
 
      content = "<!DOCTYPE HTML>\r\n<html>go back";
      server.send(200, "text/html", content);
    });
 
    server.on("/setting", []() {
      String qsid = server.arg("ssid");
      String qpass = server.arg("pass");
      if (qsid.length() > 0 && qpass.length() > 0) {
        Serial.println("clearing eeprom");
        for (int i = 0; i < 96; ++i) {
          EEPROM.write(i, 0);
        }
        Serial.println(qsid);
        Serial.println("");
        Serial.println(qpass);
        Serial.println("");
 
        Serial.println("writing eeprom ssid:");
        for (int i = 0; i < qsid.length(); ++i)
        {
          EEPROM.write(i, qsid[i]);
          Serial.print("Wrote: ");
          Serial.println(qsid[i]);
        }
        Serial.println("writing eeprom pass:");
        for (int i = 0; i < qpass.length(); ++i)
        {
          EEPROM.write(32 + i, qpass[i]);
          Serial.print("Wrote: ");
          Serial.println(qpass[i]);
        }
        EEPROM.commit();
 
        content = "{\"Success\":\"saved to eeprom... reset to boot into new wifi\"}";
        statusCode = 200;
        ESP.reset();
      } else {
        content = "{\"Error\":\"404 not found\"}";
        statusCode = 404;
        Serial.println("Sending 404");
      }
      server.sendHeader("Access-Control-Allow-Origin", "*");
      server.send(statusCode, "application/json", content);
 
    });
  } 
}

Well yeah that is not quite what i meant, but i guess it could work.

I start the unit in AP mode using.

WiFi.softAP(apname, appass);

and serve a page using the ESP8266webserver, in which the user can enter credentials, picking a network from the scan. connect to that network, and if connected, store that network in EEPROM, for retrieval when restarted. I guess you would have to check if the last save network is actually available etc.
Unfortunately (for you) i don't have a simple example of that for you.

Once you launch the webserver, you aren't going to want to have any delays. Those are going to trip your watchdog timer. The wifi radio can't be blocked from performing whatever function it wants to when it wants to. You have two 1000 ms delays in your loop. Those are going to cause issues I think.

I think the server is not at all accessible from within loop() this is more or less the part of the code that becomes available once STA has started. Also it seems to drop AP-mode (or at least it doesn't reconnect whatever device is connected to it) But server.handleClient() is not called from loop at all. This snippet is more as an example i think.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.