'Whats wrong with my code? Using Arduino Uno R3 with esp01s and AT Commands

Im trying to set up a webserver to receive Sensordata from my Arduino. I am using the Arduino Uno R3 and the ESP8262 / ESP01S (Those little wifi "only" chips). The Internet is full of different versions and methods, but non works with my set up at all.

Got some basic ideas from here, where i also got the electrical diagram. Information about AT-Commands from here, but it seems that not all of them work with the ESP01S, only some. The Basic Code ideas from this Gentleman. And also from this fellow i took the "wait for result" function.

Programming is defently not new to me, but why shoud i invent a new wheel, when there is much to take out there. My Problem is, when i use the following Code there is no response from the ESP. But when i upload "BareMinimum" Sketch and then plug in the Wifi-Shield to pins 0(TX) and 1(RX) (see secound link) i am able to send the same AT-Commands and get a response. So something must be wrong with that way of coding, but i couldnt figure it out. Maybe You have some Solutions. At first i thought i can not use the pins 8 and 9, but it seems to me the AltSoftSerial.h needs those to work. So basically i am running out of ideas and slutions from the internet. And yes, i already tried the code without the if(Check ==1) stuff, but then i get nothing from the function. Just those lines "----" between the println methods.

I am programming with the Arduino IDE, using the "Arduino Board" in tools and no additional board administrator url's (not sure what that is named in the english version of Arduino IDE).

#include <AltSoftSerial.h>
// Arduino pin 08 for RX
// Arduino Pin 09 for TX
 
AltSoftSerial espSerial;
 
void setup(){
      int check = 1;
      Serial.begin(9600);
      Serial.println("Start\r\n\");
      espSerial.begin(115200); 

      // reset the ESP8266
      if (check==1){
        Serial.println("reset the module"); 
        espSerial.print("AT+RST\r\n");
        check = wait4result( "OK", 6000); // wait for esp to return "OK" or timeout after 1s if it doesn't appear.
      } 
      // configure as a station
      if (check==1){
        Serial.println("Change to station mode"); 
        espSerial.print("AT+CWMODE=1\r\n");
        check = wait4result( "OK", 6000); 
      }
      //set mac, ip and hostname
      if (check==1){
        Serial.println("Set MAC, IP, Hostname");
        espSerial.print("AT+CIPSTAMAC=\"DE,AD,BE,EF,FE,AA\"\r\n");
        espSerial.print("AT+CIPSTA=\"xxx.xxx.xxx.xxx\",\"xxx.xxx.xxx.x\",\"xxx.xxx.xxx.x\"\r\n");
        espSerial.print("AT+CWHOSTNAME=\"Test1\"\r\n");
        check = wait4result( "OK", 6000); 
      }
      // Enter the SSID and password for your own network
        if (check==1){
        espSerial.print("AT+CWJAP=\"FRITZ!Box xxxx xx\",\"xxxxxxxxxxxxxxxxxxxx\"\r\n");
        check = wait4result( "OK", 6000); 
      }
      // configure for multiple connections
      if (check==1){
        Serial.println("Set for multiple connections"); 
        espSerial.print("AT+CIPMUX=1\r\n");
        check = wait4result( "OK", 6000); 
      }
      // start server on port 80
      if (check==1){
        Serial.println("Start the server"); 
        espSerial.print("AT+CIPSERVER=1,80\r\n");
        check = wait4result( "OK", 6000); 
      }
      if (check==1){
        Serial.println("");
        Serial.println("Waiting for page request");
        Serial.println("");
      } else {
        Serial.println("");
        Serial.println("Vorgang Fehlgeschlagen");
        Serial.println("");
      }
}
void loop(){
  
}
int wait4result(char *s, unsigned short timeout) {
      unsigned long tm=millis();
      //print Return from ESP 
      while( millis() - tm <= timeout ) {
        if (espSerial.find(s)) { // match result
          Serial.println(s);
          return 1;
        }
      }
      // send timeout msg to console.
      Serial.print(F("TimedOutWaitingFor: "));
      Serial.println(s);
      return 0;
} 

I replaced stuff like ip Adress with some x's for privacy. And there is the output from the Seriel Monitor. "Vorgang Fehlgeschlagen" is german and basically means, it doesnt work...

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source