Go Down

Topic: Wemos Mega +WiFi R3 Module ATmega2560+ESP8266 (Read 3390 times) previous topic - next topic



Really struggling to get this board working. I have read so many different posts and tutorials and none of them work and some are also conflicting with others. It's been about 10 hours of frustration and I would really like to ask for help.

I have brought 2 Wemos® Mega +WiFi R3 Module ATmega2560+ESP8266 from Banggood

I do not seem to understand this board and how to make it work as some posts say you have to upload some firmware (somehow) but don't tell you where to get this firmware. Some posts say just set the dip switches and upload a script (which I have tried but does not work)

So, if someone who has one of this boards could take a few mins to explain I would be truly greatful.

So, with the board out of the static bag, what should be my first job at getting this board to work. Say let's get the WiFi working first.

I have in the IDE already done the Additional Boards (http://arduino.esp8266.com/stable/package_esp8266com_index.json) bit and set the board to be Generic ESP8266 Module.

1) what position does the dip switches need to be in plus the RX/TX switch position
2) Do I need to upload some firmware, if so where from an how on a win10 PC
3) Do I need to add an ESP8266 Library (I have tried run a test script but it can not find esp8266.h, so presume a library is needed. I download the https://github.com/Hieromon/ESP8266 library but then it complaind "WIFI was not declared in this scope)

The script was
Code: [Select]
#include "Arduino.h"
#include "ESP8266.h"

#include "SoftwareSerial.h"
SoftwareSerial  ConsoleOut(8, 9);

#define SSID  "CZGB"
#define PWD   "whdhdudt"

void setup() {
  char  *ipAddress, ap[31];

  if (WiFi.join(SSID, PWD) == WIFI_ERR_OK) {
    ipAddress = WiFi.ip(WIFI_MODE_STA);
    ConsoleOut.print(F("\n\rIP address:"));
    if (WiFi.isConnect(ap))
      ConsoleOut.println(F("not found"));
  } else
    while (1);

void loop() {
  if (WiFi.connect((char *)"www.google.co.jp", 80) == WIFI_ERR_CONNECT) {

    if (WiFi.send((const uint8_t *)"GET / HTTP/1.1\r\n\r\n") == WIFI_ERR_OK) {
      int16_t c;
      uint16_t len = WiFi.listen(10000UL);
      while (len)
        if ((c = WiFi.read()) > 0) {
    } else
      ConsoleOut.println(F("Send fail"));


  } else
    ConsoleOut.println(F("TCP connect fail"));


  while (1);

If I can get this part completed then I can try and get the connection to the Mega side.



On this board you have an USB to TTL Serial adapter, an Atmega 2560 MCU and an esp8266 WiFi MCU.
If this would be solo modules, you would connect them with wires RX to TX. Here you have DIP switches in pairs. One for RX, and one for TX.

Only 2 device can connect their RX and TX pins together. (2560 has more RX, TX pins)

You can connect
- USB to 2560 for upload and Serial Monitor to 2560. - esp8266 is out
- USB to esp8266 for upload and Serial Monitor to esp8266 - 2560 is out
- 2560 to esp 8266 to communicate between MCU. here are too option
-- connect on Serial of 2560 - USB is out
-- connect on Serial3 of 2560 - in this case you can use USB to 2560 too so this is the best option

The Internet is full of tutorials about Arduino and esp8266 module. Use them. Only instead of rewiring, switch the DIP switches.
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.


Thanks for the reply.

I have had some success

I have now been able to upload a script to the Mega, and also separate sketch to the esp8266.

It was not all clear cut as I said previously there are many conflict posts on using this type of board and about upload firmware etc.

So, currently I can setup the esp8266 as an access point and connect to it from my iphone.

Here is what I did to help other get a basic setup working on this Wemos Mega +WiFi R3 Module ATmega2560+ESP8266 board

Arduino Mega First Time

Some Info
Table DIP switch:

1=ON  2=ON  3=OFF 4=OFF 5=OFF 6=OFF 7=OFF 8=OFF (ATmega2560<->ESP8266)
1=OFF 2=OFF 3=ON  4=ON  5=OFF 6=OFF 7=OFF 8=OFF (USB <->ATmega2560)
1=OFF 2=OFF 3=OFF 4=OFF 5=ON  6=ON  7=ON  8=OFF (USB<->ESP8266 (Update firmware or sketch))
1=OFF 2=OFF 3=OFF 4=OFF 5=ON  6=ON  7=OFF 8=OFF (USB<->ESP8266 (communication))
1=OFF 2=OFF 3=OFF 4=OFF 5=OFF 6=OFF 7=OFF 8=OFF (All independent)

Table DIP switch Special Solution:
1=ON 2=ON 3=ON 4=ON 5=OFF 6=OFF 7=OFF 8=OFF (USB <-> ATmega2560<-> ESP8266)
USB converter CH340G connect to RX0/TX0 of ATmega2560
ESP8266 connect to RX3/TX3 of ATmega25

https://arduino-esp8266.readthedocs.io/en/latest/index.html for ESP8266 documentation

Set the Additional Boards URL to http://arduino.esp8266.com/stable/package_esp8266com_index.json in preferences

Under Tools select Board then Board Manager, then install the esp8266 by ESP8266 Community

Under Tools select Board then select the "Arduino/Genuino Mega or Mega 2560"

Set the DIP switches on the actual board to 1=OFF 2=OFF 3=ON 4=ON 5=OFF 6=OFF 7=OFF 8=OFF (USB <->ATmega2560)

Paste the following sketch into the IDE, save and upload and if check the LED flashes
  Turns on an LED on for 3 seconds, then off for one second, repeatedly.
int ledpin = 13;
void setup() {               
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(ledpin, OUTPUT);     

void loop() {
  digitalWrite(ledpin, HIGH);   // set the LED on
  delay(3000);              // wait for a second
  digitalWrite(ledpin, LOW);    // set the LED off
  delay(1000);              // wait for a second

The LED should come on for 3 seconds, then off for a second and repeat.

Set the DIP switches on the actual board to 1=OFF 2=OFF 3=OFF 4=OFF 5=ON  6=ON  7=ON  8=OFF (USB<->ESP8266 (Update firmware or sketch))

Under Tools select Board then select the Generic esp8266 Module

Paste the following sketch into the IDE, save and upload

/* Create a WiFi access point and provide a web server on it. */

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

/* Set these to your desired credentials. */
const char *ssid = "Mega";
const char *password = "12345678";

ESP8266WebServer server(80);

/* Just a little test message.  Go to the IP address you setup below in a web browser
   connected to this access point to see it.
void handleRoot() {
  server.send(200, "text/html", "<h1>You are connected</h1>");

void setup() {
  Serial.print("Configuring access point...");

IPAddress local_IP(192,168,0,20);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
Serial.print("Setting soft-AP configuration ... ");
  Serial.println(WiFi.softAPConfig(local_IP, gateway, subnet) ? "Ready" : "Failed!");

  Serial.print("Setting soft-AP ... ");
  Serial.println(WiFi.softAP("ESPsoftAP_01") ? "Ready" : "Failed!");

  Serial.print("Soft-AP IP address = ");

  /* You can remove the password parameter if you want the AP to be open. */
  WiFi.softAP(ssid, password);
 // IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  server.on("/", handleRoot);
  Serial.println("HTTP server started");

void loop() {

Set the DIP switches on the actual board to 1=OFF 2=OFF 3=OFF 4=OFF 5=ON  6=ON  7=OFF 8=OFF (USB<->ESP8266 (communication))

Then open the Serial Monitor or press the reset button

Then with a wifi enabled device (eg iPhone or Android), goto the wifi section and connect to the Access Point using your details above.
Once connected open a browser and put the IP address in and you should see the "You are connected"


Hello mister,   do we have BUILT_IN LED on the ESP8266 unit in this WEMOS MEGA WIFI board?
On node MCU V3 board we have built in led on GPIO2.

Best regards.

Go Up