This is just a statement. What is your question?
If you are too lazy to even write down a specific question
The users here are too lazy to speculate what your question might be
what do you think is the meaning of the comment above these two lines of code?
It might be that your code is causing a reset which makes your code start again over and over
Add Serial.prints in your setup-function to narrow down where in the code the reset occurs
Here is a demo-code for ESP32-boards which prints more information to the serial monitor.
// Demo-Code connect an ESP32 to a WiFi-network using stationmode STA
// stationmode is simply join the WiFi-network as your computer or smartphone does it
// the code has three useful functions one for easy identifiying the code in the flash
// one for non-blocking timing
// a heartbeat-blinker function for indicating the state the code is in
// the code is written with two programming rules:
// 1. put EACH functionality into its OWN function
// 2. give EACH function a SELF-explaining name what the function does
// you should follow these programming rules
#include <WiFi.h>
// fill in YOUR SSID and YOUR password
const char *ssid = "YOUR SSID??";
const char *password = "YOUR password?";
void PrintFileNameDateTime() {
Serial.println( F("Code running comes from file ") );
Serial.println( F(__FILE__));
Serial.print( F(" compiled ") );
Serial.print(F(__DATE__));
Serial.print( F(" ") );
Serial.println(F(__TIME__));
}
boolean TimePeriodIsOver (unsigned long &periodStartTime, unsigned long TimePeriod) {
unsigned long currentMillis = millis();
if ( currentMillis - periodStartTime >= TimePeriod )
{
periodStartTime = currentMillis; // set new expireTime
return true; // more time than TimePeriod) has elapsed since last time if-condition was true
}
else return false; // not expired
}
unsigned long MyTestTimer = 0; // variables MUST be of type unsigned long
const byte OnBoard_LED = 2;
void BlinkHeartBeatLED(int IO_Pin, int BlinkPeriod) {
static unsigned long MyBlinkTimer;
pinMode(IO_Pin, OUTPUT);
if ( TimePeriodIsOver(MyBlinkTimer, BlinkPeriod) ) {
digitalWrite(IO_Pin, !digitalRead(IO_Pin) );
}
}
void ScanForWiFis() {
Serial.println("start scanning for WiFi...");
int numberOfNetworks = WiFi.scanNetworks();
Serial.println("scanning finished");
Serial.print("number of networks: ");
Serial.println(numberOfNetworks);
for (int i = 0; i < numberOfNetworks; i++) {
Serial.print("Network name: ");
Serial.println(WiFi.SSID(i));
Serial.print("Signal strength: ");
Serial.println(WiFi.RSSI(i));
Serial.println("---------------------- -");
}
}
void ConnectToWiFi() {
const byte maxCount = 60;
WiFi.mode(WIFI_STA);
Serial.println("WiFi.mode(WIFI_STA)");
int myCount = 0;
Serial.print("trying to connect to #");
Serial.print(ssid);
Serial.println("#");
WiFi.begin(ssid, password);
// Wait for connection
while (WiFi.status() != WL_CONNECTED && myCount < maxCount) {
BlinkHeartBeatLED(OnBoard_LED, 50); // blink LED fast during attempt to connect
yield();
if ( TimePeriodIsOver(MyTestTimer, 500) ) { // once every 500 miliseconds
Serial.print("."); // print a dot
myCount++;
if (myCount > maxCount) { // after 60 dots = 30 seconds restart
Serial.println();
Serial.print("trying to connect to WiFi with SSID ");
Serial.print(ssid);
Serial.println(" failed start scanning WiFis");
ScanForWiFis();
Serial.print("are you sure that the SSID ");
Serial.println(ssid);
Serial.print(" and password are correct ? ");
}
}
}
if (WiFi.status() == WL_CONNECTED ) {
Serial.println("");
Serial.print("Connected to #");
Serial.print(ssid);
Serial.print("# IP address: ");
Serial.println(WiFi.localIP());
}
}
void setup() {
Serial.begin(115200);
Serial.println( F("Setup - Start") );
PrintFileNameDateTime();
ConnectToWiFi();
}
void PrintHelloMsg() {
Serial.print( F("Hi there I'm the demo-code my IP address is: ") );
Serial.println(WiFi.localIP());
}
void loop() {
BlinkHeartBeatLED(OnBoard_LED, 500); // change blinking to a lower frequency indicating beeing connected
if ( TimePeriodIsOver(MyTestTimer, 1000) ) {
PrintHelloMsg();
}
}
/*
most ESP32 boards have a blue LED connected to GPIO-pin 2
This blue LED is used to indicate state connecting to WiFi by blinking fast
state beeing connected to Wifi by blinking with 1 Hz
If the WiFi-connection is successfully established the serial monitor shows
08:44:02.915 -> Setup-Start
08:44:02.915 -> Code running comes from file
08:44:02.915 -> your-path\ESP32-connect-to-Wifi-Demo-001\ESP32-connect-to-Wifi-Demo-001.ino
08:44:02.915 -> compiled date/time of compiling
08:44:02.971 -> WiFi.mode(WIFI_STA)
08:44:02.971 -> trying to connect to #Your SSID#
08:44:03.362 -> ....
08:44:04.215 -> Connected to #Your SSID# IP address: given IP-adress NNN.NNN.NNN.NNN
08:44:04.865 -> Hi there I'm the demo - code my IP address is : NNN.NNN.NNN.NNN
if trying to connect to the wifi fails the code scans for WiFis
and lists up all found SSIDs
So you can compare the SSIDs with the one used in the code
*/
If your board is not an ESP32 post the exact type of board you are using
Im not sure what had happened. It didnt seem to be a brownout. But yes something in the code was causing a loop.
I did remove my wifi credentials and added the generic SSID and Pass.
I rewrote the code using a differnet libraries.
I suspect it was something in the way i was calling the AsyncElegantOTA.begin(&server).
But if that was it im not sure. But thank you to everyone who commented.
And apologies for not formulating my problem better.
But all that was happening was the serial monitor was stuck in a loop. Not establishing an actual connection to the router.
Typically the esp32 displays an ip address and i can view that device from the router or via the ip address but niether of those methods worked. Once the ip address is obtained the serial monitor would either show the outputs being requested or not print anything else.
This was just looping the same pieces of information and completing the full connection.
I have solved the issue of the boot. But i have about 10 more im currently working through.
So once i have those done. I will be sure to add the working version of the code.
Coding is still new to me. So i have a lot to learn