Hello,
I am facing error whenever I am trying to compile the sketch at ardunio.
Please find the below sketch
#include <SoftwareSerial.h>
#include <GSM.h>
#define RXPIN 8
#define TXPIN 9
SoftwareSerial myserial(9,8);
//Define the PIN NUMBER of SIM
#define PINNUMBER ""
//APN Data
#define GPRS_APN "XXX.com"
#define GPRS_LOGIN ""
#define GPRS_PASSWORD ""
//create GSM object liabrary
GSMClient client;
GSM gsmaccess;
GPRS mygprs;
void setup()
{
// initialize serial communications
Serial.begin(9600);
gsmaccess.begin(PINNUMBER);
mygrps.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if((gsmaccess.begin(PINNUMBER)==GSM_READY)) &
(mygprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY))
{
notConnected = false;
}
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("Connected to GPRS network");
}
void loop(){
}
Error details as below :
In file included from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM.h:46:0,
from C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:3:
C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3ShieldV1BandManagement.h:49:125: warning: 'typedef' was ignored in this declaration
typedef enum GSM3GSMBand {UNDEFINED, EGSM_MODE, DCS_MODE, PCS_MODE, EGSM_DCS_MODE, GSM850_PCS_MODE, GSM850_EGSM_DCS_PCS_MODE};
^
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino: In function 'void setup()':
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:30:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
gsmaccess.begin(PINNUMBER);
^
sketch_oct24a:31: error: 'mygrps' was not declared in this scope
mygrps.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);
^
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:39:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
if((gsmaccess.begin(PINNUMBER)==GSM_READY)) &
^
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:40:59: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
(mygprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY))
^
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:40:59: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:40:59: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
sketch_oct24a:40: error: lvalue required as unary '&' operand
(mygprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY))
^
exit status 1
'mygrps' was not declared in this scope
In file included from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM.h:46:0,
from C:\Users\\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:2:
C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3ShieldV1BandManagement.h:49:125: warning: 'typedef' was ignored in this declaration
typedef enum GSM3GSMBand {UNDEFINED, EGSM_MODE, DCS_MODE, PCS_MODE, EGSM_DCS_MODE, GSM850_PCS_MODE, GSM850_EGSM_DCS_PCS_MODE};
^
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino: In function 'void setup()':
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:35:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
if((gsmaccess.begin(PINNUMBER)==GSM_READY) &
^
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:36:63: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
(mygprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
^
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:36:63: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
C:\Users\Documents\Arduino\sketch_sep26a\sketch_sep26b\sketch_oct24a\sketch_oct24a.ino:36:63: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
librariesGSM\GSM3SoftSerial.cpp.o (symbol from plugin): In function `GSM3SoftSerial::spaceAvailable()':
(.text+0x0): multiple definition of `__vector_3'
libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin): In function `GSM3SoftSerial::spaceAvailable()':
(.text+0x0): multiple definition of `__vector_4'
libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin): In function `GSM3SoftSerial::spaceAvailable()':
(.text+0x0): multiple definition of `__vector_5'
libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\AppData\Local\Temp\ccoez2D7.ltrans1.ltrans.o: In function `main':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to `loop'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.
Stripping out all the warnings and the stupid white space, you have this:
librariesGSM\GSM3SoftSerial.cpp.o (symbol from plugin): In function `GSM3SoftSerial::spaceAvailable()':
(.text+0x0): multiple definition of `__vector_3'
libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin): In function `GSM3SoftSerial::spaceAvailable()':
(.text+0x0): multiple definition of `__vector_4'
libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin): In function `GSM3SoftSerial::spaceAvailable()':
(.text+0x0): multiple definition of `__vector_5'
libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\AppData\Local\Temp\ccoez2D7.ltrans1.ltrans.o: In function `main':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to `loop'
You can NOT use SoftwareSerial in any sketch that uses GSM, because it implements a version of software serial that uses all the same resources that SoftwareSerial needs.