Go Down

Topic: Sending SMS with data point in it via Arduino SMS Shield (Read 1 time) previous topic - next topic

cwall

Good afternoon!

I have an Arduino Mega with an Arduino GSM Shield and Adafruit Datalogger Shield. What I want to do is send an SMS once an hour that contains a value obtained by the sensors. I have a K-30 CO2 sensor which is measuring pCO2. I'd like to change the message hourly to send me the newest pCO2 to a google voice account I just set up. I think code like this should work, but I can't figure out how to make the message change hourly with the most recent value of pCO2 obtained by the sensor. Eventually I'd like to set the text messaging up with an if/then statement based on the RTC, something like if minute == 00, send an SMS message is what I'd hope for.

Code: [Select]
#include <GSM.h>
#include <SoftwareSerial.h>
#define PINNUMBER ""

// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSM_SMS sms;

// char array of the telephone number to send SMS
// change the number 1-212-555-1212 to a number
// you have access to
char remoteNumber[20]= "phonenumber"; 

// char array of the message

void setup()
{
  // initialize serial communications
  Serial.begin(9600);

  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");
}

void loop()
{
// take measurements of K-30 CO2 level, store to variables and SD card
//delay(however long I want in between samples);
sendSMS();
}

void sendSMS(){
  delay(10000);
  Serial.print("Message to mobile number: ");
  Serial.println(remoteNumber);

  // sms text
  Serial.println("SENDING");
  Serial.println();
  Serial.println("Message:");
  Serial.println(pCO2);

  // send the message
  sms.beginSMS(remoteNumber);
  sms.print(pCO2);
  sms.endSMS();
  Serial.println("\nCOMPLETE!\n"); 
}


Thanks for the help.

V/R
Colleen

Go Up