Can't send AT commands to ESP8266

Hi,
I trying to get the ESP8266 wifi module work with my Arduino Pro Mini. Sending commands via ftdi USB to serial module works - I use:

picocom /dev/ttyUSB0 --b 9600 --omap crcrlf --imap crcrlf

I can send AT commands to the ESP8266 and I receive the replies as well.

I connected the module to arduino pro mini. I use this simple sketch:

void setup()
{
  Serial.begin(9600);
    while (!Serial) {
    ; 
  }
  Serial.println("AT");
}

void loop(){
}

When I start serial monitor in Arduino IDE, I can see the version and "ready" string once the wifi module is powered on. I also see "AT" command which arduino sends via serial line. What is strange I can't see any reply from the module. And what is also interesting is - when I enter "AT" via arduino serial monitor, I receive the "OK" string in the monitor. So it looks from some reason the module does not receive "AT" from the arduino.
Any ideas what am I doing wrong?

This is a sample from the serial monitor (first 4 AT rows are sent by resetting arduino, further commands are typed via keyboard in arduino serial monitor):

Vendor:www.ai-thinker.com

SDK Version:0.9.5(b1)
Compiled @:Dec 25 2014, 21:50:58
ready
AT
AT
AT
AT

OK
AT+SOME_NON_EXISTENT_COMMAND

ERROR
AT

OK

I received new esp8266 wifi module today, so I will check whether this one will have the same issue.

You usually need "new line" which is provided by the Serial.println but also need the Carriage Return character:

DEC 13 / CR / D = Carriage Return
DEC 10 / LF / A = Line Feed/New Line
DEC 0 / NULL / 0 = Null to end string.

Try appending these to your string.

Maybe even try make your own char array and send that:

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {

// A = ASCII 65, T = ASCII 84, NewLine = ASCII 10, End Of String = ASCII 0, Carriage Return =ASCII 13
  char AT_command[5]={65,84,10,0,13};
  
  Serial.print(AT_command);
  
  delay(5000);

}

OK...that did not quite work...but I am fairly sure it has something to do with it.

OK. Tried thus myself late last night put of curiosity.
Did noT try it but I think, looking at other posts, you need to use the whole serial.available and serial.read functions to store the rx data in a holding array and then print.

I don't think you can use serial monitor at the same time rx/tx is connected to a device. You serial.print will go to the serial monitor and not to the device.

you either need to use software serial or use a mega.

OK, I did following test:

  • connect esp8266 rx/tx to the arduino's HW tx/rx
  • connect ftdi usb to serial converter to the soft serial pins - 10/11

And I would like just to read the HW serial (read what esp8266 sends) and print it to software serial

This is the sketch I used:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Then I start the picocom, I see "Hello, World?" message - so my soft serial via ftdi works and picocom can read it. Then I reset the esp8266 - then there should be this:

[code]
{$l��|�l�|
           �
             d�p�s��p�{���
                              B�p~�n�$no���bp��l{lr$p�o��$
                                                                 

cN�|l�$��p�|�n�$��OK, I did following test:

  • connect esp8266 rx/tx to the arduino's HW tx/rx
  • connect ftdi usb to serial converter to the soft serial pins - 10/11

And I would like just to read the HW serial (read what esp8266 sends) and print it to software serial

This is the sketch I used:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Then I start the picocom, I see "Hello, World?" message - so my soft serial via ftdi works and picocom can read it. Then I reset the esp8266 - then there should be this:

[code]
�e2Nn
                                                                                                  �ln{���o
                                                                                                            ll p�N�
                                                                                                                        r�ܜ��


                                                                                                                              cn�|쎏�p��oN��l �2Nn
                                                                                                                                                         �ln{���o
                                                                                                                                                                   ��l`p�o�
                                                                                                                                                                              {������

bN�|$��b��no�
                      �OK, I did following test:

  • connect esp8266 rx/tx to the arduino's HW tx/rx
  • connect ftdi usb to serial converter to the soft serial pins - 10/11

And I would like just to read the HW serial (read what esp8266 sends) and print it to software serial

This is the sketch I used:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Then I start the picocom, I see "Hello, World?" message - so my soft serial via ftdi works and picocom can read it. Then I reset the esp8266 - then there should be this:

[code]
�ool or�ےn
                                         {OK, I did following test:

  • connect esp8266 rx/tx to the arduino's HW tx/rx
  • connect ftdi usb to serial converter to the soft serial pins - 10/11

And I would like just to read the HW serial (read what esp8266 sends) and print it to software serial

This is the sketch I used:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Then I start the picocom, I see "Hello, World?" message - so my soft serial via ftdi works and picocom can read it. Then I reset the esp8266 - then there should be this:

r��N

                                                    rl r$��o��p�n���BreoNn�l�"�`�l#l�2�l�����
                                                                                                    

                                                                                                     ���dllrl�2�ll$n��
                                                                                                                          
                                                                                                                            
                                                                                                                             �
                                                                                                                               ��~�`
                                                                                                                                     ��$��pro�dc"���l$��#
                                                                                                                                                              l$pb�"r���crbr���d bl`l��N�n���ol���c2$

                         l rd�n't use rtc mem data

rl��od�

Ai-Thinker Technology Co.,Ltd.



ready

--> So at the very end of the output there is "Ai-Thinker Technology Co.,Ltd." and "ready" string.
But instead of it there is:

picocom /dev/ttyUSB0 --b 9600 --omap crcrlf --imap crcrlf
picocom v1.7

port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 9600
parity is      : none
databits are   : 8
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv
imap is        : crcrlf,
omap is        : crcrlf,
emap is        : crcrlf,delbs,

Terminal ready
Hello, world?

;$�<$�#�;��''��#;$8��$#'��#�$��$�ee''';��$ ;�#��#�$ �ee'�$���;���$�$�?�'#;�'$�nu���tXH;$��
��.��c��bL�
!

I am wondering why such behavior. Why can't I see at least "ready" string at the end?
Baud rates are correct - I can send commands and read the output properly using 115200 baud rate when using ftdi to esp8266.

Hi,
I just want to post an update - I got it working. I am not 100% sure, but it looks I have to use the same baud rate for both serial interfaces - hardware and software.
I set the default baud rate of esp8266 to 9600 and in my sketch I did the same for sw and hw serial.
Now at least I have the proper reply from esp8266 for AT commands.

Just to review: I have software serial interface (D10,D11) connected to ftdi usb-ttl which I monitor via picocom on my PC. HW serial TX, RX are connected to ESP8266.

This is the test sketch:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("SW Serial - Hello, world?");
}

void loop() { // run over and over
  Serial.println("AT");
  while (Serial.available()) {
    mySerial.write(Serial.read());
  }
  delay(2000);
}

This is the software serial's output:

picocom /dev/ttyUSB0 --b 9600 --omap crcrlf --imap crcrlf 
picocom v1.7

port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 9600
parity is      : none
databits are   : 8
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv
imap is        : crcrlf,
omap is        : crcrlf,
emap is        : crcrlf,delbs,

Terminal ready
SW Serial - Hello, world?

AT




OK

AT




OK

AT




OK

AT




OK

So now I can continue with some further experimenting which will use esp8266.