Hy guys,
I am working on a project that involves sending a SMS whenever the alarm turns on. I am using Arduino UNO and aGSM Shield
The problem that I am having is sending the SMS. If I just run an ordinary SendSMS code then I get the message. But for my project, it won't send.
So the logic behind what I want to do is this:
Only when GSM is initialized then you can go ahead and arm the system. Then, only after the system is armed(by the press of a button) if you block the laser, the alarm will go on and send SMS notification. Otherwise do nothing.
I've done everything but manage to send the SMS notification.
My code:
void loop()
{
// check to see if GSM initialized
if (neconectat)
{
//check to see if I pressed the button to arm the system
state = digitalRead(senzorArmare);
if (state != lastState)
{
if (state == HIGH)
{
if (armat == HIGH) armat = LOW;
else armat = HIGH;
}
lastState = state;
}
//next time the button is pressed the system will be disarmed
if (armat==HIGH )
{
digitalWrite(indicatorArmare,HIGH); // indicatorArmare is a led that turns on when button is pressed
analogValue=analogRead(LDR); //read value from the LDR
delay(50);
Serial.println(analogValue); // just to see on serialMonitor the valuea red
if (analogValue>20 ) // if beam is broken
{
digitalWrite(ledAlarma,LOW); //ledAlarm is a led that turns on when beam is broken
digitalWrite(speaker,LOW);
}
else
{
digitalWrite(ledAlarma,HIGH);
digitalWrite(speaker,HIGH);
Serial.println("ALARMA!");
ok=true; // 1st ok = false - it turns on only when beam is broken
}
}
else
{
digitalWrite(indicatorArmare,LOW);
}
}
if (ok) then trimiteMesaj;
}
// send the message function
void trimiteMesaj(){
sms.beginSMS(charbuffer); // charbuffer - my phone nr
sms.print(mesaj); //mesaj - the message to send
sms.endSMS();
Serial.println("\nCOMPLETE!\n"); //just to see if the system runs this function
}
Ok so when I interrupt the beam the system holds ( I see the "ALARMA!" message on serialMonitor but nothing else happens). After 3-4 seconds COMPLETE! appears on the serialMonitor but the message is not sent.
PS: The GSM Shield is connected to a recommaned power supply.
Thank you,
Vlad C.