Mega + WiFi R3 ATmega2560 + ESP8266 (8 Mb mémoire)

I have the same problem. I think that my board is defective.

When I set the DIPs for Mega 2560 it's ok fine. But when set to use ESP8266 and using serial monitor alway the board send some dirt. I try changing the serial speed, but occurs the same.

It's can only be defective. I think.

Regarding to code above, the arduino IDE don't have that library. There are some others associated with 8266, except that.

Someone have some idea?


Hi Guys,

I solve the problem. First you need to write the code for each board according your application, but in your code you need to establish a commmincation between serial port of Atmega and ESP in both code, again in according you application. Finally, put the switches which make the intenal interconnection between both.

For example, I made a code for ESP to connect in an Access Point and put on a TCP server. When a wireless client is connected in ESP and consequently in the TCP Server, all data send by client I redirect to the serial port. As serial port of ESP is connected with serial 3 of the Atmega, the code in Atmega pass to theat the data from serial 3.

It's all!



Before you upload the sketch which board did you choose? When I choose the Atmega2560 board error come up.

For upload the sketch to the board:
5, 6, 7 ON

For run the sketch:
5 and 6 ON

It works


here a good manual. it solve any doubtэлектроника-контроллер-arduino-mega-с-esp8266/

isotopa@ thank you very much for your sharing, I also have the exactly the same of your board, and I have try many time with that board. when I try with Mega alone it works fine, and also alone with Esp works fine. But I found that I cannot use the AT Command to the esp even I already updated new firmware... that is the problem of esp? In my case for my project... I just want to send the sensors data such Temperature or Humidity from Mega pins to the Firebase via built-in Esp8266 on board. I want to start esp from mega by the AT Command via the Serial ports, but I found esp seem doesn't works with AT Command. Now my project still stuck at all.

Question 1: Do you think, Is it possible to start ESP from Mega via the Serial ports by AT Commands?
Question 2: Do we have to program to both of that , esp and mega?
Question 3: Which board did you select when upload the sketch? "Generic ESP8266 Modules" or "Mega2560"?

I hope you catch what I mean, and happy to provide more information if needed, Thank you again for sharing.

After I try many week, now it works. Follow this if you have the same to my cases:

  1. programm to the ESP(upload sketch) for wifi connection by configure the DIP to 5:on,6:on,7:on and other off.

  2. program to mega(upload sketch) in case you want to send communication to each other by configure Dip to 3:on,4:on, and other off.

  3. switch two RX0/TX0(in my case I use Serial.print() and Serial.readString() for communicate between Esp and Mega)

  4. after you already upload sketch to both Modules you can test communication between them by configure DIP to: 1:on,2:on,3:on,4:on. and then press Reset Button to restart the boards.

  5. In ESP you can get the string from Mega by if(Serial.available()) Serial.readString(); and In mega you can get data from ESP by : if(Serial.available())Serial.readString().

  6. After you got a string so you can split or do anything whatever you want.

  7. If you want send data to Firebase you must use the Firebase Library at the Esp side, in Mega it not support.

*** This work for me, I hope it can help you. Good luck.

In my case
Send from Mega
Serial.println('some text');
ESP read
if(Serial.available()) Serial.readString();

Send From ESP
Serial.println('some text');
Mega read
if(Serial3.available()) Serial3.readString();


receive on ESP from Mega works only when RXD0 - TXD0, Mega does not receive in this case

receive on Mega from ESP works only when RXD3 - TXD3, ESP does not receive in this case

It is possible at the same time to make connection from mega to esp and from esp to mega?


I know how to connect a readymade esp8266 slave module to a Mega using Serial port and using AT command set.

In this board - "Arduino Mega 2560 R3 with integrated WiFi chip ESP8266", the WiFi module is not accepting AT commands.

What code should I program in it so that it becomes similar to readymade slave module?

Thanks in advance.

Anyone managed to get the esp8266 from that board to work properly?

I’ve uploaded my script successfully to the ESP with pins 5, 6 and 7 ON. (tried with RXD0 and RXD3 without change).

I’m also able to get the serial output from ESP with pins 5 and 6 ON.

The problem I currently have is that the ESP does not seems to see my wifi. I’ve tried the same code to a NodeMCU and another ESP board and they connect almost instantly.

