ESP 8266 + Arduino Nano 3

Hey!

I just bought a ESP 8266, but It’s difficult to put it to work.

What I have so far:

VCC and CH_PD → External font 3,3v
TX → D3
RX → D2
GND → External font Ground.

To test if everything is working fine, I just use this code:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(3,2);

void setup()
{
  mySerial.begin(9600);                 
  Serial.begin(9600);                 
}

void loop()
{

    Serial.write(mySerial.read());

    mySerial.write(Serial.read()); 

}

The Blue LED blinks, and the serial monitor prints “þñ|}ù”;

It doesn’t matter which AT command I pass to the board, it gives me this weird characters.

I’ve tried a bunch of different bauds, but some doesn’t work, others keep printing those characters.

What exactly is happening?

I've tried a bunch of different bauds, but some doesn't work, others keep printing those characters.

Garbled characters usually indicate mismatched baud rates. I've never us SoftwareSerial, so not familiar with that. If you want to try directly communicating from the serial monitor to the ESP 8266, load the below dummy program on the arduino, then connect the ESP 8266 tx to the arduino tx, and the ESP 8266 rx to the arduino rx (make sure the grounds are connected). Also note that the serial monitor probably needs to be set to add a carriage return and new line characters to the at commands sent.

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

The ESp8266 is a 3.3v device and I would recommend putting a voltage divider between D2 and RX. You may also need a pull up resistor on CH_PD. take a .look at Arduino to ESP8266

As zoomket says above, garbage characters are usually a sign of a wrong baud rate. I have various ESP8266s and they had different baud rates when I received them; 9600, 38400 and 115200.

A simply way to check is to connect the ESP8266 to the Arduino, run the sketch, open the serial monitor and then cycle the power of the ESP8266. If you can read the start message you have the correct baud rate. If you get garbage characters, change the baud rate in the sketch and try again.

The baud rate you set in a Serial() call must match the ESP8266’s current default baud rate. You can change that yourself through an AT command, but until you do, you have to use its current baud rate. You can’t just force it to use a given baud rate like 9600 by using it in the Serial call.

Also, you need to level-shift the Rx/Tx signals between the ESP8266 & Arduino, or else it won’t work no matter the baud rate, reliably at least, and you risk frying the ESP8266 if you don’t.

Plus, the ESP8266 needs to get its 3.3v from a source other than the Arduino’s 3.3v pin, which is way too underpowered to properly power the ESP8266.