-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyth.py
25 lines (21 loc) · 852 Bytes
/
pyth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import conf
from boltiot import Sms, Bolt
import json, time
TO_NUMBER = input("Enter number to be sent to:")
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, TO_NUMBER, conf.FROM_NUMBER)
while True:
print ("Reading sensor value")
response = mybolt.analogRead('A0')
data = json.loads(response)
print("Sensor value is: " + str(data['value']))
try:
sensor_value = int(data['value'])
print("Making request to Twilio to send a SMS")
response = sms.send_sms("Your BPM is " +str(sensor_value))
print("Response received from Twilio is: " + str(response))
print("Status of SMS at Twilio is :" + str(response.status))
except Exception as e:
print ("Error occured: Below are the details")
print (e)
time.sleep(50)