In this article, we are going to make our own Caller ID detection using Arduino. Usually, there are several libraries over the internet, but recently I had some bad experiences with most of them. That is why I simplified the process so that we can easily integrate this function in our GSM project. So let’s find it out.



About GSM library:

There are lots of libraries for GSM on the Arduino platform. The most common one is Adafruit_FONA. The library is good for complete phone function. I personally used this library for different purposes. But the problem is, when using the caller ID detection function, the Arduino works fine it is used only a single feature.

As you may need to use this function for different purposes, so you may add some other functions. Then the problem comes in. The Arduino falls in deadloop.

And once this starts, no way to come back to work except restart the power. I was looking for a solution to this. And from that point, I wrote this simple code that we can use for caller ID detection that never falls in deadloop like that one.

But before that, you may need to know more about GSM modules. Here I used SIM800L the most common one. You can use similar modules.

The code:

#include <SoftwareSerial.h>
#define RX 4
#define TX 3
SoftwareSerial gsm = SoftwareSerial(TX, RX);

void setup()

  gsm.println("AT+CLIP=1\r\n");//enable caller id


void loop()
  while (gsm.available())
    String line = gsm.readStringUntil('\n'); 
    int index_line = line.indexOf("+88");//find the position of phn_initial  
    index_line+=3;//start after +88, [3 digits leter] 
    line = line.substring(index_line, index_line+11); //seperate phone number from main String
    int line_len = line.length() + 1;
    char phn[line_len];
    line.toCharArray(phn, line_len);
    if (line_len >= 11)



When anyone calls to the number (SIM number of the module), it replies like this:

caller id detection using Arduino.

Here, “+CLIP: “+880197xxxx70″,145,””,0,””,0” is the String we found from the module’s serial terminal.

Now, if we find the index of ‘+88’ which is my country code. [Use as per your country code], we can easily identify the caller ID.

Let’s see what happens if we run our code.


caller id detection using Arduino.

Now, you can easily use this code in your project to identify caller ID using GSM modules.

Thanks for your time. I hope this article will help you in your GSM projects.

For Professional Designs or Help:


You may check other articles: Interfacing multiple external EEPROM with Arduino through I2C


Mithun K. Das; B. Sc. in EEE from KUET; Head of R&D @ M's Lab Engineering Solution. "This is my personal blog. I post articles on different subjects related to electronics in the easiest way so that everything becomes easy for all, especially for beginners. If you have any questions, feel free to ask through the contact us page." Thanks.


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *