WeMos Mega 2560 + ESP8266

Hi there! First of all: I tried 4 hours of searching the internet but still can’t solve my problem, maybe your knowlegde will help me, so here it is:

I bought an WeMos ATmega2560+ESP8266 Board, it has an integrated ESP8266 and the connection is controlled via DIP-switches. I want to do a simple Blynk project, where I can controle an LED via the APP. For the most part I’ve followed the instructions in this YouTube Video, where a stand alone ESP is used (https://www.youtube.com/watch?v=YLKEZtLhfZo&t=2137s). However working with the WeMos was fine, I did the following steps:

  • Flash a new AT command firmware version 1.5.4 (AiThinker_ESP8266_DIO_8M_8M_20160615_V1.5.4) onto the ESP8266
  • Set up the Blynk sketch from the Website with the following settings: Board - Arduino Mega 2560, Connection - ESP8266 WiFi Shield, the Auth Token, Example - Push Data (all I changed in the C code is the SSID and Password of the network)
  • Uploaded the sketch to the Arduino and opended the serial monitor to see if things are working well

The Problem is, that the connection to the ESP isn’t correctly established. All I’m getting is:

[9] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Mega

[599] Connecting to (>OoO)> -----==O)) ^(X.X^)
[1609] ESP is not responding

I set the DIP-switches (1…8) to 11110000 and the additional switch to RXD/TXD3. An overview of the DIP modes is given here: https://forum.arduino.cc/index.php?topic=495840.0

Maybe someone know what I’m doing wrong here, please help me! :’(

Are your wifi credentials correct? And also I assume you have changed the auth token too?

Thanks for your fast reply, I indeed changed the Auth Token, yes and I checked the credential multiple times to the should be correct too

I do wonder if it to do with the firmware that you’re flashing to the esp8266.

Everything else seems like it should work? But saying that I’ve never seen that board before so I know less than you do, sorry :frowning:

Thanks for your help anyway, because I’ve never seen any other board than this one :'D But yeah I do think so, I’ve set the DIP switches so that I can access the ESP directly and typed AT to see if everything is working, it returned OK, and AT+GMR returns the current infos about the device, so this should be alright :woman_shrugging:

I have no idea what I’m doing wrong here

Without knowing how you’ve configured your code it’s difficult to comment.

I’d start by trying some simple AT commands to ensure that your Mega and ESP are actually talking to each other at the same baud rate.

Pete.

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "my Token";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "my SSID";
char pass[] = "my PWD";

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1

// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, millis() / 1000);
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

Valid argument, here is the code I use. :slight_smile: The Baudrate is set to 115200 where most AT drivers communicate as far as I know and when I connect to the ESP via DIP-switches, 115200 is the correct Baudrate for the Serial Monitor, which is also set in the sketch. Sending commands directly to the ESP works fine. But the communcation between the Mega and the ESP doesn’t :frowning:

I would have expected Serial3 to be used instead of Serial1.

Pete.

2 Likes

Good catch @PeteKnight

2 Likes

Thanks Pete! I was overlooking that line of code :roll_eyes:
Now it successfully connects to the WiFi :partying_face:

But one more thing to go: there is no ping reaction from the Blynk Cloud, so the APP is still saying the project wasn’t online yet. May this has to do with my Firewall settings or something like that? Cause my Auth Token is the one I got per E-Mail, checked it twice. And btw I tried pinging the www.blynk-cloud.com and that works fine, but here it stucks:

[9] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Mega

[599] Connecting to (>OoO)> -----==O)) ^(x.x^)
[3650] WIFI DISCONNECT
AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Jun 13 2016 11:29:20
OK
[11185] +CIFSR:STAIP,"197.7.1.150"
+CIFSR:STAMAC,"0c:13:00:03:93:02"
[11192] Connected to WiFi

How are you connecting to the internet? Via router or mobile hotspot etc and which provider do you use?

I’m connecting via a router, it’s the EasyBox 804 and the provider is Vodafone. It’s my home WiFi

Is there a chance it could be related to this?

I don’t think so. I also tried multiple way for connecting, directly via the vodafone router, via my Laptop hotspot and via a mobile hotspot from my phone which has E-Plus as provider. It always stucks after connecting. No timeout or something, just stuck. I’m wondering if it has anything to do with that Connect Wifi message at the beginning

[599] Connecting to HTC
[3650] WIFI DISCONNECTED
...
[11192] Connected to WiFi

It shows CONNECTED when using the mobile hotspot, DISCONNECTED when using the router

197.7.1.150 is a strange local IP address range to be using.

Pete.

It’s managed via the DHCP I think, didn’t put that in static, should I give it a static adress?

So the rest of the devices on your network are in the 197.7.1.xxx range?

Pete.

1 Like

Oh wow, your right my other devices have a whole different IP range, they’re all in 192.168.2.xxx, looked it up in my router

2 Likes

I.e. the 197.7.1.150 has most likely not be assigned via DHCP … :wink:

I.e. the 197.7.1.150 has most likely not be assigned via DHCP … :wink:

Okay, than please tell me how I could solve this issue :confused: My knowledge about the whole IP thing isn’t top notch :sweat_smile: