Problem with programming GPS and GPRS shield to work together
hello,
i'v ordered gprs , gps shield arduino uno board.
i use them building simple gps tracking device take position , send web application periodically.
however, i've tested both of shields seperately see if work arduino uno expected. , do.
i gps coordinates (parsed tinygps) , managed send simple sms message phone gprs shield.
but problem when combined shields @ same time.
i believe problem in software serial baud rate. gprs shield use requires 19200 baud rate while gps works @ 9600.
as i'm new arduino i'm doing stupid mistake because i've never worked more software serials opened @ same time.
so, here code. when upload board i'm able receive , see gps coordinates @ 9600 i'm not able send sms message. hope can tell me problem , what's best way fix it.
thank much
i'v ordered gprs , gps shield arduino uno board.
i use them building simple gps tracking device take position , send web application periodically.
however, i've tested both of shields seperately see if work arduino uno expected. , do.
i gps coordinates (parsed tinygps) , managed send simple sms message phone gprs shield.
but problem when combined shields @ same time.
i believe problem in software serial baud rate. gprs shield use requires 19200 baud rate while gps works @ 9600.
as i'm new arduino i'm doing stupid mistake because i've never worked more software serials opened @ same time.
so, here code. when upload board i'm able receive , see gps coordinates @ 9600 i'm not able send sms message. hope can tell me problem , what's best way fix it.
thank much
code: [select]
#include <softwareserial.h>
#include <tinygps.h>
// create instance of tinygps object
tinygps gps;
void getgps(tinygps &gps);
softwareserial myserial(7, 8);
void setup()
{
myserial.begin(19200); // gprs baud rate
serial.begin(9600);
delay(500);
}
void loop()
{
byte a;
if (serial.available()) {
= serial.read();
if (gps.encode(a)) {
getgps(gps);
}
if (a=='send') {
sendtextmessage();
}
}
if (myserial.available()) {
serial.write(myserial.read());
}
}
void getgps(tinygps &gps) {
long latitude, longitude;
gps.get_position(&latitude, &longitude);
serial.print("lat: ");
serial.println(latitude);
serial.print("lon: ");
serial.println(longitude);
}
void sendtextmessage()
{
myserial.print("at+cmgf=1\r"); //because want send sms in text mode
delay(100);
myserial.println("at + cmgs = \"+385xxxxxxxxx\"");//send sms message, careful need add country code before cellphone number
delay(100);
myserial.println("a test message!");//the content of message
delay(100);
myserial.println((char)26);//the ascii code of ctrl+z 26
delay(100);
myserial.println();
}
serial works 1 device.
if gps , gprs both use serial communications, then need 2 actual or virtual serial interfaces communicate them.
you need check whether possible software serial, , have worry pin conflicts if stacking boards.
if gps , gprs both use serial communications, then need 2 actual or virtual serial interfaces communicate them.
you need check whether possible software serial, , have worry pin conflicts if stacking boards.
Arduino Forum > Using Arduino > Programming Questions > Problem with programming GPS and GPRS shield to work together
arduino
Comments
Post a Comment