ESP8266 (ESP-01) Troubleshooting help

I purchased two "Addicore" ESP8266 (ESP-01) modules from Amazon (link) a few years ago and am just now trying to see if I can get one of them to work with my Arduino Mega.

I first searched this forum for instructions/libraries/examples and in (this) thread, I was sent over to GitHub (here).

The README.md indicates that this library is for the ESP-01 module (which is what (I believe) I have).

I have installed (this) 3.3 <-> 5v logic level converter between the Arduino and the ESP8266.

My connections from the ESP8266 through the logic level converter to the Arduino are as follows:

Ground -> Ground (below pin53)
GPIO2 -> (not connected)
GPIO0 -> (not connected)
TX -> Serial1 RX (Pin7)
RX -> Serial1 TX (Pin6)
CH_PD -> 3.3v (via Pin38)
RST -> (not connected)
VCC -> 3.3v (via Pin38)

Here is my code:

/*
 /*
 WiFiEsp example: WebClient
 This sketch connects to google website using an ESP8266 module to
 perform a simple web search.
 For more details see: http://yaab-arduino.blogspot.com/p/wifiesp-example-client.html
*/

#include "WiFiEsp.h"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(7, 6); // RX, TX
#endif

char ssid[] = "FBI Field Operations";            // your network SSID (name)
char pass[] = "5634Brier";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
int wifiPower = 38;

char server[] = "arduino.cc";

// Initialize the Ethernet client object
WiFiEspClient client;

void setup()
{
  // Take pin 38 "HIGH" to turn on WiFi module
  pinMode(wifiPower, OUTPUT); 
  digitalWrite(wifiPower, HIGH);
  
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(9600);
  // initialize ESP module
  WiFi.init(&Serial1);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  // you're connected now, so print out the data
  Serial.println("You're connected to the network");
  
  printWifiStatus();

  Serial.println();
  Serial.println("Starting connection to server...");
  // if you get a connection, report back via serial
  if (client.connect(server, 80)) {
    Serial.println("Connected to server");
    // Make a HTTP request
    client.println("GET /asciilogo.txt HTTP/1.1");
    client.println("Host: arduino.cc");
    client.println("Connection: close");
    client.println();
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

    // do nothing forevermore
    while (true);
  }
}


void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

The code compiles fine with no errors.
The light on the Logic level converter is on (as expected).
The light (red) on the ESP8266 turns on as long as pin38 is set to "HIGH".

On the serial monitor when running the code, I am getting the following error(s):

[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Cannot initialize ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] No tag found
WiFi shield not present

I have tried the following:

  • Changing the baud rate for Serial1 (ESP8266 TX/RX) (300, 1200, ... , 250000)
  • Flipping the RX/TX pin assignment in my code
  • Applying 3.3v to the RST pin (via Pin38)

Do you have any idea what I'm doing wrong?

PS - sorry that this post got so long - I wanted to add all the info and provide all of the answers to the obvious questions that will undoubtedly come...

chipreibel:
TX -> Serial1 RX (Pin7)
RX -> Serial1 TX (Pin6)

This is wrong. Serial1 RX is pin 19 on the Mega and Serial1 TX is pin 18 on the Mega. You're getting confused by this code:

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(7, 6); // RX, TX
#endif

That code will use the SoftwareSerial library to create a Serial1 on boards that don't have a hardware Serial1 but the Mega does have a hardware Serial1 and the HAVE_HWSERIAL1 macro is defined so that code never runs when you're compiling for the Mega.

chipreibel:
Changing the baud rate for Serial1 (ESP8266 TX/RX) (300, 1200, ... , 250000)

The default baud rate of the ESP8266 AT firmware is 115200 so I'd use that:

  // initialize serial for ESP module
  Serial1.begin(115200);

Thanks, Pert - I didn't catch that. I was thinking that the library was reassigning the pins - I didn't realize that it couldn't reassign them if they were on the board already.

The problem is that it still didn't work, though. My pinout is now:
Ground -> Ground (below pin53)
GPIO2 -> (not connected)
GPIO0 -> (not connected)
RX -> Serial1 TX (Pin18)
TX -> Serial1 RX (Pin19)
CH_PD -> 3.3v (via Pin38)
RST -> (not connected)
VCC -> 3.3v (via Pin38)
I also changed the baud rate at 115200 as you recommended.

