ESP8266 and Arduino – SoftwareSerial vs Serial problem

arduinoesp8266

I'm using Arduino Nano and ESP8266.

When I setup like the picture and connect Arduino Nano to PC by USB: enter image description here

The ESP8266 properly works. (Arduino Nano is just used as a bridge)

I print and read from serial with a C# program, it correctly works.

What I send from C# program:

AT+CWJAP="APN", "Pass"

The message from ESP:

AT+CWJAP="APN", "Pass"
OK

But, when I change the setup as follows:

  • Green wire (green wire on picture) to Arduino Digital2 pin
  • Red wire (red wire on picture) to Arduino Digital3 pin
  • Use Arduino code to read/write serial, instead of C# program
  • Create a software serial from code (esp8266 = SoftwareSerial(2, 3))

What I send from SoftwareSerial:

AT+CWJAP="APN", "Pass"

The message from ESP:

AT+CWJAP="APN", "Pass"
ERROR

Do you have any ideas? Why isn't the result on SoftwareSerial identical to Serial?

Best Answer

This is the info taken from arduino website:

The library has the following known limitations:

1) If using multiple software serial ports, only one can receive data at a time.

2) Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

This has not explicitly mentioned the board you are using, but I think these limitations are on hardware level. Changing the software serial pins should most likely take care of this issue.