Code for integrating Blynk with Board : Mega +WiFi R3 Atmega2560+NodeMCU ESP8266 32Mb Memory USB-TTL CH340G Compatible For Arduino Mega

Hi, there

I have bought this board.
I have success with understanding of DIP switches. But, I am failing to integrate Blynk with this board:

I am not able to understand at all which code I have to upload to Mega, or the ESP8266, what example to choose for which Module, and which Board to choose - the WeMos Pro R1 or the Arduino Mega 2560.

Its been like this for the past 24 hours :cold_sweat: and seriously, I am not able to understand what I shall do.

Please help me out with this one. I know I am asking for a lot but your help is sincerely appreciated.

UPDATE; I have some success
I got the ESP connected to Blynk, an extra DIP was turned on.
The code was

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  This example runs directly on ESP8266 chip.

  Note: This requires ESP8266 support package:
    https://github.com/esp8266/Arduino

  Please be sure to select the right ESP8266 module
  in the Tools -> Board menu!

  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!
 *************************************************************/

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


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "NetworkSSID";
char pass[] = "Password";

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

  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
 
}

Now, I want to ask how do I connect the ESP8266 to the onboard Atmega2650. I want to take data from soil sensors from Atmega2650 and use the data to make a few conditions that I have figured out.,
I just want to know what do I write on code so that mega connects with ESP and I am able to send notifications on mobile phone.

FINAL UPDATE: I have figured out the DIP Switches and the Code.
See in the Thread to see the Code.
This is the configuration for DIP Switches

I think you’ll find that you’re supposed to be running the default factory “AT” firmware on the ESP and a regular Arduino + ESP simple shield sketch on the Arduino.

If you search the forum you’ll find some info on similar boards, and how to re-flash the ESP with AT firmware.

Pete.

Hi Pete,
Thanks for your sincere help. I highly appreciate it.

Yes, you are completely true, Pete. The problem was with DIP Switches. The DIP Switches are complex but one figured out, it is the best board.

I am uploading my code which works for integration with DIP Board Connection.

After that, you can close it!

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  WARNING!
    It's very tricky to get it working. Please read this article:
    http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware

  You’ll need:
   - Blynk App (download from AppStore or Google Play)
   - Arduino Mega 2560 board
   - Decide how to connect to Blynk
     (USB, Ethernet, Wi-Fi, Bluetooth, ...)

  There is a bunch of great example sketches included to show you how to get
  started. Think of them as LEGO bricks  and combine them as you wish.
  For example, take the Ethernet Shield sketch and combine it with the
  Servo example, or choose a USB sketch and add a code from SendData
  example.
 *************************************************************/

/* Uploads on SWITCHES ON - 3,4 
WORKS ON SWITCHES ON : 1, 2*/
//it works

#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[] = "AuthToken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "NetworkName";
char pass[] = "Password";

// 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);

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);
}

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

This code is for communicating between ESP8266 (ESP-01) and Atmega2650

Hmmm, it’s certainly not on my Christmas wish list and if Santa delivered one I wouldn’t be happy!

Pete.

1 Like

Well, each child has wishes different from each other and I have got mine! What do you want? :wink::wink: anyways, Happy Christmas to each of my friend on Blynk Community and you PETE!!!:tada::confetti_ball:

Here are my thoughts on which type of board I’d like Santa to bring…

For me, the main issues with the board you are using are:

  • Lack of OTA support
  • Physical size
  • Lack of memory (although not as much of an issue when OTA isn’t an option)
  • Lack of processing power
  • High cost

Merry Christmas!

Pete.

Hi, You mentioned that you finally figured out the dip switches. Can you tell me how were they set? I see options, but not the one that worked. Thanks :slight_smile:

Hi @cmilian it really depends what you’re wanting to achieve, and to a degree what you’ve done so far.

If you want the onboard ESP8266 to act as a WiFi modem for the Arduino Mega part of the board then this is done as shown in the table, and documented in the code…

Upload code to Arduino : SWITCHES ON - 3, 4
Operation mode : SWITCHES ON : 1, 2

However, if you have previously set switches 5, 6 & 7 to the ON position and uploaded a sketch to the onboard ESP8266 then this won’t work, a you will have overwritten the factory ‘AT’ firmware. To resolve that you’ll need to get hold of a copy of the factors firmware for the ESP8266 and upload it.

When you have switches 1 & 2 in the ON position and the other switches set to OFF then the ESP8266 is connected to hardware COM port 3 on the Arduino and your Arduino sketch needs to reflect this.

Pete.

2 Likes

I think I was able to get it done, I am stuck now on the [1609] ESP is not responding.= error.

Here is my code:


/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  WARNING!
    It's very tricky to get it working. Please read this article:
    http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware

  You’ll need:
   - Blynk App (download from AppStore or Google Play)
   - Arduino Mega 2560 board
   - Decide how to connect to Blynk
     (USB, Ethernet, Wi-Fi, Bluetooth, ...)

  There is a bunch of great example sketches included to show you how to get
  started. Think of them as LEGO bricks  and combine them as you wish.
  For example, take the Ethernet Shield sketch and combine it with the
  Servo example, or choose a USB sketch and add a code from SendData
  example.
 *************************************************************/

/* 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[] = "removed on pourpose";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Sebi";
char pass[] = "Crifdgfdg";

// 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 9600

ESP8266 wifi(&EspSerial);

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);
}

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

Pete.

Sorry for the newbie question…how?

I don’t have (and certainly don’t want) one of these boards, and my comments are based purely on the data posted above.

If the ESP8266 is connected to COM3, as it says in the table above, then:
#define EspSerial Serial3
would be the way to do it.

Also, this line:

will need to be set to the correct baud rate to match the onboard ESP8266’s baud rate. I have no idea what that is for this device.

Pete.

That is not correct.
I use 1,2,3,4 on rest off to program the 2560.
If you want to program the esp then 5,6,7 on and all others off.

You can leave 1,2,3,4 on and rest off to run and program. no need to change them to run or program the mega 2560 section.

What I do is leave 1,2,3,4 on and rest off to run and program mega. To program the esp part after the initial esp is initially programmed I set up the esp accept OTA so no need to ever change the dip switched again…

Hope this helps.
Denny

1 Like

does this board come with fpr-eflashed firmware can i use it out of the box?

have you figured it out? i have the same problem

I am facing a similar issue. Can you explain the solution that you found?
I cannot decide which board to choose in the Blynk application. I am also unable to integrate ESP module with the AtMega 2560. I want to use the analog pins of Mega to read sensor data over WiFi.

Please help me with the same.
I have the same board.

@PeteKnight
How does it reflect on the Arduino sketch?
newbie question, please help.

As I said earlier in this topic, I’ve never used one of these boards and never will, so don’t have any first hand experience.
The key issue as far as the sketch is concerned is selecting the correct serial port, but that’s discussed above.
As far as the board is concerned, you need to get the switch settings correct, and NEVER upload a sketch to the ESP8266 part of the board if you want to use the BlynkSimpleShieldEsp8266.h library, where the code runs on the Mega and the ESP acts as a WiFi modem.

Pete.

1 Like