top of page

Sending SMS with Raspberry Pi: A Step-by-Step Guide

Introduction: The Raspberry Pi's versatility extends beyond traditional computing tasks, making it a fantastic platform for various DIY projects. In this guide, we'll explore how you can harness the power of your Raspberry Pi to send SMS messages. Whether you want to receive notifications, create a home automation system, or explore the world of IoT, sending SMS from your Raspberry Pi opens up a realm of possibilities.


Before you begin, ensure you have the following:

  • Raspberry Pi (any model with internet connectivity)

  • GSM/GPRS module (e.g., SIM800L)

  • SIM card with an active SMS plan

  • Jumper wires

  • Breadboard (optional)

  • Power supply for Raspberry Pi and GSM module

Step 1: Connect the GSM Module:

  1. Connect the GSM module to your Raspberry Pi using jumper wires. Refer to the datasheet for your specific module for pin connections.

Step 2: Install Required Software:

  1. Open a terminal on your Raspberry Pi.

  2. Install the required software by running:

sudo apt update
sudo apt install minicom

Step 3: Configure Minicom:

  1. Run the following command to configure minicom:

sudo minicom -s
  1. Navigate to "Serial port setup" and set the serial device to the port where your GSM module is connected (e.g., /dev/ttyS0 or /dev/ttyUSB0).

  2. Save the configuration and exit.

Step 4: Test the GSM Module:

  1. Open a minicom terminal by running:

sudo minicom

  1. Send AT commands to test the GSM module. For example:


You should receive an "OK" response.

Step 5: Write a Python Script:

  1. Create a new Python script (e.g., using a text editor like Nano or Thonny:

import serial import time def send_sms(message, phone_number): ser = serial.Serial('/dev/ttyS0', 9600, timeout=1) ser.write('AT\r\n'.encode()) time.sleep(1) ser.write('AT+CMGF=1\r\n'.encode()) time.sleep(1) ser.write(f'AT+CMGS="{phone_number}"\r\n'.encode()) time.sleep(1) ser.write(f'{message}\r\n'.encode()) time.sleep(1) ser.write(chr(26).encode()) ser.close() # Example usage: send_sms("Hello from Raspberry Pi!", "+1234567890") Replace /dev/ttyS0 with your GSM module's serial port, and update the phone number with the recipient's.

Step 6: Run the Python Script:

  1. Save the Python script.

  2. Run the script using:



Congratulations! You've successfully set up your Raspberry Pi to send SMS messages. This opens up numerous possibilities for notifications, remote monitoring, and creative projects. Experiment with different GSM modules and functionalities to enhance your Raspberry Pi-powered communication system. Happy tinkering!

452 views0 comments

Recent Posts

See All

Getting Started with Raspberry Pi: A Beginner's Guide

Introduction: Raspberry Pi is a versatile and affordable single-board computer that has gained immense popularity among tech enthusiasts, hobbyists, and educators. Whether you're interested in learnin


bottom of page