Good morning,
I am trying to send the data collected from an Atlas Scientific sensor to my mobile telephone, using Arduino Uno and the Arduino GSM-Shield (Quectel M10). Unfortunately, I have been unable to send the specific data despite I can send any other message.
Any help will be appreciated to place the data as an SMS, following is the sketch I am using.
Best regards,
#include <GSM.h>
#define PINNUMBER ""// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;
#define txpin 3;
#define rxpin 2;
String inputstring = ""; //a string to hold incoming data from the PC
String sensorstring = ""; //a string to hold the data from the Atlas Scientific product
boolean input_stringcomplete = false; //have we received all the data from the PC
boolean sensor_stringcomplete = false; //have we received all the data from the Atlas Scientific product
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("SMS Messages Sender");
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a 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");
{
char inchar = (char)Serial.read(); //get the char we just received
inputstring += inchar; //add it to the inputString
if(inchar == '\r') {input_stringcomplete = true;} //if the incoming character is a , set the flag
}
if (sensor_stringcomplete)
{ //if a string from the Atlas Scientific product has been received in its entirety
Serial.print(sensorstring); //use the hardware serial port to send that data to the PC
sensorstring = ""; //clear the string:
sensor_stringcomplete = false; //reset the flag used to tell if we have received a completed string from the Atlas Scientific product
}
while (Serial.available()) //while a char is holding in the serial buffer
{
char inchar = (char)Serial.read(); //get the new char
sensorstring += inchar; //add it to the sensorString
if (inchar == '\r') {sensor_stringcomplete = true;} //if the incoming character is a , set the flag
}
}
void loop()
{
// sms text
Serial.print("Now, enter SMS content: ");
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
// send the message
sms.beginSMS("83860450");
sms.print(sensorstring);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
delay(10000);
while (1>0);
}