An ATtiny85 is to be used to receive GPS data on the software serial dedictaed RX pin. A GSM module is to be connected to the software serial dedicated TX pin.
Is this possible?
What best approach to use?
Hello brice3010
Yes.
If the software serial function is able to run in full duplex mode and the baudrate for GSM and GPS is equal.
Check it.
Have a nice day and enjoy coding in C++.
Hi Paul, thank you for your fast reply.
Just to make sure: in one software serial declaration I can use both the GPS (RX) pin to wait for incoming data and then use the GSM (TX) pin to transmit other data?
#include <SoftwareSerial.h>
#define txPin 5 //tx pin in GSM connection
#define rxPin 3 //rx pin in GPS connection
#include <SoftwareSerial.h>
#include <TinyGPS.h>
int state = 0;
const int pin = 9;
float gpslat, gpslon;
TinyGPS gps;
SoftwareSerial mySerial(3, 5); // RX, TX
void setup()
{
mySerial.begin(9600);
}
void loop()
{
mySerial.listen();
while (mySerial.available())
{
int c = mySerial.read();
if (gps.encode(c))
{
gps.f_get_position(&gpslat, &gpslon);
}
}
if (digitalRead(pin) == HIGH && state == 0) {
mySerial.print("\r");
delay(1000);
mySerial.print("AT+CMGF=1\r");
delay(1000);
/*Replace XXXXXXXXXX to 10 digit mobile number &
ZZ to 2 digit country code*/
mySerial.print("AT+CMGS=\"+ZZXXXXXXXXXX\"\r");
delay(1000);
//The text of the message to be sent.
mySerial.print("Latitude :");
mySerial.println(gpslat, 6);
mySerial.print("Longitude:");
mySerial.println(gpslon, 6);
delay(1000);
mySerial.write(0x1A);
delay(1000);
state = 1;
}
if (digitalRead(pin) == LOW) {
state = 0;
}
}
Hello brice3010
My recommandation was to check the communication functions for the micro controller used, was´nt it?
You can code the world best sketch as long as your requiremets aren´t met.
Have a nice day and enjoy coding in C++.
Which it is can not.
Well I think that is taken into account by my code: only after data from the GPS is received should there be transmission to the GSM module.