Here is the monitor after using the new if cycle. As you can see it says connected but after that it starts trying to reconnect again
I found out why it does not work. When I do the following
//communication with wifi module
monitor.flush();
Serial.println("AT");
delay(2000);
This should send an AT to the esp8266 and get an OK as a response. But it doesn't. I even tried to upload a blank program on Arduino and go on serial IDE and manually write AT command but it doesn't give me an OK. If I manually write anything on the serial monitor it completely ignores it. What am I doing wrong? Why am I not getting the response?
IT DOESNT RECOGNISE THE AT COMMAND AT ALL. I tried every tutorial anything. If I write at he completely ignores it