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

Switching Internet Access Methods like a Phone

Hello Community,

I would like to ask about any possible solution on “Switching Internet Access Method” between WiFi, Ethernet and GSM.

• Hardware model + communication type: Arduino MEGA2560; with Arduino Ethernet Shield 2 + Sim900 GSM Module + ESP8266 Module.

Problem: I try to design a IoT gateway with 3 different internet access, i.e., Ethernet, WiFi and GSM, wish to program it to behave like a mobile phone, for example, auto detect ethernet then use ethernet, if ethernet is not available, then use wifi, if wifi is not available then use GSM.

The issue comes to the blynk library, if all library included at the same time, then using blynk.begin will cause errors.


#define BLYNK_PRINT Serial

//WiFi Library
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxx";
char pass[] = "xxx";


//Ethernet Library
#include <SPI.h>
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>

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

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(50,51); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);


void setup()
{
  // Debug console
  Serial.begin(9600);
 
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth);
  if(blynk.connected()==1){
  serial.println("Ethernet Connected to Blynk");}
  else {Blynk.begin(auth, wifi, ssid, pass);
      if (blynk.connected()==1){serial.println("WiFi Connected to Blynk");}
  }
  
}

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!
}

The error showing : “no matching function for call to ‘BlynkWifi::begin(char [33])’”

The code is just an example for what I tried, I also tried serval other ways but found out the library would conflict.

So I would like to ask community if anyone did similar project, could you please offer me an idea for what direction I should look at.

Many thanks in advance.

You might want to take a look at this…

Pete.