I tried:

  • swapping the TX/RX lines
  • Changing the baud rate for Serial1 (ESP8266 TX/RX) (300, 1200, ... , 250000)
  • commenting out the "Emulate Serial1 pins" section of code
  • shorting pins 7 & 8 (providing 3.3v to the RST pin

My code is now this:

/*
 WiFiEsp example: WebClient
 This sketch connects to google website using an ESP8266 module to
 perform a simple web search.
 For more details see: http://yaab-arduino.blogspot.com/p/wifiesp-example-client.html
*/

#include "WiFiEsp.h"

/*// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif*/

char ssid[] = "FBI Field Operations";            // your network SSID (name)
char pass[] = "********";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
int wifiPower = 38;

char server[] = "arduino.cc";

// Initialize the Ethernet client object
WiFiEspClient client;

void setup()
{
  // Take pin 38 "HIGH" to turn on WiFi module
  pinMode(wifiPower, OUTPUT); 
  digitalWrite(wifiPower, HIGH);
  
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(115200);
  // initialize ESP module
  WiFi.init(&Serial1);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  // you're connected now, so print out the data
  Serial.println("You're connected to the network");
  
  printWifiStatus();

  Serial.println();
  Serial.println("Starting connection to server...");
  // if you get a connection, report back via serial
  if (client.connect(server, 80)) {
    Serial.println("Connected to server");
    // Make a HTTP request
    client.println("GET /asciilogo.txt HTTP/1.1");
    client.println("Host: arduino.cc");
    client.println("Connection: close");
    client.println();
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

    // do nothing forevermore
    while (true);
  }
}


void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Any other ideas/suggestions?

This morning, I tried the following:

  • Using Serial2 and Serial3 (instead of Serial1)
  • Adapting the code so that I could use the Serial port instead of Serial1. (I changed all of the serial.print commands to lcd.print so that they would output on my I2C LCD instead of the serial monitor, freeing up the TX/RX on ports 1/0 for the WiFi module.)

Still no luck - Same error(s).

Any other ideas/suggestions that I can try?

I'd connect the ESP-01 up so you can send AT commands directly from Serial Monitor to verify the ESP8266 has the AT firmware installed and which version of the firmware it has.

I have uploaded several other Example sketches all of which claim that there is no response form the module.

I have attempted to send AT+ commands through the Serial interface (using all of the sketches) and don't get any responses from the module.

Perhaps this means that the modules were shipped without SW? I started to look at the firmware upload tools, and it appears as though they are more for writing software for the ESP, not for "standard setup"...

I'm not sure what to do/try next (other than hook the module up to mains voltage and let the smoke out - At least it would bring a small (and short lived) smile to my face!) LOL

https://www.allaboutcircuits.com/uploads/articles/Flashing_Circuit_Schematic.jpg shows the circuit of how the ESP-01 should be connected.

Ignore the two switches in the circuit which are used for updating the firmware.

The ESP-01 default AT firmware baud rate is 115200 as I recall. I haven't worked with them in a few months.

You should connect up directly between the PC and the ESP-01 using a USB-TTL adapter.

I found out quite by accident that if I use a USB-TTL adapter with the CP2102 chip I don't have to worry about 3.3V-5V translation. https://www.amazon.com/CP2102-UART-6PIN-Serial-Converter/dp/B00CD264HG is what I have which I bought on eBay

I would not use the Arduino until you know what ESP-01 module you have.

.

Aha. Same here. it Appears as if the AT command set firmware is not present. But you can upload sketches to the ESP01

setup
CH_PD is connected to VCC
Pull GPIO2 to VCC via 10k
Pull GPIO0 to VCC via 10k

the connect GPIO0 to GND, RTS tap to GND and then run esptool.py. ( pip3 install esptool)
( this appears tp be the same loader as the IDE)

All commands load a stub, run it, the a hard reset. The full output for the chip_id command:

chip_id - Read Chip ID from OTP ROM

$ esptool.py --port /dev/ttyUSB0 --baud 115200 --chip esp8266 chip_id
esptool.py v2.6
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP8266EX
Features: WiFi
MAC: a0:20:a6:0c:79:02
Uploading stub...
Running stub...
Stub running...
Chip ID: 0x000c7902
Hard resetting via RTS pin...

flash_id - Read SPI flash manufacturer and device ID
$ esptool.py --port /dev/ttyUSB0 --baud 115200 --chip esp8266 flash_id
...
Manufacturer: e0
Device: 4014
Detected flash size: 1MB

read_mac - Read MAC address from OTP ROM

$ esptool.py --port /dev/ttyUSB0 --baud 115200 --chip esp8266 read_mac
...
MAC: a0:20:a6:0c:79:02

Using the Arduino IDE

generic ESP8266 module

Select sketch - blinker

Load

To load, same setup as noted above GPIO0 to vcc with a 10k, then pull the GPIO to GND, toggle RST, then upload.
once complete, let GPIO0 be pulled to VCC, Toggle Rest and watch the Port output

there is and issue and output is at 74880 baud

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vac02aff5
~ld

Sketch Check Flash Config

  • load
  • Run
    r _ outpout at 74880 from exception handler

Flash real id: 001440E0
Flash real size: 1048576 bytes

Flash ide size: 1048576 bytes
Flash ide speed: 40000000 Hz
Flash ide mode: DIO
Flash Chip configuration ok.

More later ...