I brought a GSM Shield and I tried to send sms by the GSM shield. I connect GSM Shield to the arduino uno and I connect PIR sensor and 315MHz receiver(to get LP and SMOKE sensors signals when HIGH).
First I connected Arduino uno via USB but I didn't send sms messages as expected but sometimes it sent. According to the specification of GSM Shield it take upto 2A sometimes. So I use a battery to power the Arduino. I didn't recharge the battery after purchase since it shows 6.42V multimeter reading. It works as expected only in first time but now again it is not working, actually it is not registered to the network. I think there should be a kind of power issue. Can anyone tell me whether that battery is enough to initiate the GSM shield and register to the network or what was the problem of the setup. I am attaching the arduino code too, so please check whether it causes due to the coding.
#include <SoftwareSerial.h>
#include <VirtualWire.h>
#include "SIM900.h"
#include "sms.h"
SMSGSM sms;
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
const int transmit_pin = 12;
const int receive_pin = 4;
const int transmit_en_pin = 5;
const int PIRpin = 6;
boolean started=false;
int ledPin =10;
void setup(){
Serial.begin(9600);
Serial.println("Start");
pinMode(PIRpin,INPUT);
pinMode(ledPin,OUTPUT);
digitalWrite(PIRpin, LOW);
digitalWrite(ledPin,LOW);
vw_set_tx_pin(transmit_pin);
vw_set_rx_pin(receive_pin);
vw_set_ptt_pin(transmit_en_pin);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(300); // Bits per sec
vw_rx_start();
if(gsm.begin(4800)){
started=true;
digitalWrite(ledPin,HIGH);
Serial.println("Ready");
}else{
digitalWrite(ledPin,LOW);
}
};
void loop(){
if(started){
//Serial.println("Start");
if(digitalRead(PIRpin) == HIGH){
Serial.println("Send SMS");
sms.SendSMS("0783972406", "Motion detect");
}
if (vw_get_message(buf, &buflen))
{
if (buf[0] == 'l')
{
Serial.println("L");
sms.SendSMS("0783972406", "Gas Leak in the house. Call police 119");
}else if(buf[0] == 's'){
Serial.println("S");
sms.SendSMS("0783972406", "Smoke in the house. Call police 119");
}
}
}
};
Please I am doing this as project. I tried several weeks to solve this but I failed. I am new to Arduino and Electronics too. Please help me to solve this.
Thank you