Need help with my Code - Webserver AP and Station Mode


Code and Schematics

Hey, i really need help with my code. It is quite a long code i would be happy if anyone could take a look over it.
This code is for my Automated window Control. Where you can Open the Window via Buttons, IR Remote, and Web Interface. There is an Automatic mode which looks at a microphone signal (the microphone signal gets amplified and then runs over an envelope demodulator so i have enough time to look at the signal) When its too loud the window closes and if its quiet for long enough it opens the window again. My goal is that it starts the AP Mode where i can enter Wifi Cridentials, and then the esp connects to the entered WiFi and shows the main Control Webpage. Right now it connects to the entered WiFi, but it just shows the AP Mode Website, so the ap_mode_html, and not the cotrol website so the index_html. How do i get it to show the control Website after Connecting. I will upload the full code as a TextFile and the Schematics as screenshots, one schematic is the whole circuit and one is just the microphone amplifier circuit.
If you find any other mistakes please be welcome and correct me.
The code runs on the 2 different cores of the ESP32 one handles the logic and one handles the Webserver
These are tho logic Functions running on one core

messStrom(): Measures the current flowing through the motor to determine if the motor has reached an obstacle or is blocked.
findeMittelpunkt(): Moves the window to its middle position by first moving in one direction until an obstacle is detected, then moving in the opposite direction for half the measured time.
istAnschlagErreicht(): Checks if the motor has reached an obstacle based on the current measurement.
forward() and reverse(): Control the motor's direction of rotation for opening or closing the window, respectively.
stopMotor(): Stops the motor.
checkMotorError(): Checks for motor errors based on a possible error indicator signal.
handleButtons(): Processes input from physical buttons for manual control commands.
handleIR(): Processes infrared commands from a remote control.
handleCurrent(): Monitors motor current to detect overload or blockage.
handleSerial(): Allows for control and monitoring of the system via the serial interface.
handleNoiseControl(): Implements logic for automatic control based on noise level measurements.
handleOeffnen(), oeffnenVonMitte and schliessenVonMitte(): Functions for opening or closing the window from/to its middle position.
handleAutomaticModeLED(): Controls the LED display for automatic mode.

These are the webServer Funtions
startAPMode(): Initiates the Access Point (AP) mode, allowing the user to connect to the ESP32 and configure WiFi settings via a webpage.
setupWiFiAndWebServer(): Configures the WiFi connection and initializes the web server for normal operation mode.
processor(): Used to insert dynamic content into webpages.

Thanks in advance i really hope somone can help, and if you need any additional info feel free to ask. Thanks!!!

Hi @haraldfriedrich119

welcome to the arduino-forum.

The minimum required is your complete sketch. Even if your sketch is 3000 lines long
From the info you have posted it is unclear what libraries you are using and it is unclear what the detail-logic of your code is

You can post your sketch as a code-section

I have never used two cores not for webservers nor for anything else

This is a little confusing, I'm not sure if I'm getting this right. Do you want to have one landing page when the browser is connecting through AP and the other when the browser is connecting through STA? This is probably just for convenience, so that STA configuration through AP is easier? And you probably want to store STA credentials so when ESP starts again it would pick up lastly saved STA credentials? Which ESP are you using?