from boltiot import Sms, Bolt
import json, time
api_key="21c534ce-376c-4b5d-83e9-d1a5011c5560"
device_id="BOLT291275"
ssid='AC61e3dbbaa0f6f45a2af651ca4c3cd173'
auth_token='6b52b3b8c346c429786d01eab1b02f87'
from_number='+13517775274'
to_number='+918050531606'
minimum_limit = 15
mybolt=Bolt(api_key,device_id)
sms=Sms(ssid,auth_token,to_number,from_number)
print(format("Auto LED Controller",'_^50'))
error='{"success": "0", "message": "A Connection error occurred"}'
offlne='{"value": "offline", "time": null, "success": 1}'
result=mybolt.isOnline()
if result==error:
print("\n Check weather your computer or bolt device is connected to Internet.....")
elif result==offlne:
print("\n Bolt Device is offline....")
else :
while True:
print ("\n Recognizing Value from Senser.......")
response = mybolt.analogRead('A0')
data = json.loads(response)
inten=int(data['value'])
print("value from senser is: " + str(inten))
if inten>minimum_limit:
result=mybolt.digitalWrite('0','HIGH')
print("Someone opened the door")
time.sleep(10)
mybolt.digitalWrite('0','LOW')
time.sleep(10)
else:
result=mybolt.digitalWrite('0','LOW')
print("Locker is closed")
time.sleep(10)
Comments