Help with esp8266 and Arduino Mega

Serial communication only allows one thing at a time, AT commands or pass through data from MEGA to WiFi. You will not be able to do both at same time.

All I can suggest is double/triple check all connections, sketch settings, power, etc… basicly that error says no communication, and bad hardware connection or mismatched BAUD rates are the other culprits aside from power.

Also, make sure you are NOT using SoftwareSerial with the MEGA and pins 18-19, but instead using Serial1

Yes all connection correct like you send in the link
But how you update esp8266 frimware and it’s important ???

In Shield mode the ESP only uses the AT firmware… it basically becomes a simple Serial to WiFi adapter.

Typically like this for the MEGA

#define ESP8266_BAUD 115200  // For ESP link
ESP8266 wifi(&Serial1);  // Pins 18 & 19 on MEGA - For ESP link

// in setup
Serial.begin(115200);  // BLYNK_PRINT data - For Serial Monitor
Serial1.begin(ESP8266_BAUD);  // Set ESP8266 baud rate - For ESP link

Can you send all code

i can’t write more replies now but i give up it’s not working ,why it’s doing this:tired_face::expressionless::worried:

https://examples.blynk.cc/?board=Arduino%20Mega%202560&shield=ESP8266%20WiFi%20Shield&example=GettingStarted%2FBlynkBlink

1 Like

Confirm which exact ESP you have (show link or picture if you can).

Confirm if you are using the UNO or the MEGA for the rest of this troubleshooting

Post the sketch that YOU have loaded on either the UNO or MEGA (depending on which one you wish to troubleshoot)

As per your initial post, reprint the wiring schema that you are using for whichever Arduino we will troubleshoot.

PS. Sorry, I do not offer troubleshooting via YouTube. You are already a Basic user, and I don’t like to manually advance users too quickly past that level, so you need to wait until the system allows you to post again (or keep reading posts as that will also accelerate your advancement),… Besides I am heading to sleep :sleeping: I will check in later.

this is the code:

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "4d00839f76124c83a10*******";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Blin*****";
char pass[] = "AF2******";

// Hardware Serial on Mega, Leonardo, Micro...


// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:


ESP8266 wifi(&EspSerial);

void setup()
{
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(9600);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
}

void loop()
{
  Blynk.run();
}

with arduino uno and i can use mega
software or hardware
and this is the module:

can the problem be from frimware??or connection??

So using above method you would have pin 2 on the UNO going to TX on the ESP, and Pin 3 on the UNO going to RX on the ESP. The ESP needs to be running AT firmware (probably pre-installed when you got it) and preset for 9600 BAUD (usualy it’s default is 115200)

SoftSerial will work with either UNO or MEGA, but you get better results on the MEGA with Serial1 (Note the 1 at the end) as following code (and as already posted in previous post)… with Pin 18 to ESP TX and pin 19 to ESP RX, and changing the ESP setting to 11500 BAUD via AT command before hooking it up to the Arduino as below.

// or Software Serial on Uno, Nano...
// #include <SoftwareSerial.h>
// SoftwareSerial EspSerial(2, 3); // RX, TX

// Hardware Serial on Mega, Leonardo, Micro...
#define ESP8266_BAUD 115200  // For ESP link
ESP8266 wifi(&Serial1);  // Pins 18 & 19 on MEGA - For ESP link

void setup()
{
// Debug console
Serial.begin(115200);  // Optional - BLYNK_PRINT data - For IDE Serial Monitor

Serial1.begin(ESP8266_BAUD);  // Set baud rate - For ESP8266 link
Blynk.begin(auth, wifi, ssid, pass);
}

can i write AT COMMAND using arduino board and IDE

with mega code serial monitor write :esp not responding

Yes, a bit of a catch 22 though… as you have it hooked up correctly and communicating in the first place.

This is the sketch I use for my MEGA and ESP-01 for when I rarely need to do so.

/*
Accessing AT commands on ESP8266-01 with integrated WiFi login.
ESP connected to Serial1 on Mega
AT commands via IDE Serial monitor.
*/

// ===== VOID SETUP LOOP =====
void setup()
{
  Serial.begin(115200);  // Set IDE Monitor baud rate
  Serial1.begin(115200);  // Set ESP8266 baud rate
  delay(10);
  Serial1.println("AT+CIFSR");  // just displays network connection IP and MAC so I know it is online.
}

void loop()
{
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial1.write(inByte);
  }
}