Alex Glow
Published © GPL3+

SMS Button (with Twilio)

Send a text message with Python, via a Raspberry Pi set up with the Twilio SDK.

BeginnerProtip1 hour1,776
SMS Button (with Twilio)

Things used in this project

Hardware components

Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
Adafruit USB to TTL Serial Cable
Big Red Dome Button
SparkFun Big Red Dome Button
Female/Female Jumper Wires
Female/Female Jumper Wires

Software apps and online services

SMS Messaging API
Twilio SMS Messaging API


Read more


Button connection

This is the same on any Pi with the standard 40-pin connector.


Button-to-SMS Demo

Send a Twilio message when you press a button on your Raspberry Pi!
# Twilio button-to-SMS demo
# Code is a mashup of Twilio Python SMS demo and Inderpreet Singh's button demo
# Smooshed together by Alex Glow; full tutorial:

# Download the helper library from
from import Client
import RPi.GPIO as GPIO
import time

# Use the Broadcom SOC Pin numbers 
# Setup the Pin with Internal pullups enabled and PIN in reading mode. 
GPIO.setup(18, GPIO.IN, pull_up_down = GPIO.PUD_UP)

# Your Account Sid and Auth Token from
account_sid = 'ACXXX'
auth_token = 'YOURTOKEN'
client = Client(account_sid, auth_token)

# Our function on what to do when the button is pressed
def SendMsg(channel): 
   message = client.messages \
         body='PyLadies Rock!',


# Add our function to execute when the button pressed event happens 
GPIO.add_event_detect(18, GPIO.FALLING, callback = SendMsg, bouncetime = 2000)

# Now wait! 
while 1:  


Alex Glow

Alex Glow

98 projects • 978 followers
The Hackster team's resident Hardware Nerd. I like robots, music, EEG, wearables, and languages. FIRST Robotics kid.