I’ve enabled ESP debug using that config in my platformio.ini (I’m using platformio to upload the firmware to the ESP) :

platform = espressif8266
board = d1_mini
framework = arduino
build_flags =

What I’m seeing from the console, is that the ESP on the “Mega + WiFi R3 ATmega2560 + ESP8266” board see way less wifi than any other ESP board I have… It see between 0 to 3 Wifi when other boards can see up to 20 networks around.
(see log below)

I’ve even tried with an antenna on the board but that changed absolutely nothing…
I’ve also used a 12v power supply thinking the 5v usb power should not be enough…
I’ve 2 of those boards… They both give me the same result : Poor network resolution.

Also, my wifi network is the one with the strongest signal when I check with my computer or my phone from the same location the board is located.

Can’t figure out why it see so less network around… Any idea???

Script :

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

ESP8266WiFiMulti WiFiMulti;

void setup() {

 // We start by connecting to a WiFi network
 WiFiMulti.addAP("412 Precondition Failed", "MY WIFI PASS");

 Serial.print("Wait for WiFi... ");

 while ( != WL_CONNECTED) {

 Serial.println("WiFi connected");
 Serial.println("IP address: ");


void loop() {

Console output (other ESP boards display like 20 networks)

[WIFI][APlistAdd] add SSID: 412 Precondition Failed

Wait for WiFi... [WIFI] delete old wifi config...
[WIFI] start scan
[WIFI] scan done

[WIFI] 1 networks found
       0: [1][3C:90:66:zz:zz:zz] EBOX-4229 (-87) *

[WIFI] no matching wifi found!
.[WIFI] delete old wifi config...
[WIFI] start scan
[WIFI] scan done
[WIFI] 2 networks found
       0: [1][3C:90:66:zz:zz:zz] EBOX-4229 (-87) *
       1: [1][40:65:A3:zz:zz:zz] BELL062 (-82) *

[WIFI] no matching wifi found!
.[WIFI] delete old wifi config...
[WIFI] start scan
[WIFI] scan done
[WIFI] 2 networks found
       0: [1][3C:90:66:zz:zz:zz] EBOX-4229 (-86) *
       1: [1][54:64:D9:zz:zz:zz] BELL387 (-90) *

When turning it in AP mode, I can’t connect to it, it drop immediately as I try to connect to it…

In reply to posters above...

To Awesomo I have the same issue - the ESP creates a WiFi AP when powered up, without the Mega sending any AT commands to it at all. The ESP doesn't respond to any AT commands.

To rcosta I get the same problem - If I try to connect to the serial port on the ESP I get a crash dump at a very strange baud rate.

Kimleng stated that he uploaded a new sketch for AT commands to the ESP chip from the Arduino IDE.

Could you please post the location you downloaded those sketches from?

(Esspressif provide a flashing tool, but it is scary - you have to select lots of different .bin files, and send them to the right address - I'll be much happier using Arduino IDE and a sketch/libraries).

This board is a carrion, pay 10% of a minimum wage in that, only expert to get ... Mine will stay in the bottom of the drawer until I have the courage to throw away ...

Does anyone have any further info on this board?
I'd really like to use it....

The response from RobotDyn isn't very helpful.

The crash dump I get at 74880 baud(!) is:

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

load 0x40100000, len 25700, room 16
tail 4
chksum 0x0b
load 0x3ffe8000, len 848, room 4
tail 12
chksum 0x3f
ho 0 tail 12 room 4
load 0x3ffe8350, len 184, room 12
tail 12
chksum 0xb7
csum 0xb7

i used the @Kimleng instructions to upload this sketch on esp module

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth = “936f6136f9f1454981c46cce3382620”;

// Your WiFi credentials.
// Set password to “” for open networks.
const char ssid = “arduino”;
const char pass = “”;

// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin V1
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable

// process received value

void setup()
// Debug console

Blynk.begin(auth, ssid, pass);

// You can also specify server:
//Blynk.begin(auth, ssid, pass, “”, 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

void loop()

and i haven’t problem with the upload but when i go to search the wifi network on the phone i don’t find it, where i wrong?

Hello everyone esp8266 on board can't connect to WiFi. I follow DIP switch table but it's still not connect.
2.what is "MODE" button on the board and how to use
Could you help me please?

thank you

Take a look at the link as posted by isotopa

You can use Google Translate as the blog is in Russian.

The author describes the load of the library and the board settings to program both processors.

Where he refers to "WeMos D1 R2 & mini" to program the esp8266, I used "LOLIN(WEMOS) D1 R2 & mini"
He used Flash Size:4M(3m SPIFFS) as one of the boars settings

You have to press the "MODE" button before you upload the sketch
to the esp8266

I was able to load the sample as described and switch LED13 on and off through the web sample.электроника-контроллер-arduino-mega-с-esp8266/

If you have difficulty connecting the ESP8266 on your (WeMos) Mega wifi to your router (etc), check the age/security of your router:

This line of code that allowed connecting with my old router:


which also highlights that I should upgrade it...

If you’re reading this thread because you can’t get your MEGA or UNO with on-board ESP8266 WiFi (robotdyn, wemos, unbranded) to send data to the web (ie Thingspeak) using a WiFi connection, consider sending AT commands to the OEM ESP8266 firmware from an Arduino sketch, which avoids figuring out how to transfer bytes between an Arduino sketch on the MEGA / UNO and an ESP8266 sketch on the ESP8266.

Perhaps the pros consider AT commands to be a complicated / inefficient / knuckle-dragging approach, but if, like me, you just want your data to flow with minimal effort learning to code, you might benefit from the many hours I spent figuring out what might seem obvious to the pros…though simple successful example code for the MEGA/UNO w/ESP8266 boards is noticeably absent from all the web posts I looked at… Based on the many postings I reviewed, people (like me) asking how to get these MEGA/UNO w/ESP8266 boards working didn’t seem to know enough about this subject to interpret informed responses, while the informed respondents don’t realize their responses assume a certain level of understanding that someone like me doesn’t have.

Anyway, here’s the basic concept / process I eventually used for the MEGA w/ESP8266:

  1. Flash ESP8266 chip with appropriate Espressif firmware (or don’t erase the firmware in the first place…I spent several hours with the esp flash tool figuring out correct reflash settings)
  2. Using key elements (commented in attached MEGA sketch) upload an Arduino sketch to the Mega with DIP positions: ON:3,4; OFF:1,2,5,6,7,8; RX/TX switch: any position
  3. Use the ‘special solution’ switch configuration: DIPs: ON:1,2,3,4; OFF:5,6,7,8; RX/TX switch set to RX3/TX3
  4. The ‘special solution’ connects the MEGA’s serial3 port to the ESP8266 at the same time the serial port connects to the serial monitor
  5. Open serial monitor and your Thingspeak channel to see what’s happening. You should see AT commands and values in the serial monitor, and about every 30 seconds a new value should appear on Thingspeak.

After figuring this out with the MEGA w/ESP8266, here’s the basic concept / process I used for the UNO:

  1. Flash ESP8266 chip with appropriate Espressif firmware (or don’t erase the firmware in the first place…I spent several hours with esp tool figuring out correct reflash settings)
  2. Using key elements (commented in attached UNO sketch) upload an Arduino sketch to the UNO with DIP positions: ON:3,4; OFF:1,2,5,6,7,8
  3. To connect the UNO serial output directly to the ESP8266, use the switch configuration: DIPs: ON:1,2; OFF:3,4,5,6,7,8.
  4. Serial monitor will not work (since serial is being used for data transfer between UNO MCU and ESP8266), but you can open your Thingspeak channel to see if anything is showing up.

If nothing shows up on Thingspeak, use serial monitor to connect directly to the ESP8266 (DIP: ON:5,6; OFF:1,2,3,4,7,8) and send AT commands directly to the ESP8266; copy AT command strings by using serial monitor while running the MEGA sketch, copying the AT command strings to MS Word or notepad.

Hope it works for you!

MEGAwWiFi_logger_webpost_example.ino (8.78 KB)

UNOwWiFi_logger_webpost_example.ino.ino (7.66 KB)

It worked.

I use WemosMEGA + blynk + example code Push button and LED (13)

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "vXJswotHJM26Un0jS43Du_-Iw82OG1C9";
char ssid[] = "*********";
char pass[] = "********";
#define EspSerial Serial3
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

void setup()
  Blynk.begin(auth, wifi, ssid, pass);

void loop()
    if ( Serial3.available() )   {  Serial.write( );  }
    if ( Serial.available() )       {  Serial3.write( );  }