domingo, 27 de diciembre de 2015

relay with gsm/ acticacion de reles con un SMS

the following components allow to control differents devices via SMS.
(this control will allow to make a irrigation smart system )




code to gsm shield:

       
#include "SIM900.h"
#include "sms.h"
#include "SoftwareSerial.h"
#include "sms.h"
SMSGSM sms;

boolean started=false;
char smsbuffer[160];
char n[20];
int inc=10;
int  porta = 13;
//inserir o número telefonico
char number[]="+56963022591";

int pinmotor=13;
int i=0;
void setup() 
{
  
  pinMode(pinmotor,OUTPUT);
  //Serial connection.
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  if (gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
  if(started){
    delsms();
  }

};

void loop() 
{
   
  int pos=0;
  //Serial.println("Loop");
  if(started){
    pos=sms.IsSMSPresent(SMS_ALL);
    if(pos){
      sms.GetSMS(pos,n,smsbuffer,100);
      if(!strcmp(smsbuffer,"luz off")){
     
        digitalWrite(pinmotor,LOW);
        delay(100);
      }      
      if(!strcmp(smsbuffer,"luz on")){
       
       // for(i=0; i<256 10="" at="" code="" del="" delay="" delsms="" digitalwrite="" do="" else="" for="" i="" if="" int="" it="" max="" ncant="" ndeleted="" nfind="" pinmotor="" pos="" serial.print="" serial.println="" sms.deletesms="" sms="" the="" times="" void="">