Go Down

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

SniffTheGlove

Hi,

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
https://www.banggood.com/Wemos-Mega-WiFi-R3-ATmega2560ESP8266-32Mb-Memory-USB-TTL-CH340G-Compatible-For-Arduino-Mega-p-1205437.html?cur_warehouse=CN

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

  WiFi.reset(WIFI_RESET_HARD);
  WiFi.begin(9600);
  if (WiFi.join(SSID, PWD) == WIFI_ERR_OK) {
    ipAddress = WiFi.ip(WIFI_MODE_STA);
    ConsoleOut.print(F("\n\rIP address:"));
    ConsoleOut.print(ipAddress);
    ConsoleOut.print(':');
    if (WiFi.isConnect(ap))
      ConsoleOut.println(ap);
    else
      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) {
          ConsoleOut.write((char)c);
          len--;
        }
    } else
      ConsoleOut.println(F("Send fail"));

    WiFi.close();

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

  WiFi.disconnect();

  while (1);
}


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

Thanks

Juraj

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.

SniffTheGlove

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

Quote
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

Start
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
--------------------------------------------------------------
/*
  Blink
  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() {
  delay(1000);
  Serial.begin(57600);
  Serial.println();
  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 = ");
  Serial.println(WiFi.softAPIP());

  //--------------------------------------------
  /* 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: ");
  //Serial.println(myIP);
  server.on("/", handleRoot);
  server.begin();
  Serial.println("HTTP server started");
}

void loop() {
  server.handleClient();
}
--------------------------------------------------------------

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"


Go Up