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
}
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?
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
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
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.