Sending SMS alarms with SquidBee
Marcos Yarza - November 11, 2008


Important: Libelium has launched a new sensor device: Waspmote. It is ready for research and market applications. You can discover the differences between both platforms in the document: Waspmote vs SquidBee.


The "Alarm SMS Mote" is developed from the article GPRS communication in SquidBee, where is shown how to add GPRS communication to SqidBee. Now, using this hardware we'll develop the software nedeed to send SMS when a command is received by the mote.

3
First thing to do is set up the hardware (GPRS communication in SquidBee).

Now we have in our Wireless sensor network a mote than is able to communicate with the sensor network (IEEE 802.15.4) and with GPRS netwok. This gives us the possibility of send SMS to standard movil phones.

This new feature is what we use in this article. The mote will send an alarm SMS when it get a code from the sensor network.

We have a network like this:

8

The software than is controlling the communications can be divided in two parts, one part controlls the ZigBee communication and the second part controlls the SMS feature. The second part is implemented into a function (sendAlarmSMS()).

The main program is waiting data from XBee and when it get some data it checks if those data received are equal to the alarma code (01 in this example) and if the code received is the alarm code, it calls the function sendAlarmSMS() and the SMS is sent, once the SMS is sent, the mote goes back to the "waiting" state.

Arduino code

/*
* Copyright (C) 2008 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 0.1
* Author: Marcos Yarza <m.yarza [at] libelium [dot] com>
*/

#include <SoftwareSerial.h>          // include the SoftwareSerial library for communicating with XBee shield

#define rxPin 9                      // the pins of the "new" serial port
#define txPin 8

// set up a new serial port
SoftwareSerial xbee = SoftwareSerial(rxPin, txPin);

int led = 13;
int onModulePin = 2;        // the pin to switch on the module (without press on button)

int timesToSend = 1;        // Numbers of SMS to send
int count = 0;

int inData = 0;
int inData1 = 0;
int inData2 = 0;
int inData3 = 0;
int inData4 = 0;
int inData5 = 0;

void switchModule(){
  digitalWrite(onModulePin,HIGH);
  delay(2000);
  digitalWrite(onModulePin,LOW);
}

void sendAlarmSMS(){
   
    Serial.print("AT+CMGS=");                      // send the SMS command
    Serial.println(""*********"");               // send the number
    delay(1500);
    Serial.println("Alaram from SquidBee mote!!!!!!");      // the SMS body
    delay(500);
    Serial.println(26,BYTE);                // end of message command 1A (hex)
     
}

void setup(){

  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);

  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);

  Serial.begin(115200);                     // the GPRS port
  
  xbee.begin(9600);                        // set the data rate for the SoftwareSerial port
   
  switchModule();                          // swith the module ON the led on the module starts blinking

  delay(20000);                            // waits 20 seconds for starting up the module                 
 
  Serial.println("AT+CMGF=1");             // set the SMS mode to text
 
  delay(2500);
  xbee.println("SquidBee alarm mote ready");
  delay(500);
 
  
}

void loop(){
   xbee.println("Waiting the alarm command");
 
   inData = xbee.read();
   inData1 = xbee.read();
  
   if ((inData == '0')&&(inData1 == '1')){          // if I get 01 from XBee I send the alarm
     sendAlarmSMS();
     xbee.println("01 received, alarma sent");
    
     delay(4000);
   }
  
}

 

gallery.png
theGroup.png

barra_lateral/rss
Research
  • Enclosure
  • Energy Management
  • GPS Mesh Networks
  • Hardware Node
  • Manager Platform
  • Mesh Routing Protocols
  • Sensor Integration
  • System and Communications
barra_lateral/techM