I have this code:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <GSM.h>
#define PINNUMBER "" // Opt from user
#define GPS_RX_PIN 2
#define GPS_TX_PIN 3
#define WHITE 0x7 //For LCD library
//Objects initialization
GSM gsmAccess;
GSM_SMS sms;
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
TinyGPSPlus gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);
// Chars and strings for gps values
char clat[10 + 20 + 1] = "Latitude/Longitude: ";
char clng[10 + 1];
String string1, string2, finalstr;
const int xpin = A0; // X-axis of the accelerometer
const int ypin = A1; // Y-axis
const int zpin = A2; // Z-axis (only on 3-axis models)
float convX = 0.0, convY = 0.0, convZ = 0.0;
int sampleDelay = 20;
char remoteNumber[20] = "306978666866"; // Opt from user
uint8_t i = 0;
void setup()
{
Serial.begin(9600); //GSM
ss.begin(4800); //gps
analogReference(EXTERNAL); // For external analog reference of ADXL335
pinMode(xpin, INPUT);
pinMode(ypin, INPUT);
pinMode(zpin, INPUT);
// Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setBacklight(WHITE);
lcd.setCursor(0, 0);
// GSM connection state
boolean notConnected = true;
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER) == GSM_READY)
notConnected = false;
else
{
lcd.print("Not connected");
delay(1000);
}
}
lcd.print("GSM initialized");
delay(2000);
lcd.print("SELECT=Emergency");
}
void loop()
{
bool uniFlag = false;
int x = analogRead(xpin);
delay(1); // Add a small delay between pin readings. I read that you should
// do this but haven't tested the importance.
int y = analogRead(ypin);
delay(1);
int z = analogRead(zpin);
// zero_G is the reading we expect from the sensor when it detects
// no acceleration. Subtract this value from the sensor reading to
// get a shifted sensor reading.
float zero_G = 502.0;
// 'scale' is the number of units we expect the sensor reading to
// change when the acceleration along an axis changes by 1G.
// Divide the shifted sensor reading by scale to get acceleration in Gs.
// 610 (1g) - 502 (0g) = 108
float scale = 108;
//value (g) = (measurement - 502)/ 108
convX = ((float)x - zero_G)/scale;
convY = ((float)y - zero_G)/scale;
convZ = ((float)z - zero_G)/scale;
delay(sampleDelay);
if (convX > 2 || convX < -2 || convY > 2 || convY < -2)
uniFlag = true;
uint8_t buttons = lcd.readButtons();
if (buttons) {
if (buttons & BUTTON_SELECT) {
uniFlag = true;}
}
if (uniFlag == true)
{
bool isGpsLocationValid = false;
do
{
while (ss.available()>0)
{
char c = byte(ss.read());
if (gps.encode(c))
{
if (gps.location.isValid())
{
dtostrf(gps.location.lat(), 10, 6, clat+20);
dtostrf(gps.location.lng(), 10, 6, clng);
isGpsLocationValid = true;
string1 = String(clat);
string2 = String(clng);
finalstr = string1 + string2;
}
}
}
} while (isGpsLocationValid == false);
}
sendSMS(finalstr);
}
void sendSMS(String thisString)
{
sms.beginSMS(remoteNumber);
sms.print(thisString);
sms.endSMS();
lcd.setCursor(0, 0);
lcd.print("Message sent!");
delay(10000); //for multiple bumps
}
When I try to compile it I get these errors:
GSM\GSM3SoftSerial.cpp.o: In function `__vector_5':
C:\Program Files (x86)\Arduino\libraries\GSM/GSM3SoftSerial.cpp:525: multiple definition of `__vector_5'
SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:319: first defined here
GSM\GSM3SoftSerial.cpp.o: In function `__vector_4':
C:\Program Files (x86)\Arduino\libraries\GSM/GSM3SoftSerial.cpp:518: multiple definition of `__vector_4'
SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:312: first defined here
GSM\GSM3SoftSerial.cpp.o: In function `__vector_3':
C:\Program Files (x86)\Arduino\libraries\GSM/GSM3SoftSerial.cpp:511: multiple definition of `__vector_3'
SoftwareSerial\SoftwareSerial.cpp.o:C:\Program Files (x86)\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:305: first defined here
What is going on? Is it that GSM.h declares SoftwareSerial inside? Are there any solutions?
This is the first time I get these kinds of compilation errors and have no idea what is going on or how to fix it.
@and my username or to flag this. Thanks!