Monday, November 4, 2013

First Things

I wanted a simpler, lower powered monitor so I am investigating using an Arduino Uno with a Linksprite SIM900-based GPRS card. My appreciation to http://tronixstuff.com/tutorials/ for the core code example used in this post.

I have an initial trial setup working and able to send and receive text messages and call my cell phone using the GoPhone sim card (443 379-XXXX) I have been using in my USB modem with the Beaglebone Linux card. I did not need to change the sim card account to do this.

This (a simple hack, admittedly) sketch sends text messages to my iPhone:

// Send text to iphone via Linksprite SIM900 arduino shield
// Works 11/4/2013

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);

void setup()
{
  SIM900.begin(19200);
  SIM900power();  
  delay(20000);  // give time to log on to network. 
}

void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(5000);
}

void sendSMS(char *textmsg)
{
  SIM900.print("AT+CMGF=1\r");                                                        // AT command to send SMS message
  delay(100);
  SIM900.println("AT + CMGS = \"+1410XXXXXXX\"");                                     // recipient's mobile number, in international format
  delay(100);
  SIM900.println(textmsg);        // message to send
  delay(100);
  SIM900.println((char)26);       // End AT command with a ^Z, ASCII code 26
  delay(100); 
  SIM900.println();
  delay(5000);                    // give module time to send SMS
}

void loop()
{
  sendSMS("Message 1");
  delay(10000);
  sendSMS("Message 2");
  SIM900power();                  // turn off module
  do {} while (1);
}


No comments:

Post a Comment