Unable to read or write to Serial on Uno and Nano for ESP8266

I have been struggling with this for a while, but just kept putting off asking for help. I have searched as far as I can with Google but just can't find the answer.

The two different types of boards I am using:
Arduino Nano
Arduino Uno

IDE: Arduino 1.8.5
OS: Windows 10 Home 64-bit (10.0, Build 17134)

I have tried:

  • Using all 4 of the different boards I have
  • Using different USB cables
  • Using different USB ports (USB 2.0 and USB 3.0)
  • Using Software Serial (a few different libraries that I found as well as the built in one)
  • Using Hardware Serial pins
  • Changing Baud rates in both the code as well as the Serial Monitor
  • Using board-powered 3v or 5v
  • Using externally-powered 3v or 5v
  • Pretty much every ESP8266 wiring diagram you can find on Google

I am sure that I am forgetting some other basic attempts at getting it to work.

The short explanation is that I am trying to get ESP8266 modules to work and have spent a lot of time learning about them. I purchased a USB to ESP8266 board to program them because I thought this was my issue. I have gotten the modules themselves to do everything that I want them to, but I just can't get them to work with the Arduino boards.

The issue is that I just can't get Serial to work on the boards with these modules. I'm not sure if there is a simpler way to test if the Serial pins work AT ALL though. I can't sent AT commands, I can't receive anything back from the module, and the Tx and Rx lights don't even indicate that the board is trying to communicate.

I am so frustrated, but only because I don't know what else to try. Please, any help or suggestions would be wonderful as I am all out of ideas.

Thank you for taking the time to read.

(deleted)

what esp8266 dev board you have? you want to use AT firmware? what pins did you use for SoftwareSerial? did you connect RX to TX? did you use 9600 baud on booth sides? with what code did you test?

spycatcher2k:
How do you think we feel, as you have provided no code, or a wiring diagram!

Like I said, I tried all the ones I could find, but this is the one I felt was probably the safest to not damage anything:

The code is irrelevant as I am trying to even do something as simple as send commands through the Serial Monitor, but here is an example of a Software Serial code I tried:

/ Basic serial communication with ESP8266
// Uses serial monitor for communication with ESP8266
//
//  Pins
//  Arduino pin 2 (RX) to ESP8266 TX
//  Arduino pin 3 to voltage divider then to ESP8266 RX
//  Connect GND from the Arduiono to GND on the ESP8266
//  Pull ESP8266 CH_PD HIGH
//
// When a command is entered in to the serial monitor on the computer 
// the Arduino will relay it to the ESP8266
//
 
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX
 
void setup() 
{
    Serial.begin(9600);     // communication with the host computer
    //while (!Serial)   { ; }
 
    // Start the software serial for communication with the ESP8266
    ESPserial.begin(9600);  
 
    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() );  }
 
    // listen for user input and send it to the ESP8266
    if ( Serial.available() )       {  ESPserial.write( Serial.read() );  }
}

A lot was changed from the code to test smaller issues (pins, naming, Baud rates, etc.).

Juraj:
what esp8266 dev board you have? you want to use AT firmware? what pins did you use for SoftwareSerial? did you connect RX to TX? did you use 9600 baud on booth sides? with what code did you test?

I have both the ESP8266-01 and 01S variants. Yes, I want to use AT firmware and went through a great many versions before I found one that worked for me. I tried quite a few different pins for SoftwareSerial just to be certain. For hardware Serial, I connected to pins 0 and 1 for RX and TX (tried reversing many times as well just in case).

Anything that is a simple solution that could be tested within seconds, I have probably tried.

This code i have tested and i found its ok

