GSM.h and WiFi.h conflict

Hello everyone,

I was using an arduino Mega, cellular shield and Wifi shield. My purpose is a switch between cellular connection and wifi connection on one Mega board. so I have to make wifi code and cellular code in the same sketch.

However, when I include <GSM.h> and <Wifi.h> at the same time, when I use WiFi.status() to debug, it returns 255(which means no wifi shield) even if there is a wifi shield on the board.

That confused me a lot. I am sure the problem is due to the <GSM.h>, but I have no idea of the detailed problem, and I do not know how to fix it. Is there anyone who can help me with this? I really appreciated your help!

Thank you so much!

I think I have figured out the problems, but I do not know how to fix this.

if I do
#include <GSM.h>
#include<WiFi.h>
then the WiFi.status() is not reporting correctly;

if I do
#include<WiFi.h>
#include <GSM.h>
then the Wifi.status() is reporting correctly however m_gsmAccess.getStatus() is always not GSM_READY.

Anyone can help any?

I really appreciated that!

I don't use those together, but it seems they both use pin D7. The GSM uses D7 for its reset, and the WiFi uses D7 for its handshake pin. I don't know how you are going to fix that.