BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

WeMos Mega 2560 + ESP8266

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:

The biggest problem we have is that we don’t know what code has been used in the ESP8266 as it is just a bin file.

You could try to set a static IP, search on here for static IP, it should be fairly easy. Never needed to use it myself though.