gprs2 + realy2

hi all…

trying to use gprs 2.0 + relay 2.0. basically depending on what comes in via sms i want to turn on/off different relays…
using arduino uno. the shields are both seeed…

it almost works. except that the relays are not turning on/off. my guess is it has to do with the overlapping pins - gprs software serial is on 7 and 8 and the realys are on 4,5,6 and 7.

is there an example how to control the gprs via the hardware serial setting? so at least the serial will be on 0 and 1 and maybe then the relays will be controllable…

i did see an example on instructables but no matter what i do it doesn’t work for me…

any help will be appreciated…

thanks…

Hi
Sorry for the delayed reply
Follow the steps to implement your project
1.Mount the GPRS shield on the arduino board.
2.Don’t mount the relay shield on the arduino board instead make connections as shown in the diagram belowRelay_Shield_Connection.jpg
3.Upload the following sketch

[code]/*

  • Function : GPRS SMS Read Relay ON or OFF
  • Hardware : GPRS_Shield’s,Relay Shield
  • Copyright © 2015 Seeed Technology Limited
  • Website : www.seeed.cc
  • The MIT License (MIT)
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the “Software”), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is
  • furnished to do so, subject to the following conditions:
  • The above copyright notice and this permission notice shall be included in
  • all copies or substantial portions of the Software.
  • THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  • OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    */
    #include <GPRS_Shield_Arduino.h>
    #include <SoftwareSerial.h>
    #include <Wire.h>

#define PIN_TX 7
#define PIN_RX 8
#define BAUDRATE 19200

#define MESSAGE_LENGTH 20

char gprsBuffer[64];
char *s = NULL;

int Relay1 = 3;
int Relay2 = 4;
int Relay3 = 5;
int Relay4 = 6;

GPRS gprsTest(PIN_TX, PIN_RX, BAUDRATE);

void setup() {

  Serial.begin(19200);
  pinMode(Relay1, OUTPUT); // set a PIN D3 to DigitalOutput
  pinMode(Relay2, OUTPUT); // set a PIN D4 to DigitalOutput
  pinMode(Relay3, OUTPUT); // set a PIN D5 to DigitalOutput
  pinMode(Relay4, OUTPUT); // set a PIN D6 to DigitalOutput

  while (!gprsTest.init())
  {
  Serial.print("init error\r\n");
  delay(1000);
  }

  delay(3000);
  Serial.println("Init Success,send SMS message to this number RL1ON, RL2ON, RL3ON and RL4ON(Relay1,2,3 and 4 ON) or RL1OFF,RL2OFF,RL3OFF,RL4OFF (Relay1,2,3 and 4 OFF)");

}

void loop() {

  sim900_read_buffer(gprsBuffer, 32, DEFAULT_TIMEOUT);

  if (NULL != (s = strstr(gprsBuffer, "+CMTI: \"SM\"")))
  {
  char message[MESSAGE_LENGTH];
  int messageIndex = atoi(s + 12);

  gprsTest.readSMS(messageIndex, message, MESSAGE_LENGTH);
  Serial.print("Recv Message: ");
  Serial.println(message);

  if (NULL != strstr(message, "RL1ON")) 
  {
  digitalWrite(Relay1, HIGH);   // sets the Relay1 ON
  Serial.println("Relay1 ON");
  delay(1000);
  }

  if (NULL != strstr(message, "RL1OFF")) 
  {
  digitalWrite(Relay1, LOW);   // sets the Relay1 OFF
  Serial.println("Relay1 OFF");
  delay(1000);
  }

  if (NULL != strstr(message, "RL2ON")) 
  {
  digitalWrite(Relay2, HIGH);   // sets the Relay2 ON
  Serial.println("Relay2 ON");
  delay(1000);
  }

  if (NULL != strstr(message, "RL2OFF")) 
  {
  digitalWrite(Relay2, LOW);   // sets the Relay2 OFF
  Serial.println("Relay2 OFF");
  delay(1000);
  }


  if (NULL != strstr(message, "RL3ON")) 
  {
  digitalWrite(Relay3, HIGH);   // sets the Relay3 ON
  Serial.println("Relay3 ON");
  delay(1000);
  }

  if (NULL != strstr(message, "RL3OFF")) 
  {
  digitalWrite(Relay3, LOW);   // sets the Relay3 OFF
  Serial.println("Relay3 OFF");
  delay(1000);
  }


  
  if (NULL != strstr(message, "RL4ON")) 
  {
  digitalWrite(Relay4, HIGH);   // sets the Relay4 ON
  Serial.println("Relay4 ON");
  delay(1000);
  }

  if (NULL != strstr(message, "RL4OFF")) 
  {
  digitalWrite(Relay4, LOW);   // sets the Relay4 OFF
  Serial.println("Relay4 OFF");
  delay(1000);
  }
 }
  sim900_clean_buffer(gprsBuffer, 32);

}
[/code]
4.Use the "GPRS_SIM900 library on gitHub - Non Suli " in the link.

Please let us know if works and feel free to ask any queries regarding this project.

Thanks
Kavi