Testing SMS Gateways
For one of my projects I’m testing an SMS gateway, and decided it would be fun to build a useful alarm clock out of it. For those of you who know Python, you may find this funny. /dev/ttyUSB0 is my Arduino with a temperature sensor. The gateway credentials and phone numbers below are fictional placeholders.
import serial
import urllib2
def check_temp():
ser = serial.Serial('/dev/ttyUSB0', 9600)
t = ser.readline().strip()
return float(t)
t = check_temp()
if int(t) < 8:
message = "It+is+now+%f+degrees;+time+to+get+moving." % t
f = urllib2.urlopen('http://api.clickatell.com/http/sendmsg?user=EXAMPLE_USER&password=YOUR_PASSWORD_HERE&api_id=EXAMPLE_API_ID&from=+61400000000&to=+61400000000&text=%s' % message)
And in crontab:
45 6 * * * python /opt/scripts/temp_alarm.py