2

I'm trying to make something that has one led and a gsm module which is SIM800L, I'm using seeeduino GPRS library. What I'm trying to do is that when I call the GSM module and hung up after ringing once (about 2 seconds of ringtone) the led turns on, and when I call again and hang up after the second ringing sound (about 5 seconds of ringtone) the led turns off; Note that the SIM800 module when starts receiving a call it prints on the serial every ringing period (about 2.5sec):

RING

{number 0664xxxxx}

then it shows up again telling, 2 times for one rington, 3 times for two ringtons, and when I stop calling the GSM the module prints:

NO CARRIER

Here's my code as start:

#include <SoftwareSerial.h>
String inData;
char incomingByte;
//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 8

//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 7

//Create software serial object to communicate with SIM800
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);

void setup() {
  //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);
  while(!Serial);

  //Being serial communication witj Arduino and SIM800
  serialSIM800.begin(9600);
  delay(1000);

  Serial.println("Setup Complete!");
}

void loop() {
  //Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
  if(serialSIM800.available()){
    Serial.write(serialSIM800.read());
    incomingByte = serialSIM800.read();
    inData += incomingByte;
  }

if(inData != "")
   {
     if (inData.indexOf("RING") >= 0) {
      delay(4000);
      serialSIM800.println("ath"); // Hang up at command
      inData = "";
     }  
  }

  //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
  if(Serial.available()){     
    serialSIM800.write(Serial.read()); 
  }
}

I did this code so it hangs up 4 seconds after calling printing the message "RING", but it didn't work, can you please help guys, thanks!

VE7JRO
  • 2,554
  • 18
  • 25
  • 29
M. Serseg
  • 53
  • 6

0 Answers0