0

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.

Context

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.

Problem

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).

Question

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.

[code]

#include "ESP8266WiFi.h"

void setup() {
  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was previously connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  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");
  else
  {
    Serial.print(n);
    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(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
      delay(10);
    }
  }
  Serial.println("");

  // Wait a bit before scanning again
  delay(5000);
}

[output other ESP board]

scandone
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
scandone
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
scandone
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]

SDK:2.2.1(cfd48f3)/Core:2.4.1/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1)
bcn 0
del if1
usl
mode : sta(2c:3a:e8:26:36:13)
add if0
wifi evt: 8
Setup done
scan start
scandone
scan done
1 networks found
1: BELL558 (-69)*

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

scan start
scandone
scan done
no networks found

scan start
scandone
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
Connecting....
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...
Remi
  • 159
  • 1
  • 10

3 Answers3

1

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.

Juraj
  • 18,264
  • 4
  • 31
  • 49
0

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
webServer.begin();

// In LOOP
// keep checking to see if someone connects to device
webServer.handleClient();

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?

Brian Moreau
  • 112
  • 3
0

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