1
votes

i am connecting my esp8266 to my arduino nano

ESP Tx > Arudino Tx
ESP Rx > Arduino Rx
ESP 3.3v > Arduino 3v3
ESP Dh_cp > Arduino 3v3
ESP Gnd > Arduino Gnd

I am supplying arduino nano via usb and 12V at VIN, using a common ground for all

I have tried all baud rates and sent AT commands at all. The ESP8266's red light is always on and blue light only turns on at start, arduino's TX Red light is always on when ESP8266 is connected as well.

As a last resort, I tried flashing the ESP8266 with a firmware from the espressif site, i flashed the nonos sdk (non boot version) v2.0.0.

the Serial Monitor does not show anything on any baud rate

I have tried many codes i found online, like the code here : but mainly i use a blank code as i want to just connect the esp8266 to the arduino and get it to give some kind of feedback that it is working for now. like in this link : http://randomnerdtutorials.com/getting-started-with-esp8266-wifi-transceiver-review/

Using this code

#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX

void setup() 
{
    Serial.begin(115200);     // communication with the host computer
    //while (!Serial)   { ; }

    // Start the software serial for communication with the ESP8266
    ESPserial.begin(115200);  

    Serial.println("");
    Serial.println("Remember to to set Both NL & CR in the serial monitor.");
    Serial.println("Ready");
    Serial.println("");    
}

void loop() 
{
    // listen for communication from the ESP8266 and then write it to the serial monitor
    if ( ESPserial.available() )   {  Serial.write( ESPserial.read() );  } else { Serial. println("not ready");}

    // listen for user input and send it to the ESP8266
    if ( Serial.available() )       {  ESPserial.write( Serial.read() );  }
}

the serial monitor constantly printed "not ready" so im guessing the ESP module is not available to be read from, but i dont know how we can diagnose the problem from this

when flashing i used baud rate 115200

Using this circuit to test as well http://www.martyncurrey.com/wp-content/uploads/2015/01/Arduino-to-ESP8266.jpg

4
Comments are not for extended discussion; this conversation has been moved to chat.Bhargav Rao♦

4 Answers

0
votes

ESP Rx -> Arudino Tx ESP Tx -> Arduino Rx

Change it , i think it will work

good luck.

0
votes

If you just want to use AT commands then just upload a blank sketch having void setup(){}
void loop(){} in it. Also, keep your wiring as it is. I am doing the same thing exactly and it is working fine with me. You can refer to this link also https://www.instructables.com/id/Getting-Started-With-the-ESP8266-ESP-01/

0
votes

You should always cross RX (Receive) with TX (Transmit) like this:

ESP Rx > Arudino Tx

ESP Tx > Arduino Rx

ESP 3.3v > Arduino 3v3

ESP Dh_cp > Arduino 3v3

ESP Gnd > Arduino Gnd

You should also conciser an external power supply, because ESP require more amps, than Arduino can provide, and It probably will not work properly (for sure not reliably).

(Do not forget to make a common GND for arduino, power supply and ESP)

0
votes

The other answers all bring up something you should change, but these probably aren't the culprit of the problem. There is one fatal error. Software serial does not work at a baud rate of 115200. You must connect the ESP8266 to the TX and RX pins with a blank sketch and change the baud rate of the ESP8266 to 9600 before software serial will be able to pick it up.

Also, I don't think that code will be able to properly receive the return. Try something more along this:

#define RX_PIN 3
#define TX_PIN 2
#define ESP_BRATE 9600

SoftwareSerial esp8266(RX_PIN, TX_PIN);

bool at_command(String command, int timeout_ms, String* output) {
  esp8266.println(command);

  String ret;

  int start_time = millis();
  while (timeout_ms == -1 || millis() < start_time + timeout_ms) {
    String line = esp8266.readStringUntil('\n');
    if (line == "OK\r") {
      if (output) {
        *output = ret;
      }
      return true;
    }
    if (line == "ERROR\r") {
      if (output) {
        *output = ret;
      }
      return false;
    }

    ret += line;
    ret += '\n';
  }
  if (output) {
    *output = ret;
  }
  return false;
}

void setup()
{
  Serial.begin(9600);
  while (!Serial) {
    delay(10);
  }

  esp8266.begin(ESP_BRATE); // I changed this on the ESP to 9600
  while (!esp8266) {
    delay(10);
  }

  String out;
  bool ret;

  ret = at_command("AT", -1, &out);
  Serial.println(out);
  if (!ret) {
    Serial.println("AT is not returning OK");
    return;
  }

Full example code for an ESP8266-01 based weather station can be found here and might help show you what to do. It includes lots of documentation about using the ESP and should get you to where you need to be!