{"id":61669,"date":"2025-06-10T15:28:00","date_gmt":"2025-06-10T19:28:00","guid":{"rendered":"https:\/\/www.engineersgarage.com\/?p=61669"},"modified":"2025-06-11T12:15:48","modified_gmt":"2025-06-11T16:15:48","slug":"articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms","status":"publish","type":"post","link":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/","title":{"rendered":"RPi Python Programming 22: Calls &#038; SMS using a SIM900A GSM-GPRS modem"},"content":{"rendered":"<p class=\"ai-optimize-6 ai-optimize-introduction\"><span data-preserver-spaces=\"true\">In the <a href=\"https:\/\/www.engineersgarage.com\/microcontroller-projects\/articles-raspberry-pi-sim900a-gsm-gprs-modem-at-commands\/\"><strong>previous tutorial<\/strong><\/a>, we covered the AT commands that are supported by a SIM900 GSM-GPRS modem. We\u2019ve already discussed how to interface a SIM900A GSM-GPRS modem with Raspberry Pi, Arduino, as well as other microcontrollers and desktop computers. Now, it&#8217;s time to use this modem to make and receive calls, and send and receive SMS.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-7\"><span data-preserver-spaces=\"true\">In this tutorial, we\u2019ll demonstrate voice call and SMS messaging using a SIM900A with Raspberry Pi (RPi) and a desktop computer.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-8\"><strong><span data-preserver-spaces=\"true\">Communicating with a GSM-GPRS modem using Python<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">We\u2019ve previously learned about serial universal asynchronous receiver\/transmitter (UART) communication using RPi\u2019s serial TTL port.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-9\"><span data-preserver-spaces=\"true\">Simply interface the GSM modem with RPi\u2019s serial TTL port and open a serial communication port with the modem using the serial.Serial() method. Next, you can send the AT commands to the modem using the serial.write() method and receive a response from the AT commands using the serial.read() method.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-10\"><span data-preserver-spaces=\"true\">The response from the modem can be stored in a variable and printed on the console the using print() method. It\u2019s also possible to design a\u00a0<\/span><strong><a class=\"_e75a791d-denali-editor-page-rtfLink\" href=\"https:\/\/www.engineersgarage.com\/featured\/rpi-python-programming-11-python-gui-with-tkinter\/\" target=\"_blank\" rel=\"noopener noreferrer\">GUI application using the TTK library<\/a><\/strong><span data-preserver-spaces=\"true\">\u00a0and a text editor so the data is sent and received over a serial port \u2014 and shown within a Python application.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-11\"><span data-preserver-spaces=\"true\">In fact, Python is platform-independent and can be used to set up serial communication on any device and any other platform (i.e. not just RPi\u2019s Linux platform but also others such as Win32 and macOS).<\/span><\/p>\n<p class=\"ai-optimize-12\"><span data-preserver-spaces=\"true\">On a desktop system, the modem can be interfaced using a USB-serial board. To do so, first figure out the port name where the GSM modem is interfaced with the desktop, via the USB interface. We\u2019ve covered how to\u00a0<\/span><a class=\"_e75a791d-denali-editor-page-rtfLink\" href=\"https:\/\/www.engineersgarage.com\/raspberrypi\/raspberry-pi-serial-communication-uart-protocol-ttl-port-usb-serial-boards\/\" target=\"_blank\" rel=\"noopener noreferrer\"><span data-preserver-spaces=\"true\"><strong>find a serial port name on a desktop here<\/strong><\/span><\/a><span data-preserver-spaces=\"true\">.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-13\"><span data-preserver-spaces=\"true\">Typically, the modem communicates at 9600 bps baud rate and 8N1 UART data encoding. The modems are designed to auto-detect the baud rate. While the data encoding scheme remains 8N1, the maximum 115200 bps baud rate can be used to communicate with the modem.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-14\"><strong><span data-preserver-spaces=\"true\">Booting the SIM900A GSM-GPRS modem<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">To begin, we must prepare the GSM modem for cellular communication. Insert a SIM card into the SIM cardholder of the SIM900A modem. The modem is similar to a mobile phone and requires a SIM card to connect with a cellular network.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-15\"><span data-preserver-spaces=\"true\">Most of the modems have SIM cardholders for Mini SIM (2FF form factor). However, Micro SIM (3FF form factor) and Nano SIM (4FF form factor) can also be plugged in so long as the SIM contacts touch the cardholder pins properly.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-16\"><span data-preserver-spaces=\"true\">Next, turn on the GSM modem by connecting the modem to a power adaptor (5V-12V, 2A). The modem\u2019s status LED or Network LED will start blinking. It typically blinks at a faster rate while the modem connects to the mobile network. Once the modem is connected to the subscribed communication service provider (CSP), it blinks every three seconds. It may take up to a minute for the modem to boot (just like a mobile phone boot) and connect with a subscribed mobile network.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-17\"><span data-preserver-spaces=\"true\">If you ring the plugged-in SIM, the modem will start ringing via the buzzer and flash the ring indicator LED on it. This confirms the modem is working. In fact, when you call the SIM number, the call is automatically picked up by the modem after a few rings. And if you connect a speaker and microphone to the modem, you can speak to and receive calls on the plugged-in SIM. So, the microphone and speaker input are actually on the modem.\u00a0\u00a0<\/span><\/p>\n<p class=\"ai-optimize-18\"><strong><span data-preserver-spaces=\"true\">Interfacing SIM900A with RPi<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">The SIM900A modem is a 5V device and Raspberry Pi is s 3.3V single-board computer. We cannot directly interface the TTL serial port of the SIM900 modem with RPi\u2019s serial TTL port.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-19\"><span data-preserver-spaces=\"true\">If you directly connect the serial ports of modem and RPi, it will transmit the serial data to the modem because the 5V modem can tolerate 3.3V UART voltages. But when you try to receive data from the modem on RPi, the 5V UART signals from modem can damage or destroy RPi\u2019s serial receiver pin.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-20\"><span data-preserver-spaces=\"true\">To be safe, let\u2019s use a 5V to 3.3V TTL Logic Shifter. A simple 5V-to-3V3 logic shifter can be designed using 1N4148 diode as shown in this circuit diagram:<\/span><\/p>\n<p class=\"ai-optimize-21\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-01.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61670\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-01-300x197.png\" alt=\"\" width=\"654\" height=\"430\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-01-300x197.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-01-362x238.png 362w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-01.png 491w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><\/a><\/p>\n<p class=\"ai-optimize-22\">Alternatively, you can use a 2, 4, or 8-channel level switching I\/O module. This is an 8-channel level switching bidirectional I\/O module:<\/p>\n<p class=\"ai-optimize-23\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61671\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-02-300x200.jpg\" alt=\"\" width=\"656\" height=\"437\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-02-300x200.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-02-357x238.jpg 357w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-02-600x400.jpg 600w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-02.jpg 608w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a><\/p>\n<p class=\"ai-optimize-24\">Next, connect the modem&#8217;s Rxd, Txd, and ground pins with those of RPi via the level-switching circuit or I\/O module. Now, you are ready to communicate with the modem over the serial port.<\/p>\n<p class=\"ai-optimize-25\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61672\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-03-300x123.png\" alt=\"\" width=\"699\" height=\"287\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-03-300x123.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-03-1024x419.png 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-03-768x314.png 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-03-1536x628.png 1536w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-03-2048x838.png 2048w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-03-368x151.png 368w\" sizes=\"auto, (max-width: 699px) 100vw, 699px\" \/><\/a><\/p>\n<p class=\"ai-optimize-26\"><strong><span data-preserver-spaces=\"true\">Making a call from Raspberry Pi<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">To enable serial communication with the modem on RPi, you must import the serial, RPi.GPIO, os, and time libraries. The os and time library are necessary to use the sleep() function, which ensures RPi awaits responses from the modem.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-27\"><span data-preserver-spaces=\"true\">Begin by setting the pin numbering system to the board numbers and access RPi\u2019s serial TTL port using the serial.Serial() method. The port name on Raspberry Pi is \/dev\/serial0. Alternatively, the port name can be \/dev\/ttyS0 or \/dev\/ttyAMA0 \u2014 use whichever one is the primary UART on the\u00a0<\/span><strong><a class=\"_e75a791d-denali-editor-page-rtfLink\" href=\"https:\/\/www.engineersgarage.com\/raspberrypi\/articles-raspberry-pi-models-2019\/\" target=\"_blank\" rel=\"noopener noreferrer\">respective Raspberry Pi<\/a><\/strong><span data-preserver-spaces=\"true\">.\u00a0\u00a0<\/span><\/p>\n<p class=\"ai-optimize-28\"><span data-preserver-spaces=\"true\">Send the AT command &#8220;AT&#8221; to the modem using the serial.write() method to check communication with it. Read the response from the modem using the serial.read() method and print it to the console using the print() method or to a GUI interface. The modem will respond &#8220;OK&#8221; if it\u2019s properly working and connected to Raspberry Pi.\u00a0<\/span><\/p>\n<ul>\n<li class=\"ai-optimize-29\"><span data-preserver-spaces=\"true\">To make a call, send an &#8220;ATD&lt;Mobile-Number&gt;&#8221; command to the modem<\/span><\/li>\n<li class=\"ai-optimize-30\"><span data-preserver-spaces=\"true\">To end the call, send an &#8220;ATH&#8221; command to the modem<\/span><\/li>\n<\/ul>\n<p class=\"ai-optimize-31\"><span data-preserver-spaces=\"true\">The Python script that&#8217;s shown below successfully makes a call on a number and ends the call after 30 seconds. The AT commands are passed as bytes to the modem and the &#8216;\\r&#8217; escape sequence is used to pass the command-line enter. You can also connect a microphone and speaker with the modem. Previously, we hacked an earphone so voice calls could be received on the GSM-GPRS modem.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-32\"><span style=\"color: #993300;\">import serial<\/span><br \/>\n<span style=\"color: #993300;\">import os, time<\/span><br \/>\n<span style=\"color: #993300;\">import RPi.GPIO as GPIO<\/span><\/p>\n<p class=\"ai-optimize-33\"><span style=\"color: #993300;\">GPIO.setmode(GPIO.BOARD)<\/span><br \/>\n<span style=\"color: #993300;\">port = serial.Serial(&#8220;\/dev\/ttyS0&#8221;, baudrate=9600, timeout=1)<\/span><\/p>\n<p class=\"ai-optimize-34\"><span style=\"color: #993300;\">port.write(b&#8217;AT\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-35\"><span style=\"color: #993300;\">port.write(b&#8217;ATD9166873301;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;Calling&#8230;&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(30)<\/span><br \/>\n<span style=\"color: #993300;\">port.write(b&#8217;ATH\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;Hang Call&#8230;&#8221;)<\/span><\/p>\n<p class=\"ai-optimize-36\"><strong><span data-preserver-spaces=\"true\">Receiving a call on RPi<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span>When the plugged-in SIM on the modem is called from a phone or any mobile device, the modem automatically picks up the call after a few rings. The modem transmits &#8220;RING&#8221; from its Txd pin when there\u2019s an incoming call. The number calling to the SIM can be extracted using the &#8220;AT+CLIP&#8221; command.<\/p>\n<p class=\"ai-optimize-37\"><span data-preserver-spaces=\"true\">This call is automatically picked up by the modem unless it\u2019s rejected, which can be done using the &#8220;ATH&#8221; AT command. To manually attend the call, the &#8220;ATA&#8221; command can be used.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-38\"><strong><span data-preserver-spaces=\"true\">Configuring SIM900 for SMS messaging<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">The modem first needs to be configured for SMS messaging from SIM900. Begin by checking if the modem is working by sending it the &#8220;AT&#8221; command. Next, turn off the echo by sending the &#8220;ATE0&#8221; command. Set indicators for receiving SMS using the &#8220;AT+CNMI&#8221; command.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-39\"><span data-preserver-spaces=\"true\">This is a set type command and has the following format:<\/span><\/p>\n<p class=\"ai-optimize-40\"><span style=\"color: #800000;\"><strong>AT+CNMI = &lt;mode&gt;, &lt;mt&gt;, &lt;bm&gt;, &lt;ds&gt;, &lt;bfr&gt;<\/strong><\/span><\/p>\n<p class=\"ai-optimize-41\"><strong>The &lt;mode&gt; can be passed using the following values:<\/strong><\/p>\n<p class=\"ai-optimize-42\"><span data-preserver-spaces=\"true\"><strong>0:<\/strong> A newly received message with unsolicited result codes are buffered in the modem. If the modem&#8217;s buffer is full, the result codes can be buffered elsewhere or the older indications can be replaced by new ones.<br \/>\n<\/span><span data-preserver-spaces=\"true\"><strong>1:<\/strong> The received message result codes are discarded and rejected when the modem is online (i.e. there\u2019s a live serial link between the modem and the controlling device). Otherwise, the result codes are directly transferred to the controlling device.<br \/>\n<\/span><span data-preserver-spaces=\"true\"><strong>2:<\/strong> The received message result codes are buffered in the modem when the modem is online (i.e. there\u2019s a live serial link between the modem and the controlling device). Otherwise, the result codes are directly transferred to the controlling device.<br \/>\n<\/span><span data-preserver-spaces=\"true\"><strong>3:<\/strong> In this mode, the received message result codes are directly transferred to the controlling device.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-43\"><strong>The &lt;mt&gt; can be passed using the following values:<\/strong><\/p>\n<p class=\"ai-optimize-44\"><strong>0:<\/strong> ThebSMS-DELIVER indications are not routed to the controlling device.<br \/>\n<strong>1:<\/strong> If the SMS-DELIVER is stored in the modem, an indication of its memory location is routed to the controlling device using the result codes (a response to the AT commands) for the &#8220;+CMTI:&lt;mem&gt;, &lt;index&gt;&#8221; command.<br \/>\n<strong>2:<\/strong> The SMS-DELIVER result codes are directly routed to the controlling device.<br \/>\n<strong>3:<\/strong> Class 3 SMS-DELIVERs are routed to the controlling device using the unsolicited result codes.<\/p>\n<p class=\"ai-optimize-45\"><strong>The &lt;bm&gt; can be passed using the following values: <\/strong><\/p>\n<p class=\"ai-optimize-46\"><strong>0:<\/strong> The CBM indications are not routed to the controlling device.<br \/>\n<strong>2:<\/strong> Any new CBMs are routed directly to the controlling device using the unsolicited result codes (a response to the AT command) \u2014 &#8220;+CMB: &lt;length&gt;&lt;CR&gt;&lt;LF&gt;&lt;pdu&gt;&#8221; for the PDU mode or &#8220;+CBM:&lt;sn&gt;,&lt;mid&gt;,&lt;dcs&gt;,&lt;pages&gt;&lt;CR&gt;&lt;LF&gt;&lt;data&gt; for the text mode.<\/p>\n<p class=\"ai-optimize-47\"><strong>The &lt;ds&gt; can be passed using the following values:<\/strong><\/p>\n<p class=\"ai-optimize-48\"><span data-preserver-spaces=\"true\"><strong>0:<\/strong> The SMS-STATUS-REPORTs are\u00a0<\/span><em><span data-preserver-spaces=\"true\">not<\/span><\/em><span data-preserver-spaces=\"true\">\u00a0routed to the controlling device.<br \/>\n<\/span><span data-preserver-spaces=\"true\"><strong>1:<\/strong> The SMS-STATUS-REPORTs are routed to the controlling device using the unsolicited result code (a response to the AT command) by using &#8220;+CDS:&lt;length&gt;&lt;CR&gt;&lt;LF&gt;&lt;pdu&gt;&#8221; for the PDU mode and &#8220;+CDS:&lt;fo,&lt;mr&gt;,[&lt;ra&gt;],[&lt;tora&gt;],&lt;scts&gt;,&lt;dt&gt;&lt;st&gt;&#8221; for the text mode.<\/span><\/p>\n<p class=\"ai-optimize-49\"><span data-preserver-spaces=\"true\">The &lt;bfr&gt; can be passed using the following values:<\/span><\/p>\n<p class=\"ai-optimize-50\"><span data-preserver-spaces=\"true\"><strong>0:<\/strong> The modem\u2019s buffer is flushed to the controlling device when the controlling device enters mode 1 to 3.<br \/>\n<\/span><span data-preserver-spaces=\"true\"><strong>1:<\/strong> The modem\u2019s buffer is cleared to the controlling device when the controlling device enters mode 1 to 3.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-51\"><span data-preserver-spaces=\"true\">Remember, the controlling device is the Raspberry Pi, Arduino, microcontroller, or the computer that\u2019s controlling the GSM modem. In the SIM900A AT command reference, the modem is referred to as the terminal adapter (TA) and the controlling device is referred to as the terminal equipment (TE).\u00a0<\/span><\/p>\n<p class=\"ai-optimize-52\"><span data-preserver-spaces=\"true\">In this case, we set the SMS indications to &#8220;AT+CNMI=1, 1, 0, 0, 0.&#8221;\u00a0<\/span><\/p>\n<p class=\"ai-optimize-53\">Next, check the preferred SMS storage location using the &#8220;AT+CPMS=?&#8221; command. The storage location can be set to the SIM card (&lt;sm&gt;) or phone\/modem (&lt;me&gt;).<\/p>\n<p class=\"ai-optimize-54\">There are three memories, where:<\/p>\n<p class=\"ai-optimize-55\"><strong>1.<\/strong> The messages are read and deleted<br \/>\n<strong>2.<\/strong> Writing and sending the messages are completed<br \/>\n<strong>3.<\/strong> Received messages are stored<\/p>\n<p class=\"ai-optimize-56\">We set all the three memories to the SIM card using the AT command: AT+CPMS=&#8221;SM&#8221;,&#8221;SM&#8221;,&#8221;SM.&#8221; In response, the modem sends back the used and total memory for all three of the operations (reading, writing, and storing received SMS).<\/p>\n<p class=\"ai-optimize-57\">These SMS settings will be lost if they\u2019re not saved to the modem. To save these settings, the command &#8220;AT+CSAS&#8221; is passed to the modem.<\/p>\n<p class=\"ai-optimize-58\">We deleted all of the current SMS messages stored in the SIM card using the AT+ CMGDA=&#8221;DEL ALL&#8221; command. Finally, we recheck the memory space used for the SMS messages with the AT+CPMS=&#8221;SM&#8221;,&#8221;SM&#8221;,&#8221;SM&#8221; command. This time the used memory locations are 0.<\/p>\n<p class=\"ai-optimize-59\"><span style=\"color: #993300;\">import serial<\/span><br \/>\n<span style=\"color: #993300;\">import os, time<\/span><br \/>\n<span style=\"color: #993300;\">import RPi.GPIO as GPIO<\/span><\/p>\n<p class=\"ai-optimize-60\"><span style=\"color: #993300;\">GPIO.setmode(GPIO.BOARD)<\/span><br \/>\n<span style=\"color: #993300;\">port = serial.Serial(&#8220;\/dev\/ttyS0&#8221;, baudrate=9600, timeout=1)<\/span><\/p>\n<p class=\"ai-optimize-61\"><span style=\"color: #993300;\">port.write(b&#8217;AT\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-62\"><span style=\"color: #993300;\">port.write(b&#8221;ATE0\\r&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-63\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CNMI=1,1,0,0,0\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-64\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CPMS=&#8221;SM&#8221;,&#8221;SM&#8221;,&#8221;SM&#8221;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-65\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CSAS\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(10)<\/span><\/p>\n<p class=\"ai-optimize-66\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CMGDA=&#8221;DEL ALL&#8221;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-67\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CPMS=&#8221;SM&#8221;,&#8221;SM&#8221;,&#8221;SM&#8221;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-68\"><strong><span data-preserver-spaces=\"true\">Sending the SMS from RPi<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">To send the SMS, first set the messaging to the text mode using &#8220;AT+CMGF=1&#8243; command. Then, select a number to send the SMS using the AT+CMGS=&#8221;XXXXXXXXXX&#8221; command, where XXXXXXXXXX is a mobile number.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-69\"><span data-preserver-spaces=\"true\">The message to be sent is stored in a variable. The output buffer is cleared using the reset_output_buffer()or the flushoutput() method but only if the serialpy version installed on RPI is less than 2.5.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-70\"><span data-preserver-spaces=\"true\">The message is concatenated with CTRL+Z or a substitute character using the char(26) method. The message along with the substitute character is encoded using the str.encode() method and sent to the modem using the serial.write() method.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-71\"><span style=\"color: #993300;\">import serial<\/span><br \/>\n<span style=\"color: #993300;\">import os, time<\/span><br \/>\n<span style=\"color: #993300;\">import RPi.GPIO as GPIO<\/span><\/p>\n<p class=\"ai-optimize-72\"><span style=\"color: #993300;\">GPIO.setmode(GPIO.BOARD)<\/span><br \/>\n<span style=\"color: #993300;\">port = serial.Serial(&#8220;\/dev\/ttyS0&#8221;, baudrate=9600, timeout=1)<\/span><\/p>\n<p class=\"ai-optimize-73\"><span style=\"color: #993300;\">port.write(b&#8217;AT\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-74\"><span style=\"color: #993300;\">port.write(b&#8221;AT+CMGF=1\\r&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;Text Mode Enabled&#8230;&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(3)<\/span><br \/>\n<span style=\"color: #993300;\">port.write(b&#8217;AT+CMGS=&#8221;9166873301&#8243;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">msg = &#8220;test message from SIM900A&#8230;&#8221;<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;sending message&#8230;.&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(3)<\/span><br \/>\n<span style=\"color: #993300;\">port.reset_output_buffer()<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><br \/>\n<span style=\"color: #993300;\">port.write(str.encode(msg+chr(26)))<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(3)<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;message sent&#8230;&#8221;)<\/span><\/p>\n<p class=\"ai-optimize-75\"><strong><span data-preserver-spaces=\"true\">Receiving the SMS on RPi<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">Received messages are stored in the SIM card or the phone\/modem. The received SMS message at a particular index can be read by passing the AT+CMGR=&lt;index&gt; command. To read all of the SMS messages stored in the configured memory (either the SIM card or the phone\/modem), the AT+CMGL=&#8221;ALL&#8221; command can be passed to the modem.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-76\"><span data-preserver-spaces=\"true\">The modem will respond with the SMS indications and a body of the SMS that are received.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-77\"><span style=\"color: #993300;\">import serial<\/span><br \/>\n<span style=\"color: #993300;\">import os, time<\/span><br \/>\n<span style=\"color: #993300;\">import RPi.GPIO as GPIO<\/span><\/p>\n<p class=\"ai-optimize-78\"><span style=\"color: #993300;\">GPIO.setmode(GPIO.BOARD)<\/span><br \/>\n<span style=\"color: #993300;\">port = serial.Serial(&#8220;\/dev\/ttyS0&#8221;, baudrate=9600, timeout=1)<\/span><\/p>\n<p class=\"ai-optimize-79\"><span style=\"color: #993300;\">port.write(b&#8217;AT\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-80\"><span style=\"color: #993300;\">port.write(b&#8221;ATE0\\r&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-81\"><span style=\"color: #993300;\">port.write(b&#8221;AT+CMGF=1\\r&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;Text Mode Enabled&#8230;&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-82\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CPMS=&#8221;SM&#8221;,&#8221;SM&#8221;,&#8221;SM&#8221;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-83\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CMGR=1\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(100)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-84\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CMGL=&#8221;ALL&#8221;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(300)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-85\"><strong><span data-preserver-spaces=\"true\">Interfacing SIM900A with a desktop computer<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">When using a desktop computer, the GSM-GPRS modem can be interfaced with a USB-to-serial board. The modem via USB-to-serial board is identified as a USB slave on the desktop.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-86\"><span data-preserver-spaces=\"true\">After figuring out the serial port name on the desktop system (macOS, Linux, or Windows), it\u2019s only necessary to change the serial port name in the above scripts.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-87\"><span data-preserver-spaces=\"true\">The modem is interfaced to the desktop as follows:<\/span><\/p>\n<p class=\"ai-optimize-88\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-04.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61674\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-04-245x300.png\" alt=\"\" width=\"675\" height=\"829\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-04-245x300.png 245w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-04-835x1024.png 835w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-04-768x942.png 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-04-194x238.png 194w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-04.png 910w\" sizes=\"auto, (max-width: 675px) 100vw, 675px\" \/><\/a><\/p>\n<p class=\"ai-optimize-89\">Here, we\u00a0have connected the GSM-GPRS modem with a Windows computer. On our Windows desktop, the modem via the USB-serial board is identified as COM22.<\/p>\n<p class=\"ai-optimize-90\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-05-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-61675 aligncenter\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-05-300x225.jpg\" alt=\"\" width=\"655\" height=\"491\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-05-300x225.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-05-1024x768.jpg 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-05-768x576.jpg 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-05-1536x1152.jpg 1536w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-05-2048x1536.jpg 2048w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-05-317x238.jpg 317w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/a><\/p>\n<p class=\"ai-optimize-91\"><strong><span data-preserver-spaces=\"true\">Making a call from a desktop computer<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">As mentioned earlier in the Python script, to make a call from Raspberry Pi, first comment or remove the following RPi specific lines:<\/span><\/p>\n<p class=\"ai-optimize-92\"><span style=\"color: #800000;\"><strong>import RPi.GPIO as GPIO<br \/>\nGPIO.setmode(GPIO.BOARD)<br \/>\nport = serial.Serial(&#8220;\/dev\/ttyS0&#8221;, baudrate=9600, timeout=1)<\/strong><\/span><\/p>\n<p class=\"ai-optimize-93\"><span data-preserver-spaces=\"true\">Open a serial communication with the COM port, where the GSM modem is connected via the USB-serial board. Here, it is using COM22.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-94\"><span data-preserver-spaces=\"true\">Add this line:<br \/>\n<\/span><span style=\"color: #800000;\"><strong>port = serial.Serial(&#8220;COM22&#8221;, baudrate=9600, timeout=1)<\/strong><\/span><\/p>\n<p class=\"ai-optimize-95\"><span data-preserver-spaces=\"true\">Now, we can make a call from the desktop using the SIM900 modem.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-96\"><span style=\"color: #993300;\">import serial<\/span><br \/>\n<span style=\"color: #993300;\">import os, time<\/span><br \/>\n<span style=\"color: #993300;\">#import RPi.GPIO as GPIO<\/span><\/p>\n<p class=\"ai-optimize-97\"><span style=\"color: #993300;\">#GPIO.setmode(GPIO.BOARD)<\/span><br \/>\n<span style=\"color: #993300;\">#port = serial.Serial(&#8220;\/dev\/ttyS0&#8221;, baudrate=9600, timeout=1)<\/span><br \/>\n<span style=\"color: #993300;\">port = serial.Serial(&#8220;COM22&#8221;, baudrate=9600, timeout=1)<\/span><\/p>\n<p class=\"ai-optimize-98\"><span style=\"color: #993300;\">port.write(b&#8217;AT\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-99\"><span style=\"color: #993300;\">port.write(b&#8217;ATD9166873301;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;Calling&#8230;&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(30)<\/span><br \/>\n<span style=\"color: #993300;\">port.write(b&#8217;ATH\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;Hang Call&#8230;&#8221;)<\/span><\/p>\n<p class=\"ai-optimize-100\"><strong>The result:<\/strong><\/p>\n<p class=\"ai-optimize-101\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-06.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61676\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-06-284x300.png\" alt=\"\" width=\"655\" height=\"692\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-06-284x300.png 284w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-06-225x238.png 225w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-06.png 680w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/a><\/p>\n<p class=\"ai-optimize-102\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22-R07-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-61677 aligncenter\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22-R07-300x225.jpg\" alt=\"\" width=\"656\" height=\"492\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22-R07-300x225.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22-R07-1024x768.jpg 1024w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22-R07-768x576.jpg 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22-R07-1536x1152.jpg 1536w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22-R07-2048x1536.jpg 2048w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22-R07-317x238.jpg 317w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a><\/p>\n<p class=\"ai-optimize-103\"><iframe loading=\"lazy\" src=\"https:\/\/drive.google.com\/file\/d\/155hN_UI3MmdyA2uCbQ9auFN3ebGXEUn3\/preview\" width=\"640\" height=\"480\"><\/iframe><\/p>\n<p class=\"ai-optimize-104\"><strong>Receiving a call on a desktop computer<br \/>\n<\/strong>To receive a call on a desktop computer, the process is much the same as on Raspberry Pi. We can pass the commands to end incoming call or manually answer these call using a serial application (such as Termite or Putty) on a Windows desktop.<\/p>\n<p class=\"ai-optimize-105\"><strong>Configuring SIM900 for SMS messaging<\/strong> <strong>on a desktop<\/strong><br \/>\nHere, we also need to comment or remove RPi&#8217;s specific lines and add the proper code to open the serial COM port of a Windows desktop in the Python script \u2013 which must be written to configure the SMS settings on Raspberry Pi.<\/p>\n<p class=\"ai-optimize-106\"><span style=\"color: #993300;\">import serial<\/span><br \/>\n<span style=\"color: #993300;\">import os, time<\/span><br \/>\n<span style=\"color: #993300;\">#import RPi.GPIO as GPIO<\/span><\/p>\n<p class=\"ai-optimize-107\"><span style=\"color: #993300;\">#GPIO.setmode(GPIO.BOARD)<\/span><br \/>\n<span style=\"color: #993300;\">#port = serial.Serial(&#8220;\/dev\/ttyS0&#8221;, baudrate=9600, timeout=1)<\/span><br \/>\n<span style=\"color: #993300;\">port = serial.Serial(&#8220;COM22&#8221;, baudrate=9600, timeout=1)<\/span><\/p>\n<p class=\"ai-optimize-108\"><span style=\"color: #993300;\">port.write(b&#8217;AT\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-109\"><span style=\"color: #993300;\">port.write(b&#8221;ATE0\\r&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-110\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CNMI=1,1,0,0,0\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-111\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CPMS=&#8221;SM&#8221;,&#8221;SM&#8221;,&#8221;SM&#8221;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-112\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CSAS\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(10)<\/span><\/p>\n<p class=\"ai-optimize-113\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CMGDA=&#8221;DEL ALL&#8221;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-114\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CPMS=&#8221;SM&#8221;,&#8221;SM&#8221;,&#8221;SM&#8221;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-115\"><strong>The result:<\/strong><\/p>\n<p class=\"ai-optimize-116\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-08.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61678\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-08-300x292.png\" alt=\"\" width=\"655\" height=\"638\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-08-300x292.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-08-245x238.png 245w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-08.png 681w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/a><\/p>\n<p class=\"ai-optimize-117\">From the result codes received from the modem, a maximum of 25 messages can be stored in the SIM card. In this case, there were already two messages stored on it.<\/p>\n<p class=\"ai-optimize-118\">After deleting all of the current messages while in configuration, there are 0 used in the SMS memory locations.<\/p>\n<p class=\"ai-optimize-119\"><strong>Sending the SMS from a desktop computer<\/strong><br \/>\nOnce again, comment or remove RPi\u2019s specific lines. Add the proper code to open the serial COM port of the Windows desktop in the Python script, which is written to send the SMS messages from Raspberry Pi.<\/p>\n<p class=\"ai-optimize-120\"><span style=\"color: #993300;\">import serial<\/span><br \/>\n<span style=\"color: #993300;\">import os, time<\/span><br \/>\n<span style=\"color: #993300;\">#import RPi.GPIO as GPIO<\/span><\/p>\n<p class=\"ai-optimize-121\"><span style=\"color: #993300;\">#GPIO.setmode(GPIO.BOARD)<\/span><br \/>\n<span style=\"color: #993300;\">#port = serial.Serial(&#8220;\/dev\/ttyS0&#8221;, baudrate=9600, timeout=1)<\/span><br \/>\n<span style=\"color: #993300;\">port = serial.Serial(&#8220;COM22&#8221;, baudrate=9600, timeout=1)<\/span><\/p>\n<p class=\"ai-optimize-122\"><span style=\"color: #993300;\">port.write(b&#8217;AT\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-123\"><span style=\"color: #993300;\">port.write(b&#8221;AT+CMGF=1\\r&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;Text Mode Enabled&#8230;&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(3)<\/span><br \/>\n<span style=\"color: #993300;\">port.write(b&#8217;AT+CMGS=&#8221;9166873301&#8243;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">msg = &#8220;test message from SIM900A&#8230;&#8221;<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;sending message&#8230;.&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(3)<\/span><br \/>\n<span style=\"color: #993300;\">port.reset_output_buffer()<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><br \/>\n<span style=\"color: #993300;\">port.write(str.encode(msg+chr(26)))<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(3)<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;message sent&#8230;&#8221;)<\/span><\/p>\n<p class=\"ai-optimize-124\"><strong>The result:<\/strong><\/p>\n<p class=\"ai-optimize-125\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-09.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61679\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-09-285x300.png\" alt=\"\" width=\"655\" height=\"690\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-09-285x300.png 285w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-09-226x238.png 226w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-09.png 681w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/a><\/p>\n<p class=\"ai-optimize-126\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-10.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61680\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-10-144x300.jpg\" alt=\"\" width=\"351\" height=\"731\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-10-144x300.jpg 144w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-10-492x1024.jpg 492w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-10-768x1597.jpg 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-10-739x1536.jpg 739w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-10-985x2048.jpg 985w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-10-114x238.jpg 114w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-10.jpg 1080w\" sizes=\"auto, (max-width: 351px) 100vw, 351px\" \/><\/a><\/p>\n<p><span style=\"color: #0000ff;\"><strong><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-11.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61681\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-11-144x300.jpg\" alt=\"\" width=\"351\" height=\"731\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-11-144x300.jpg 144w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-11-492x1024.jpg 492w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-11-768x1597.jpg 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-11-739x1536.jpg 739w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-11-985x2048.jpg 985w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-11-114x238.jpg 114w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-11.jpg 1080w\" sizes=\"auto, (max-width: 351px) 100vw, 351px\" \/><\/a><\/strong><\/span><br \/>\n<iframe loading=\"lazy\" src=\"https:\/\/drive.google.com\/file\/d\/1aqLtRKwDged6sR_lS_Lui3jT5Vc8uaie\/preview\" width=\"640\" height=\"480\"><\/iframe><\/p>\n<p class=\"ai-optimize-127\"><strong>Receiving the SMS on a desktop computer<br \/>\n<\/strong>It\u2019s also necessary to comment or remove RPi\u2019s specific lines here. Add code to open the serial COM port of the Windows desktop in the Python script, which is written to receive the SMS on Raspberry Pi.<\/p>\n<p class=\"ai-optimize-128\"><span style=\"color: #993300;\">import serial<\/span><br \/>\n<span style=\"color: #993300;\">import os, time<\/span><br \/>\n<span style=\"color: #993300;\">#import RPi.GPIO as GPIO<\/span><\/p>\n<p class=\"ai-optimize-129\"><span style=\"color: #993300;\">#GPIO.setmode(GPIO.BOARD)<\/span><br \/>\n<span style=\"color: #993300;\">#port = serial.Serial(&#8220;\/dev\/ttyS0&#8221;, baudrate=9600, timeout=1)<\/span><br \/>\n<span style=\"color: #993300;\">port = serial.Serial(&#8220;COM22&#8221;, baudrate=9600, timeout=1)<\/span><\/p>\n<p class=\"ai-optimize-130\"><span style=\"color: #993300;\">port.write(b&#8217;AT\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-131\"><span style=\"color: #993300;\">port.write(b&#8221;ATE0\\r&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-132\"><span style=\"color: #993300;\">port.write(b&#8221;AT+CMGF=1\\r&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(10)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><br \/>\n<span style=\"color: #993300;\">print(&#8220;Text Mode Enabled&#8230;&#8221;)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-133\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CPMS=&#8221;SM&#8221;,&#8221;SM&#8221;,&#8221;SM&#8221;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(30)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-134\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CMGR=1\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(100)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-135\"><span style=\"color: #993300;\">port.write(b&#8217;AT+CMGL=&#8221;ALL&#8221;\\r&#8217;)<\/span><br \/>\n<span style=\"color: #993300;\">rcv = port.read(300)<\/span><br \/>\n<span style=\"color: #993300;\">print(rcv)<\/span><br \/>\n<span style=\"color: #993300;\">time.sleep(1)<\/span><\/p>\n<p class=\"ai-optimize-136\"><strong>The result<\/strong>:<\/p>\n<p class=\"ai-optimize-137\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-12-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61685\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-12-1-144x300.jpg\" alt=\"\" width=\"352\" height=\"728\" \/><\/a><\/p>\n<p class=\"ai-optimize-138\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-13-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61686\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-13-1-144x300.jpg\" alt=\"\" width=\"352\" height=\"728\" \/><\/a><\/p>\n<p class=\"ai-optimize-139\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61683\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-14-300x272.png\" alt=\"\" width=\"664\" height=\"601\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-14-300x272.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-14-768x695.png 768w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-14-263x238.png 263w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/22R-14.png 791w\" sizes=\"auto, (max-width: 664px) 100vw, 664px\" \/><\/a><\/p>\n<p class=\"ai-optimize-140\">Note: the received SMS messages are stored in the SIM card, so we are passing commands to read those messages from the SIM card\u2019s memory locations.<\/p>\n<p class=\"ai-optimize-141\">Now you can interface a SIM900 GSM-GPRS modem with Raspberry Pi and any desktop system. This includes making and receiving calls and sending and receiving SMS messages.<\/p>\n<p class=\"ai-optimize-142\"><em>In the <a href=\"https:\/\/www.engineersgarage.com\/microcontroller-projects\/articles-raspberry-pi-neo-6m-gps-module-interfacing\/\" target=\"_blank\" rel=\"noopener noreferrer\">next tutorial<\/a>, we\u2019ll learn how to interface a GPS modem with Raspberry Pi and a desktop computer.<\/em><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous tutorial, we covered the AT commands that are supported by a SIM900 GSM-GPRS modem. We\u2019ve already discussed how to interface a SIM900A GSM-GPRS modem with Raspberry Pi, Arduino, as well as other microcontrollers and desktop computers. Now, it&#8217;s time to use this modem to make and receive calls, and send and receive&hellip;<\/p>\n","protected":false},"author":387,"featured_media":61687,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1853,3993],"tags":[1724],"class_list":{"2":"type-post","10":"entry","11":"has-post-thumbnail"},"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.2 (Yoast SEO v25.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>RPi Python Programming 22: Voice call and SMS using SIM900A<\/title>\n<meta name=\"description\" content=\"In this tutorial, we\u2019ll demonstrate voice call and SMS messaging using a SIM900A with Raspberry Pi (RPi) and a desktop computer.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RPi Python Programming 22: Calls &amp; SMS using a SIM900A GSM-GPRS modem\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we\u2019ll demonstrate voice call and SMS messaging using a SIM900A with Raspberry Pi (RPi) and a desktop computer.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/\" \/>\n<meta property=\"og:site_name\" content=\"Engineers Garage\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/engineersgarage\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nikhil Agnihotri\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@EngineersGarage\" \/>\n<meta name=\"twitter:site\" content=\"@EngineersGarage\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nikhil Agnihotri\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/\"},\"author\":{\"name\":\"Nikhil Agnihotri\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6\"},\"headline\":\"RPi Python Programming 22: Calls &#038; SMS using a SIM900A GSM-GPRS modem\",\"datePublished\":\"2025-06-10T19:28:00+00:00\",\"dateModified\":\"2025-06-11T16:15:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/\"},\"wordCount\":3336,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg\",\"keywords\":[\"raspberrypi\"],\"articleSection\":[\"Featured Contributions\",\"Raspberry pi\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/\",\"url\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/\",\"name\":\"RPi Python Programming 22: Voice call and SMS using SIM900A\",\"isPartOf\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg\",\"datePublished\":\"2025-06-10T19:28:00+00:00\",\"dateModified\":\"2025-06-11T16:15:48+00:00\",\"description\":\"In this tutorial, we\u2019ll demonstrate voice call and SMS messaging using a SIM900A with Raspberry Pi (RPi) and a desktop computer.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#primaryimage\",\"url\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg\",\"contentUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg\",\"width\":800,\"height\":600,\"caption\":\"OLYMPUS DIGITAL CAMERA\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.engineersgarage.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"RPi Python Programming 22: Calls &#038; SMS using a SIM900A GSM-GPRS modem\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.engineersgarage.com\/#website\",\"url\":\"https:\/\/www.engineersgarage.com\/\",\"name\":\"Engineers Garage\",\"description\":\"Electronic Projects, Electrical Engineering Resources, Makers Articles and Product News\",\"publisher\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.engineersgarage.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\",\"name\":\"Engineer's Garage - WTWH Media\",\"url\":\"https:\/\/www.engineersgarage.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png\",\"contentUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png\",\"width\":372,\"height\":52,\"caption\":\"Engineer's Garage - WTWH Media\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/engineersgarage\",\"https:\/\/x.com\/EngineersGarage\",\"https:\/\/www.youtube.com\/channel\/UC0VITh11JSYk-UW7toLebUw\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6\",\"name\":\"Nikhil Agnihotri\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g\",\"caption\":\"Nikhil Agnihotri\"},\"url\":\"https:\/\/www.engineersgarage.com\/author\/nikhil-agnihotri\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"RPi Python Programming 22: Voice call and SMS using SIM900A","description":"In this tutorial, we\u2019ll demonstrate voice call and SMS messaging using a SIM900A with Raspberry Pi (RPi) and a desktop computer.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/","og_locale":"en_US","og_type":"article","og_title":"RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem","og_description":"In this tutorial, we\u2019ll demonstrate voice call and SMS messaging using a SIM900A with Raspberry Pi (RPi) and a desktop computer.","og_url":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/","og_site_name":"Engineers Garage","article_publisher":"https:\/\/www.facebook.com\/engineersgarage","og_image":[{"width":800,"height":600,"url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg","type":"image\/jpeg"}],"author":"Nikhil Agnihotri","twitter_card":"summary_large_image","twitter_creator":"@EngineersGarage","twitter_site":"@EngineersGarage","twitter_misc":{"Written by":"Nikhil Agnihotri","Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#article","isPartOf":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/"},"author":{"name":"Nikhil Agnihotri","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6"},"headline":"RPi Python Programming 22: Calls &#038; SMS using a SIM900A GSM-GPRS modem","datePublished":"2025-06-10T19:28:00+00:00","dateModified":"2025-06-11T16:15:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/"},"wordCount":3336,"commentCount":0,"publisher":{"@id":"https:\/\/www.engineersgarage.com\/#organization"},"image":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#primaryimage"},"thumbnailUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg","keywords":["raspberrypi"],"articleSection":["Featured Contributions","Raspberry pi"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/","url":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/","name":"RPi Python Programming 22: Voice call and SMS using SIM900A","isPartOf":{"@id":"https:\/\/www.engineersgarage.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#primaryimage"},"image":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#primaryimage"},"thumbnailUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg","datePublished":"2025-06-10T19:28:00+00:00","dateModified":"2025-06-11T16:15:48+00:00","description":"In this tutorial, we\u2019ll demonstrate voice call and SMS messaging using a SIM900A with Raspberry Pi (RPi) and a desktop computer.","breadcrumb":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#primaryimage","url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg","contentUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg","width":800,"height":600,"caption":"OLYMPUS DIGITAL CAMERA"},{"@type":"BreadcrumbList","@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-sim900a-gsm-gprs-modem-voice-call-sms\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.engineersgarage.com\/"},{"@type":"ListItem","position":2,"name":"RPi Python Programming 22: Calls &#038; SMS using a SIM900A GSM-GPRS modem"}]},{"@type":"WebSite","@id":"https:\/\/www.engineersgarage.com\/#website","url":"https:\/\/www.engineersgarage.com\/","name":"Engineers Garage","description":"Electronic Projects, Electrical Engineering Resources, Makers Articles and Product News","publisher":{"@id":"https:\/\/www.engineersgarage.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.engineersgarage.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.engineersgarage.com\/#organization","name":"Engineer's Garage - WTWH Media","url":"https:\/\/www.engineersgarage.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png","contentUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png","width":372,"height":52,"caption":"Engineer's Garage - WTWH Media"},"image":{"@id":"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/engineersgarage","https:\/\/x.com\/EngineersGarage","https:\/\/www.youtube.com\/channel\/UC0VITh11JSYk-UW7toLebUw"]},{"@type":"Person","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6","name":"Nikhil Agnihotri","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g","caption":"Nikhil Agnihotri"},"url":"https:\/\/www.engineersgarage.com\/author\/nikhil-agnihotri\/"}]}},"featured_image_src":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg","featured_image_src_square":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-1.jpg","author_info":{"display_name":"Nikhil Agnihotri","author_link":"https:\/\/www.engineersgarage.com\/author\/nikhil-agnihotri\/"},"_links":{"self":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts\/61669","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/users\/387"}],"replies":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/comments?post=61669"}],"version-history":[{"count":0,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts\/61669\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/media\/61687"}],"wp:attachment":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/media?parent=61669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/categories?post=61669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/tags?post=61669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}