I have a problem with this code that I am using GPS and gsm … but I have to comment(disable) the
Serial_GSM.begin(9600);
so the code of GPS start working,
or I have to comment(disable)
Serial_GPS.begin(9600);
so the GSM start working
///////////
but both of them at the same time they don’t work together so please could you help me with this
////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
#include <SoftwareSerial.h>
#include "TinyGPS++.h"
#include <stdio.h>
#include <stdlib.h>
SoftwareS erial Serial_GSM(7,8); // GSM Pins // RX=pin 8, TX=pin 7
SoftwareSerial Serial_GPS(10, 11); // GPS Pins // RX=pin 11, TX=pin 10
TinyGPSPlus gps;//This is the GPS object that will pretty much do all the grunt work with the NMEA data
void setup()
{
** ///////////////////////////////////////////////////////////////////////////////////////**
** Serial.begin(9600); // Arduino Serial baud rate**
** delay(500); **
** Serial_GSM.begin(9600);// This opens up communications to the GSM**
** delay(500); **
** Serial_GPS.begin(9600);// This opens up communications to the GPS**
** delay(500);**
** //////////////////////////////////////////////////////////////////////////////////////**
** ////////////// The Next Code is to initialize GSM so it is able to receive sms/////////////**
//////////////////////////////////////////////////////////////////////////////////////// **
** Serial_GSM.print(“AT+CMGF=1\r”); // set SMS mode to text
** delay(100);**
** Serial_GSM.print(“AT+CNMI=2,2,0,0,0\r”);**
** // blurt out contents of new SMS upon receipt to the GSM shield’s serial out**
** delay(100);**
** Serial.println(“Ready…”);**
/////////////////////////////////////////////////////////////////////////////////////////
}
void loop()
{
** //////////////////GPS/////////////////////////**
** while(Serial_GPS.available())//While there are characters to come from the GPS**
** {**
** gps.encode(Serial_GPS.read());//This feeds the serial NMEA data into the library one char at a time**
** }**
** if(gps.location.isUpdated())//This will pretty much be fired all the time anyway but will at least reduce it to only after a package of NMEA data comes in**
** {**
** //Get the latest info from the gps object which it derived from the data sent by the GPS unit **
** Serial.println(“Satellite Count:”);**
** Serial.println(gps.satellites.value());**
** Serial.println(“Latitude:”);**
** Serial.println(gps.location.lat(), 6);**
** Serial.println(“Longitude:”);**
** Serial.println(gps.location.lng(), 6);**
** Serial.println(“Speed MPH:”);**
** Serial.println(gps.speed.mph());**
** Serial.println(“Altitude Feet:”);**
** Serial.println(gps.altitude.feet());**
** Serial.println("");**
** delay(5000); **
** }**
** ///////////////////////////////////////////**
** ///////////////////////////////////////////**
** ////////////this code to check the incoming sms from Mobile ///////////////////////////////**
** if(Serial_GSM.available() > 0)**
** {**
** if(Serial_GSM.find(“MyPassword”))///check if the Incoming sms that has been sent from Mobile is “My Password”**
** {**
** SendTextMessage("I got Your sms and Password is Correct ");//if the sms is "MyPassword"replay it with another sms I " got Your sms and Password is Correct "**
** delay(200);**
** Serial_GSM.println(“AT+CMGD=1,4”); //Delete all the sms in SIM card memory after the reply of sms **
** delay(500);**
** }**
** else**
** {**
** Serial.println(“No sms is coming or the Password is incorrect”); **
** }**
** }**
**} **
///this function is to send a sms
void SendTextMessage(String SendedMessage)
{
** Serial_GSM.println(“AT+CMGF=1”); //Because we want to send the SMS in text mode**
** delay(100);**
** Serial_GSM.println(“AT+CMGS=”+00491########"\r"); // the phone number that is want to send the sms to it**
** delay(100);**
** Serial_GSM.println(SendedMessage);//the content of the message**
** delay(100);**
** Serial_GSM.println((char)26);//the ASCII code of the ctrl+z is 26**
** delay(100);**
}