I've got 2 "Mega + WiFi R3 ATmega2560 + ESP8266" (link) and both have same issue when trying to use the ESP chip.

Hope someone can point me toward something else to try in order to get them working properly.


I'm able to flash the ESP chip using Arduino IDE or PlatformIO. Dip switch need to be : 5, 6 and 7 ON to flash, and only 5 and 6 to debug through serial.

I've tried using different boards (Generic ESP8266 module, Wemos D1 R2 & mini, Node MCU) as well as different flash mode (DIO, QIO), crystal frequency (26 Mhz, 40 Mhz), CPU frequency (80 Mhz, 160 Mhz)

They all flash correctly without any error and I can get my serial output.

It's written ESP8266EX on the ESP chip. And I've tried with or without an antenna plugged on the board.


The problem I got on both of them is huge instability when using wifi. I cannot connect to them when they are in AP mode, they drop immediately.. And I cannot connect to or see my own wifi network from the Mega's ESP.

The same script and flashing config used on other ESPs devices work as expected (see [output other ESP board] below). I've tried on WeMos and NodeMCU devices.

But with the mega+wifi, it only see between 0 and 2 access point that are at a greater distance and weaker signal than my own wifi ([output mega+wifi] below).


I don't have any clue on what can cause such a different result on device from same family (ESP/espressif). As if there was some sort of setting that need to be changed on those ESPs.

Any help or insight would be truly appreciated.


#include "ESP8266WiFi.h"

void setup() {

  // Set WiFi to station mode and disconnect from an AP if it was previously connected

  Serial.println("Setup done");

void loop() {
  Serial.println("scan start");

  // WiFi.scanNetworks will return the number of networks found
  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0)
    Serial.println("no networks found");
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i)
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(" (");
      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");

  // Wait a bit before scanning again

[output other ESP board]

scan done
8 networks found
1: 412 Precondition Failed (-67)*
2: VIDEOTRON1547 (-90)*
3: BELL275 (-94)*
4: BELL558 (-72)*
5: C-PC_Network (-88)*
6: BELL387 (-90)*
7: EBOX-4229 (-94)*
8: VIDEOTRON6825 (-80)*

scan start
scan done
11 networks found
1: 412 Precondition Failed (-63)*
2: VIDEOTRON1547 (-88)*
3: BELL681 (-90)*
4: BELL275 (-90)*
5: VIDEOTRON0442 (-90)*
6: BELL558 (-71)*
7: BELL602 (-90)*
8: IKA COIFFURE (-90)*
9: C-PC_Network (-87)*
10: EBOX-4229 (-87)*
11: BELL387 (-90)*

scan start
scan done
7 networks found
1: 412 Precondition Failed (-65)*
2: BELL681 (-88)*
3: VIDEOTRON1547 (-88)*
4: EBOX-4229 (-88)*
5: BELL387 (-87)*
6: BELL558 (-71)*
7: dlink-Ares (-75)*

[output mega+wifi]

bcn 0
del if1
mode : sta(2c:3a:e8:26:36:13)
add if0
wifi evt: 8
Setup done
scan start
scan done
1 networks found
1: BELL558 (-69)*

scan start
scan done
1 networks found
1: BELL387 (-88)*

scan start
scan done
no networks found

scan start
scan done
1 networks found
1: BELL387 (-87)*

[erasing flash]

PS \tool-esptoolpy> python .\esptool.py -p COM10 erase_flash
esptool.py v2.3.1
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 14.2s
Hard resetting via RTS pin...
  • try to erase the flash of the esp8266 with esptool and then upload a sketch from IDE. choose Generic esp8266 as a board
    – Juraj
    Commented Jun 13, 2018 at 6:57
  • I did it using python .\esptool.py -p COM10 erase_flash and that didn't changed anything. Output added to the question.
    – Remi
    Commented Jun 13, 2018 at 10:47

3 Answers 3


I had this problem. On Robotdyn D1 mini the esp8266 flash erase did help. On Robotdyn D1 R2 only the flashing of the AT firmware with Espressif Flash Download Tool restored the esp8266. After then the sketches from IDE had working WiFi.

There are some settings of the Espressif basic esp8266 libraries (SDK) saved on flash and there is some incompatibility between SDK versions. The Flash Download Tool creates right esp settings binary and flashes it to right address on flash.

  • ESP8266_AT_Bin_V1.6.2 ? and then at or at_sdio ? and how do I know the right addresses to use?
    – Remi
    Commented Jun 13, 2018 at 11:55
  • "at". addresses depend on the size of the flash and are listed in the readme file
    – Juraj
    Commented Jun 13, 2018 at 12:16
  • Thanks. Just flashed it and even with direct AT command, on only sees very few wifi network AT+CWMODE? +CWMODE:2 OK AT+CWMODE=3 OK AT+CWMODE? +CWMODE:3 OK AT+CWLAP +CWLAP:(2,"CHANTAL-PC-Network",-77,"00:26:5a:d1:c9:96",11,162,0,5,3,7,1)
    – Remi
    Commented Jun 13, 2018 at 12:36
  • AT+GMR AT version: 13 2018 11:10:59) SDK version:2.2.1(6ab97e9) compile time:Jun 7 2018 19:34:26 Bin version(Wroom 02):1.6.2
    – Remi
    Commented Jun 13, 2018 at 12:38
  • and can you connect to your network (CWJAP) ?
    – Juraj
    Commented Jun 13, 2018 at 13:55

You state you "cannot connect to them when they are in AP mode" but I do not see AP configured in your code.

// ESP AP Server
// password can be blank 
// must be min 8 chars or will not work
const char *APName = "MYESP8266";
const char *APPass = "MYPASS123"; 
// start the access point server
WiFi.softAP(APName, APPass);
// define web link functions
webServer.on("/", doRoot);
// start server

// In LOOP
// keep checking to see if someone connects to device

Regarding the mega-wifi-r3-atmega2560-esp8266 I am unsure how these work, is the code being flashed to the ESP chip or to the Arduino chip and ESP is in AT mode?

  • For the AP mode, I tried with the example provided here : arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/… I simply cannot connect to the AP (when I'm able to see it) even if I'm only 1 foot away from the board.
    – Remi
    Commented Jun 13, 2018 at 11:38
  • Do you get an error after typing in the password? Commented Jun 13, 2018 at 12:43
  • Try making the password all caps Commented Jun 13, 2018 at 12:43
  • No, from computer is says "can't connect to network" and from my phone the AP simply disappear. The same code work perfectly on other boards. Seems more like core firmware issue.
    – Remi
    Commented Jun 13, 2018 at 13:02
  • If it goes off then most likely the code is crashing and ESP rebooting Commented Jun 13, 2018 at 13:25

If you've come upon this page because the ESP8266 on your (WeMos) Mega wifi won't connect to your router (etc), check the age/security of your router: Wifi stopped connecting (Wemos D1 Mini)

This line of code that allowed connecting with my old router: WiFi.enableInsecureWEP();

which also highlights that I should upgrade it...

Not the answer you're looking for? Browse other questions tagged or ask your own question.