Hello Everyone...
I am basically trying to make a speedometer using a GPS Module, and then send an sms message through the GSM Module if certain speed is exceeded.
I used the code attached, but I faced the following error: Error compiling for board Arduino/Genuino Uno.
Can anyone help me solve the problem.
the error code is:
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"
In file included from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries\GSM\src/GSM.h:46:0,
from C:\Users\awss\Documents\Arduino\intergration1\intergration1.ino:5:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries\GSM\src/GSM3ShieldV1BandManagement.h:49:1: 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\awss\Documents\Arduino\intergration1\intergration1.ino: In function 'boolean gsmmessage()':
C:\Users\awss\Documents\Arduino\intergration1\intergration1.ino:67:20: warning: invalid conversion from 'const char*' to 'char' [-fpermissive]
char remoteNum = "966....."; // telephone number to send sms
^~~~~~~~~~
C:\Users\awss\Documents\Arduino\intergration1\intergration1.ino:68:17: warning: invalid conversion from 'const char*' to 'char' [-fpermissive]
char txtMsg = "You car is speeding...";
^~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\awss\Documents\Arduino\intergration1\intergration1.ino:69:25: warning: invalid conversion from 'char' to 'const char*' [-fpermissive]
sms.beginSMS(remoteNum);
^
In file included from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries\GSM\src/GSM.h:53:0,
from C:\Users\awss\Documents\Arduino\intergration1\intergration1.ino:5:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries\GSM\src/GSM3SMSService.h:69:7: note: initializing argument 1 of 'int GSM3SMSService::beginSMS(const char*)'
int beginSMS(const char* to);
^~~~~~~~
libraries\GSM\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
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
#include <math.h> //math library to use for round function
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <LiquidCrystal.h>
#include <GSM.h>
//TinyGPS gps; //create a gps object
TinyGPSPlus gps;
GSM gsmAccess;
GSM_SMS sms;
#define PINNUMBER 2
float fLat, fLong; //floats for longitude and latitude; will be used to determine whether the GPS data is up to date or not
unsigned long fix_age; // returns +- latitude/longitude in degrees
const int rs = 12, en = 13, d4 = 9, d5 = 10, d6 = 6, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
SoftwareSerial ss(5, 4);
void setup()
{
Serial.begin(9600); //start the serial communication
lcd.begin(20, 4);
ss.begin(9600);
}
void loop()
{
while (ss.available() > 0)
{
gps.encode(ss.read());
if (gps.location.isUpdated())
{
lcd.print(" speedKmph= ");
lcd.print(gps.speed.kmph());
lcd.print(" speedmps= ");
lcd.print(gps.speed.mps());
delay(1000);
lcd.clear();
while ( 3 < gps.speed.mps() <10 )
{
gsmmessage();
}
}
}
while (ss.available() == 0)
{lcd.print(" No GPS Connection ");
delay(1000);
lcd.clear();
}
}
boolean gsmmessage()
{
char remoteNum = "966....."; // telephone number to send sms
char txtMsg = "You car is speeding...";
sms.beginSMS(remoteNum);
sms.print(txtMsg);
sms.endSMS();
}
intergration1.ino (1.5 KB)
I cannot open ino files on my device. More members will see your code if you post it according to the forum guidelines. Following the guidelines will get you better help faster.
When you have errors, post the entire text of the error message. Paraphrasing the message leave out much important information. It is easy to post the error. In the IDE there is a "copy error" button (lower right of the IDE window). Copy the error and paste the error into a post in code tags.
boolean gsmmessage()
{
char remoteNum = "966....."; // telephone number to send sms
char txtMsg = "You car is speeding...";
sms.beginSMS(remoteNum);
sms.print(txtMsg);
sms.endSMS();
}
You can't store a character pointer in a character. Did you mean to use character pointers or character arrays?
const char * remoteNum = "966....."; // telephone number to send sms
const char * txtMsg = "You car is speeding...";
char remoteNum[] = "966....."; // telephone number to send sms
char txtMsg[] = "You car is speeding...";
Or you could just use the string constants directly:
boolean gsmmessage()
{
sms.beginSMS("966.....");
sms.print( "You car is speeding...");
sms.endSMS();
}
The GSM library has its own built-in GSMSoftSerial so it can't be used with SoftwareSerial due to interrupt conflicts:
I would try an Arduino Micro which has built-in USB, leaving Serial1 free. You could then use Serial1 for GPS and the GSM library's GSMSoftSerial for the GSM module.
johnwasser:
The GSM library has its own built-in GSMSoftSerial so it can't be used with SoftwareSerial due to interrupt conflicts:
I would try an Arduino Micro which has built-in USB, leaving Serial1 free. You could then use Serial1 for GPS and the GSM library's GSMSoftSerial for the GSM module.
Thanks that was the reason of the problem, I deleted the software serial, and I can unplug the GPS pins during uploading the code. However, the problem I am facing now is that serial 1 is used for both the lcd display and the GPS, which causes conflict. Do you have a workaround that avoids software serial.
Abdulazizhd:
the problem I am facing now is that serial 1 is used for both the lcd display and the GPS, which causes conflict. Do you have a workaround that avoids software serial.
The LCD should not be using a serial connection at all. It appears to be using pins 6, 8, 9, 10, 12, and 13.
const int rs = 12, en = 13, d4 = 9, d5 = 10, d6 = 6, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
Could you post your new sketch (after Tools->Auto Format, of course)?
If you need more than two serial ports (Serial/Serial1 + SoftwareSerial/GSMSoftSerial) you should probably upgrade to an Arduino MEGA which has FOUR hardware serial ports: Serial, Serial1, Serial2, Serial3.
johnwasser:
The LCD should not be using a serial connection at all. It appears to be using pins 6, 8, 9, 10, 12, and 13.
const int rs = 12, en = 13, d4 = 9, d5 = 10, d6 = 6, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
Could you post your new sketch (after Tools->Auto Format, of course)?
If you need more than two serial ports (Serial/Serial1 + SoftwareSerial/GSMSoftSerial) you should probably upgrade to an Arduino MEGA which has FOUR hardware serial ports: Serial, Serial1, Serial2, Serial3.
#include <math.h> //math library to use for round function
//#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <LiquidCrystal.h>
#include <GSM.h>
#include <GSM3SoftSerial.h>
//TinyGPS gps; //create a gps object
TinyGPSPlus gps;
GSM gsmAccess;
GSM_SMS sms;
#define PINNUMBER "4843"
float fLat, fLong; //floats for longitude and latitude; will be used to determine whether the GPS data is up to date or not
unsigned long fix_age; // returns +- latitude/longitude in degrees
const int rs = 12, en = 13, d4 = 9, d5 = 10, d6 = 6, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//SoftwareSerial ss(5, 4);
void setup()
{
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("SMS Messages Sender");
// 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) {
notConnected = false;
} else {
Serial.println("Not connected");
delay(1000);
}
Serial2.begin(9600);
Serial.begin(9600); //start the serial communication
lcd.begin(20, 4);
}
}
void loop()
{
while (Serial2.available() > 0)
{
gps.encode(Serial2.read());
if (gps.location.isUpdated())
{
lcd.print(" speedKmph= ");
lcd.print(gps.speed.kmph());
lcd.print(" speedmps= ");
lcd.print(gps.speed.mps());
delay(1000);
lcd.clear();
while ( 3 < gps.speed.mps() < 10 )
{
gsmmessage();
}
}
}
while (Serial2.available() == 0)
{
lcd.print(" No GPS Connection ");
delay(1000);
lcd.clear();
}
}
boolean gsmmessage() {
boolean gsmm;
sms.beginSMS("9660000000");
sms.print( "You car is speeding...");
sms.endSMS();
return gsmm;
}
void setup()
{
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}
You're supposed to call Serial.begin() BEFORE you use the Serial port.
Serial2.begin(9600);
So... Arduino MEGA?
while ( 3 < gps.speed.mps() < 10 )
{
gsmmessage();
}
That is NOT how you compare against a range. This isn't Fortran. Are you SURE you want a WHILE loop so it continues to seen the same SMS message forever? I think an 'if' would be better.
if (gps.speed.mps() > 3 && gps.speed.mps() < 10)
{
gsmmessage();
}