Post topics, source code that relate to the Arduino Platform

User avatar
By WalfasProject8
#35017 Hello everyone. I want to write an Arduino sketch that sends AT commands to the ESP automatically (without having to write them manually on the serial monitor). I've tryed to do this is declaring an array of strings with the AT commands:

Code: Select allString ordenes[]=
  {  "AT+CWMODE=3",
     "AT+CWQAP",
     "AT+CWJAP=\"charly\",\"contrase\"",
     "AT+CIFSR" ,
     "AT+CIPMUX=1",
     "AT+CIPSERVER=1,80",
     "END"                 
  };


Then writing this on the setup:
Code: Select all int index = 0;
     while(ordenes[index] != "END")
        {  WIFI1.println(ordenes[index++]);
           while ( true)
              {   String s = GetLineWIFI();
                  if ( s!= "") Serial.println(s);
                  if ( s.startsWith("no change")) 
                          break;
                  if ( s.startsWith("OK")) 
                          break;
                  if ( s.startsWith("ready")) 
                         break;
                  // if (millis()-T >10000) break;
              }
          Serial.println("....................");
      }


The problem is that, when I execute the program, the ESP goes crazy and it doesn't send all of the AT commands, I've tryed to fix this by putting a voltage regulator between the Arduino TX and the ESP RX, but it stills doing the same. Any help or feedback is aprecciated.
User avatar
By Venkatesh
#35024 1) Check baudrates (never use higher ones, lower is fine, but response from esp to arduino will be slightly slow)
2) I don't know how you are reading the response inside "GetLineWIFI".
3) for testing, just use more delay between each command send and check the response. Now you can see Whether you are getting response or not.
User avatar
By esp03madness
#35028 Can you post a sample of what you see?

Some general advice: each AT command involves a series of messages. The simplest case being just either "OK" or "ERROR". You need to look for these (with a timeout) after each command. You're sort of doing that, but hard to say where the problem is without seeing the output.