SparkFun ESP8266 WiFi shield not present on Arduino Mega 2560 REV3

I have an issue initializing the SparkFun ESP8266 WiFi shield with my Arduino Mega REV3. When I run the same code with an Arduino UNO it works without any problems.
What could be the problem?
The code that I'm running is this:

#include <WiFiEsp.h>
#include <SparkFunESP8266WiFi.h>
#include <WiFiEspClient.h>

char ssid[] = "NETWORK_NAME";
char password[] = "PASSWORD";

// Create an instance of the server
WiFiEspServer server(80);
void setup() {
  Serial.begin(9600);

  // Start the software serial connection with the ESP8266 module
  esp8266.begin();
  
  // Initialize the ESP8266 module
  WiFi.init(&esp8266);

  // Connect to WiFi network
  while ( WiFi.status() != WL_CONNECTED) {
    WiFi.begin(ssid, password);
    delay(10000);  // Wait 10 seconds for the connection to be established
  }

  // Start the server
  server.begin();
}
void loop (){
 //Some loop 
}

This is the output when I run the code

[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Cannot initialize ESP module

the AT firmware runs at 115200 baud.
make the shield connect to Serial1 or Serial3 of the Mega.
then https://github.com/JAndrassy/WiFiEspAT#getting-started

Your solution does not seem to work for me. I have tried to connect the TX and RX pin on the shield to RX1 and TX1 on the board, but that didn't do the trick. I also tried to change Serial1 to pin (6,7) and that failed as well. I took a picture of my hardware connection for illustration purposes.

you can switch the switch to SW UART so it doesn't conflict with the Serial connection to the computer.
then use jumper wires from pin 8 to RX1 and from pin 9 to TX 1.

I connected jump wires from pins 8 and 9 to every communication pin but the Arduino still can't find the shield. Can it be something wrong with the code?

#include <WiFiEsp.h>
#include <SparkFunESP8266WiFi.h>
#include <WiFiEspClient.h>

char ssid[] = "NETWORK_NAME";
char password[] = "PASSWORD";

// Create an instance of the server
WiFiEspServer server(80);
void setup() {
  Serial.begin(115200);

  // Start the software serial connection with the ESP8266 module
  esp8266.begin(115200);
  
  // Initialize the ESP8266 module
  WiFi.init(&esp8266);

  // Connect to WiFi network
  while ( WiFi.status() != WL_CONNECTED) {
    WiFi.begin(ssid, password);
    delay(10000);  // Wait 10 seconds for the connection to be established
  }

  // Start the server
  server.begin();
}
void loop (){
 //Some loop 
}

I have also tried the SparkFun ESP8266 AT Libary ESP8266_Shield_Demo example sketch and that doesn't work either with the Mega but with the UNO. Is it possible that the two component (SparkFun ESP8266 WiFi Shield and Arduino Mega 2560 REV3) aren't compatible with each other?

use Serial1 instead of esp8266

I still have the same output unfortunately

are you sure that there is an AT firmware in the shield?
upload the SerialPassthrough example (change it to use 115200 baud rate) and try to send some simple AT commands from Serial Monitor

When using that example nothing is shown on the monitor. I tried to follow this guide https://www.allaboutcircuits.com/projects/update-the-firmware-in-your-esp8266-wi-fi-module/ but I get access denied when trying to use the PuTTY program

use the Serial Monitor in IDE

How do I do that when I have no connection with the shield?

I'm not familiar with the SparkFun shield, but the library uses pins 8 & 9 for the Software Serial, which will not work on a Mega (the Rx pin must support pin change interrupts, those do not on a Mega). You would likely need to modify the library to change the pin numbers, or use Serial1/Serial2/Serial3 on a Mega. The constructor would need to be changed to

esp8266.begin(9600, ESP8266_HARDWARE_SERIAL);

to use hardware Serial on pins 0/1.

you have a connection because the SerialPassthrough sketc bridges USB to Serial1 and Serial1 is wired to RX and TX pins of the shield.
so please open the Serial Monitor and enter AT

I changed the pins in the library that are set to SerialSoftware. I tried to execute the change of code you provided but it's still the same result with both changes combined and separately.

I had the Serial Monitor open at all times and it did not respond with any output to any AT command I tried.

try to set the baud rates in the SerialPassthrough sketch to 74880 to see the boot log of the esp8266

and please check again that you set the switch to SW UART and wired RX to TX between SW UART pins of the shield and Serial1 pins of the Mega

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.