GSM library an Software serial library error
hello
i have 2 codes
the first code send sms through gsm module
and second read latitude , longtude gps module
when merge 2 codes send latitude , longtude gps phone through gsm
there error mean can't use software serial library , gsm library in same code
so can use gps module?
can 1 me please
i have 2 codes
the first code send sms through gsm module
code: [select]
#include <gsm.h>
#define pinnumber ""
// initialize library instance
gsm gsmaccess; // include 'true' parameter debug enabled
gsm_sms sms;
// char array of telephone number send sms
// change number 1-212-555-1212 number
// have access to
char remotenumber[20]= "01145445380";
// char array of message
string txtmsg="test";
void setup()
{
// initialize serial communications
serial.begin(9600);
serial.println("sms messages sender");
// connection state
boolean notconnected = true;
// start gsm shield
// if sim has pin, pass parameter of begin() in quotes
while(notconnected)
{
if(gsmaccess.begin(pinnumber)==gsm_ready)
notconnected = false;
else
{
serial.println("not connected");
delay(1000);
}
}
serial.println("gsm initialized");
sendsms();
}
void loop()
{
// nothing see here
}
void sendsms(){
serial.print("message mobile number: ");
serial.println(remotenumber);
// sms text
serial.println("sending");
serial.println();
serial.println("message:");
serial.println(txtmsg);
// send message
sms.beginsms(remotenumber);
sms.print(txtmsg);
sms.endsms();
serial.println("\ncomplete!\n");
}
and second read latitude , longtude gps module
code: [select]
/*
this sketch run skynav skm53 gps
rxd arduino pin 3
txd arduino pin 2
rst leave open
nc leave open
gnd ground
vcc +5
make sure download , save arduino/libraries folder tinygps.h
, newsoftserial.h files.
*/
#include <tinygps.h>
#include <softwareserial.h>
unsigned long fix_age;
softwareserial gps(6,7);
tinygps gps;
void gpsdump(tinygps &gps);
bool feedgps();
void getgps();
long lat, lon;
long lat, lon;
void setup(){
gps.begin(9600);
serial.begin(9600);
}
void loop(){
long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;
// retrieves +/- lat/long in 100000ths of degree
gps.get_position(&lat, &lon, &fix_age);
getgps();
serial.print("latitude : ");
serial.print(lat/1000000,7);
serial.print(" :: longitude : ");
serial.println(lon/1000000,7);
}
void getgps(){
bool newdata = false;
unsigned long start = millis();
// every 1 seconds print update
while (millis() - start < 1000)
{
if (feedgps ()){
newdata = true;
}
}
if (newdata)
{
gpsdump(gps);
}
}
bool feedgps(){
while (gps.available())
{
if (gps.encode(gps.read()))
return true;
}
return 0;
}
void gpsdump(tinygps &gps)
{
//byte month, day, hour, minute, second, hundredths;
gps.get_position(&lat, &lon);
lat = lat;
lon = lon;
{
feedgps(); // if don't feed gps during long routine, may drop characters , checksum errors
}
}
when merge 2 codes send latitude , longtude gps phone through gsm
there error mean can't use software serial library , gsm library in same code
so can use gps module?
can 1 me please
you using pin 2 & 3 in both cases.. gsm modem uses 2&3 tx & rx.
use different set of pins gps module.
use different set of pins gps module.
Arduino Forum > Using Arduino > Project Guidance > GSM library an Software serial library error
arduino
Comments
Post a Comment