# Based on the example code on http://razzpisampler.oreilly.com/ch07.html import RPi.GPIO as GPIO import urllib import time GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) def button_pressed(): print('button pressed') data = urllib.urlencode({'text': 'hello!'}) print(data) urllib.urlopen('http://beam.soracom.io:8888/', data) while True: input_state = GPIO.input(18) if input_state == False: button_pressed() time.sleep(0.5)