This is a sister project to the "GPS Logger, reading and Writing to and from SD" because it is connected, but then again a separate and stand alone device. For this project, I am currently using what I had on hand, and will be temporarily; a Arduino pro mini 168 Chinese copy, which is fine, until the two projects merge. Then I will be using a Nano 328.
This code is functional but limited, and is just a starting point. Both the pro mini 168 module and the GSM A6 module, are being powered by their USB ports, for now, that will also change when the projects merge. The virtual serial TX, RX are connected to pins (6,7) using<SoftwareSerial.h>, which will most likely change also.
The amount of characters that I'm able to send, over GSM, per text right now is 118. I'm hoping someone, with further knowledge can increase this amount per text. This code will also have to grab the data from the GPS module, then send a text message, every five minutes or so, automatically. This added after original posting I would also like to be able to upload a five character text (.) to reflect the sea level pressure to correctly adjust the altitude. End off added content
I had to piece the code together from copy pasting half at a time. I don't know why the Arduino IDE would not allow me to copy paste all at once but the Sketch should work fine.
#include <SoftwareSerial.h>
char messageIn;
// If more than 118 characters into the String, you will get giberish in the serial monitor
//...AT+CMGS="+181386753giberish here ...Notice that the final 2 cell phone numbers are "gibberish" covered.
// I used 120 characters to achieve the error
String coordinatesGPS = "-82.41273,28.07181,4433.00-82.41273,28.07181,4433.00-82.41273,28.07181,4433.00-82.41273,28.07181,4433.00testtesttestte";
SoftwareSerial mySerial(6, 7);
void setup()
{
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
//would not send a text message unless I sent these AT commands first
mySerial.println("AT");
delay(1000);
mySerial.println("ATD");
mySerial.println("ATH");
delay(100);
//Send a text
mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"+18133477680\"\r"); // Replace jenny jennies number with mobile number
delay(1000);
mySerial.println("Zeppelin initialized");// The SMS text you want to send
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
void loop()
{
// mySerial.println("s");
// delay(2000);
if (Serial.available() > 0)
switch (Serial.read())
{
case 's':
SendMessage();
break;
case 'r':
RecieveMessage();
break;
}
if (mySerial.available() > 0)
Serial.write(mySerial.read());
}
void SendMessage()
{
mySerial.println("AT");
delay(1000);
mySerial.println("ATD");
mySerial.println("ATH");
delay(100);
mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"+18138675309\"\r"); // Replace jenny jennies cell number with mobile number
delay(1000);
mySerial.println(coordinatesGPS);// The SMS text you want to send
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
void RecieveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000);
}