#include <SoftwareSerial.h>
#define RX 2
#define TX 3
String AP = "esp8266";       // CHANGE ME
String PASS = "Test123456"; // CHANGE ME
String API = "YOUR_API_KEY";   // CHANGE ME
String HOST = "api.thingspeak.com";
String PORT = "80";
String field = "field1";
int countTrueCommand;
int countTimeCommand; 
boolean found = false; 
int valSensor = 1;
SoftwareSerial esp8266(RX,TX); 
 
  
void setup() {
  Serial.begin(115200);
  esp8266.begin(115200);
  sendCommand("AT",5,"OK");
  sendCommand("AT+CWMODE=1",5,"OK");
  sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK");
}
void loop() {
 valSensor = getSensorData();
 String getData = "GET /update?api_key="+ API +"&"+ field +"="+String(valSensor);
sendCommand("AT+CIPMUX=1",5,"OK");
 sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
 sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");
 esp8266.println(getData);delay(1500);countTrueCommand++;
 sendCommand("AT+CIPCLOSE=0",5,"OK");
}
int getSensorData(){
  return random(1000); // Replace with 
}
void sendCommand(String command, int maxTime, char readReplay[]) {
  Serial.print(countTrueCommand);
  Serial.print(". at command => ");
  Serial.print(command);
  Serial.print(" ");
  while(countTimeCommand < (maxTime*1))
  {
    esp8266.println(command);//at+cipsend
    if(esp8266.find(readReplay))//ok
    {
      found = true;
      break;
    }
  
    countTimeCommand++;
  }
  
  if(found == true)
  {
    Serial.println("OYI");
    countTrueCommand++;
    countTimeCommand = 0;
  }
  
  if(found == false)
  {
    Serial.println("Fail");
    countTrueCommand = 0;
    countTimeCommand = 0;
  }
  
  found = false;
 }

AJITnayak:
This code i have tested and i found its ok

#include <SoftwareSerial.h>

#define RX 2
#define TX 3
String AP = “esp8266”;      // CHANGE ME
String PASS = “Test123456”; // CHANGE ME
String API = “YOUR_API_KEY”;  // CHANGE ME
String HOST = “api.thingspeak.com”;
String PORT = “80”;
String field = “field1”;
int countTrueCommand;
int countTimeCommand;
boolean found = false;
int valSensor = 1;
SoftwareSerial esp8266(RX,TX);

void setup() {
  Serial.begin(115200);
  esp8266.begin(115200);
  sendCommand(“AT”,5,“OK”);
  sendCommand(“AT+CWMODE=1”,5,“OK”);
  sendCommand(“AT+CWJAP=”"+ AP +"",""+ PASS +""",20,“OK”);
}
void loop() {
valSensor = getSensorData();
String getData = “GET /update?api_key=”+ API +"&"+ field +"="+String(valSensor);
sendCommand(“AT+CIPMUX=1”,5,“OK”);
sendCommand(“AT+CIPSTART=0,“TCP”,”"+ HOST +"","+ PORT,15,“OK”);
sendCommand(“AT+CIPSEND=0,” +String(getData.length()+4),4,">");
esp8266.println(getData);delay(1500);countTrueCommand++;
sendCommand(“AT+CIPCLOSE=0”,5,“OK”);
}
int getSensorData(){
  return random(1000); // Replace with
}
void sendCommand(String command, int maxTime, char readReplay) {
  Serial.print(countTrueCommand);
  Serial.print(". at command => “);
  Serial.print(command);
  Serial.print(” ");
  while(countTimeCommand < (maxTime*1))
  {
    esp8266.println(command);//at+cipsend
    if(esp8266.find(readReplay))//ok
    {
      found = true;
      break;
    }
 
    countTimeCommand++;
  }
 
  if(found == true)
  {
    Serial.println(“OYI”);
    countTrueCommand++;
    countTimeCommand = 0;
  }
 
  if(found == false)
  {
    Serial.println(“Fail”);
    countTrueCommand = 0;
    countTimeCommand = 0;
  }
 
  found = false;
}

Thanks for the code!

Unfortunately, I am getting the following returned:

0. at command => AT Fail
0. at command => AT+CWMODE=1 Fail

To test it, I tried:

  • 3 different cables
  • Both models of Arduino boards
  • Both models of ESP8266
  • 2 different PCs

24 total tests.

SoftwareSerial at 115200 baud? use 9600. set it to the AT firmware too

Can you share me how you connected. How you setting serial monitor. how you setting Arduino environment for esp8266 in images.