Пример #1
0
def activate():

    prevdata = []
    global highbound
    global lowbound
    global flag

    framesize = 5
    temp_sens = Bolt(conf.apikey, conf.device_id)
    sms = Sms(conf.ssid, conf.auth_token, conf.tonumber, conf.fromnumber)
    while True:

        response = temp_sens.analogRead('A0')
        data = json.loads(response)
        try:
            sensor_value = int(data['value'])
            temp = sensor_value / 10.24
            print(temp)

        except Exception as e:
            print("Error", e)
            continue
        if flag == 1:
            bounds = computebounds.computebounds(prevdata, framesize)
            if not bounds:
                print("Need ", (framesize - len(prevdata)), " more points")
                prevdata.append(temp)
                time.sleep(5)
                continue
        try:
            if flag == 1:
                highbound = bounds[0]
                lowbound = bounds[1]

            print("High Bound = ", highbound, "   Low Bound = ", lowbound)
            #highbound=data['up']
            #lowbound=data['low']
            if temp > highbound:

                try:
                    print("Temperature has gone up to ", temp)
                    response = sms.send_sms("Temperature has increased to " +
                                            str(temp))
                    break
                except Exception as e:
                    print("Error", e)
            elif temp < lowbound:

                try:
                    print("Temperature has gone down to ", temp)
                    response = sms.send_sms("Temperature has decreased to " +
                                            str(temp))
                    break
                except Exception as e:
                    print("Error", e)
        except Exception as e:
            print("Error ", e)
        prevdata.append(temp)
        time.sleep(5)
Пример #2
0
def sendSms(phno, msg):
    #print ('SMS')
    print(type(phno))
    print("_", phno, "_")
    #print (msg)
    sms = Sms(conf.SID, conf.AUTH_TOKEN, phno, conf.FROM_NUMBER)
    try:
        print("SMS REQ")
        response = sms.send_sms(msg)
        print("RESP OF SMS TWIL: " + str(response))
        print("     RESP STATUS: " + str(response.status))
    except Exception as e:
        print("Error", e)
Пример #3
0
    def laser():
        api_key = "b42f36a3-9e5b-440c-8fa4-c57de4e5c4ca"
        device_id = "BOLT3732040"
        mybolt = Bolt(api_key, device_id)
        sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)

        print(json.loads(mybolt.isOnline())['value'])
        while True:
            response = mybolt.analogRead('A0')
            data = json.loads(response)
            print(data['value'])
            try:
                sensor_value = int(data['value'])
                print(sensor_value)
                if sensor_value < 1020:
                    response = sms.send_sms(" an unwanted access")
                    response = mybolt.digitalWrite('0', 'HIGH')
                    sleep(20000)

            except Exception as e:
                print("error", e)
                sleep(10000)
Пример #4
0
minimum_limit = 300
maximum_limit = 600

mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.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'])
        if sensor_value > maximum_limit or sensor_value < minimum_limit:
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms(
                "The Current temperature sensor value is " + str(sensor_value))
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
            print(
                "----------------------------------------------------------------"
            )
            print("Intensity Value: ", sensor_value)

            print("Dear Prince, Your fieled No: 1 humidity is low")
            print("Turning on electric motor No: 01..............")
            response = mybolt.digitalWrite('0', 'HIGH')
            print(response)

            print(
                "Sending SMS alert on your mobile number that elctric motor is turned on "
            )
Пример #5
0
    print("This is the value " + data['value'])
    sensor_value = 0
    try:
        sensor_value = int(data['value'].split(",")[0])
    except e:
        print("There was an error while parsing the response: ", e)
        continue

    bound = compute_bounds(history_data, conf.FRAME_SIZE, conf.MUL_FACTOR)
    if not bound:
        required_data_count = conf.FRAME_SIZE - len(history_data)
        print("Not enough data to compute Z-score. Need ", required_data_count,
              " more data points")
        history_data.append(int(data['value']))
        time.sleep(10)
        continue

    try:
        if sensor_value > bound[0]:
            print("The light level increased suddenly. Sending an SMS.")
            response = sms.send_sms("Someone turned on the lights")
            print("This is the response ", response)
        elif sensor_value < bound[1]:
            print("The light level decreased suddenly. Sending an SMS.")
            response = sms.send_sms("Someone turned off the lights")
            print("This is the response ", response)
        history_data.append(sensor_value)
    except Exception as e:
        print("Error", e)
    time.sleep(10)
Пример #6
0
import conf, json, time
from boltiot import Sms, Bolt

minimum_limit = 300
maximum_limit = 600

mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.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'])
        if sensor_value > maximum_limit or sensor_value < minimum_limit:
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms(
                "The Current temperature sensor value 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(10)

#Temperature=(100*sensor_value)/1024
Пример #7
0
mybolt = Bolt(conf.API_KEY,conf.DEVICE_ID)
sms = Sms(conf.SID,conf.AUTH_TOKEN,conf.TO_NUMBER,conf.FROM_NUMBER)

old_state = 0     
while True:
   print("Reading value from Bolt")
   response = mybolt.digitalRead('1')
   data = json.loads(response)
   print (data)
   new_state = int(data['value'])   
   if old_state != new_state:  
   #Change in state indicates that the garage door is openend or closed
      try:
         if new_state == 1:    #value of new_state is 1 implies that garage door is open
            print("Making request to twilio to send SMS")   #sending an SMS to the TO NUMBER
            response = sms.send_sms("Garage is open")
            print ("Response received from twilio is:"+str(response))
            print ("Status of SMS at Twilio is :"+str(response.status))

         elif new_state == 0:     #value of new_state is 0 implies that garage door is closed
            print("Making request to twilio to send SMS")   #sending an sms to the TO NUMBER
            response = sms.send_sms("Garage is closed")
            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)
   old_state = new_state   #assign new_state value to the old_state for the next cycle
   time.sleep(20)     #wait for 20 seconds
Пример #8
0
    history_data.append(int(data['value']))
    time.sleep(10)
    continue
try:
    if sensor_value > bound[0]:
        buzz = mybolt.digitalWrite('1', "HIGH")
        print(buzz)
        time.sleep(2)
        api_object = get_api_object(config)
        tweet = (
            "Temperature increased suddenly Current Temperature is: " +
            str(sensor_valuec))
        status = api_object.update_status(status=tweet)
        print("Tweeted")
        response = sms.send_sms(
            "Temperature increased suddenly Current Temperature is: " +
            str(sensor_valuec))
        print("Response:", response)
        print(
            "Anomaly of the temperature occured because of increase in temperature."
        )
        buzzoff = mybolt.digitalWrite('1', "LOW")
        print(buzzoff)
    elif sensor_value < bound[1]:
        buzz = mybolt.digitalWrite('1', "HIGH")
        print(buzz)
        time.sleep(2)
        print(
            "Anomaly of the temperature occured because of decrease in temperature."
        )
        buzzoff = mybolt.digitalWrite('1', "LOW")
        time.sleep(10)
        continue

    print ("This is the value "+data['value'])  #To print the Analog Value received form the Bolt WiFi Module

    try:
        moist=(int(data['value'])/1024)*100   #To convert the vales in Percentage
	moist = 100 - moist     #To find the moisture content left in soil out of total 100%
        print ("The Moisture content is ",moist," % mg/L")
    except e:
        print("There was an error while parsing the response: ",e)
        continue
    try:     #To find the moisture content of the land
        if moist < 30:
            print ("The Moisture level is  highly decreased.  SMS is sent.")
            response = sms.send_sms("THE MOISTURE CONTENT  IN LAND IS LESS THAN 30%, SO PLEASE START MOTOR TO IRRIGATE LAND.THE LAND HIGHLY DRY")
            print("This is the response ")
        elif moist < 30 and moist < 50:
            print ("The Moisture level is decreased.  SMS is sent.")
            response = sms.send_sms("THE MOISTURE CONTENT  IN LAND IS LESS THAN 50%, SO PLEASE START MOTOR TO IRRIGATE LAND.")
            print("This is the response ")
        elif moist < 50 and moist < 70:
            print ("The Moisture level moderate.  SMS is sent.")
            response = sms.send_sms("THE MOISTURE CONTENT  IN LAND IS MODERATE, SO AFTER  SOME TIME YOU START MOTOR TO IRRIGATE LAND.")
            print("This is the response ")
        else:
            print("The Moisture level is highly. SMS is sent")
            response = sms.send_sms("DON'T IRRIGATE THE LAND AS IT'S MOISTURE CONTENT IS HIGH")
            print("This is the response")     
    except Exception as e:
        print ("Error occred : Below are details",e)
    bound = compute_bounds(history_data, conf.FRAME_SIZE, conf.MUL_FACTOR)
    if not bound:
        required_data_count = conf.FRAME_SIZE - len(history_data)
        print("Not enough data to compute Z-score. Need ", required_data_count,
              " more data points")
        history_data.append(int(data['value']))
        time.sleep(10)
        continue

    try:
        if sensor_value / 10.24 > maximum_limit:
            print("The Temperature value increased suddenly. Sending an sms.")
            # display the temeprature value in degree celsus
            print("The Current temperature is: " + str(sensor_value / 10.24) +
                  " °C")
            response = sms.send_sms(
                "Alert ! Someone has opened the fridge door")
            response1 = mailer.send_email(
                "Alert !", "The level temperature can destroy the tablets.")
        # condition for the temperature value is between  the critical_limit and the maximum_limit
        elif sensor_value / 10.24 > critical_limit or sensor_value / 10.24 < maximum_limit:
            print(
                "Urgent! Temperature condition can destroy the tablets. Sending an email."
            )
            #display the temperature value in degree celsus
            print(" The Current temperature is:" + str(sensor_value / 10.24) +
                  "°C")
            response = mailer.send_email(
                "Alert !", "The level temperature can destroy the tablets.")
            print("This is the response", response)
        history_data.append(sensor_value)
    except Exception as e:
Пример #11
0

Selling_price = input("Enter Selling Price : ")
mybolt = Bolt(conf.api_key, conf.device_id)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
mailer = Email(conf.MAILGUN_API_KEY, conf.SANDBOX_URL, conf.SENDER_MAIL,
               conf.RECIPIENT_MAIL)

while True:
    c_price = get_bitcoin_price()
    print(get_bitcoin_price(), time.ctime())
    if c_price >= Selling_price:
        # Enable Buzzer
        response_buzzer = mybolt.digitalWrite('0', 'HIGH')
        print(response_buzzer)
        # Send SMS
        response_SMS = sms.send_sms("The Bitcoin selling price is now : " +
                                    str(c_price))
        # Send Mail
        response_mail = mailer.send_email(
            "PRICE ALERT",
            "The Bitcoin selling price is now : " + str(c_price))
        # Send Telegram Alert
        message = 'Alert! Price is now : ' + str(c_price)
        telegram_status = send_telegram_message(message)
        print("This is the Telegram status:", telegram_status)
    else:
        response = mybolt.digitalWrite('0', 'LOW')
        print(response)
    time.sleep(297)
        Temp = round(Temperature, 2)
        print(
            f"  Room Temperature at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} is : {Temp} Degree Celsius"
        )
        engine.say(
            f"  Room Temperature at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} is : {Temp} Degree Celsius"
        )
        engine.runAndWait()
        fb.write(
            f"  Room Temperature at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} is : {Temp} Degree Celsius \n"
        )

        if sensor_value > maximum_limit or sensor_value < minimum_limit:
            response = sms.send_sms(
                f"The Current temperature is {str(Temp)} Degree Celsius at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} "
            )  #mailer.send_email("Alert", "The Current temperature sensor value is " +str(Temp))
            fa.write(
                f" Critical Room Temperature at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} is : {Temp} Degree Celsius \n"
            )
            engine.say(
                "Oops, Critical Alert,  Temperature Crossed the limit , Please Maintain the Temperature "
            )
            engine.runAndWait()
            engine.say(
                "We Are Sending Alert sms to the Registered Mobile number ")
            engine.runAndWait()
    except Exception as e:
        print('Error', e)
    engine.say("Next Alert is coming in 20 seconds")
    engine.runAndWait()
    print("The current Temperature is:", current_price)
    

    if current_price == -999:
        print("Request was unsuccessfull. Skipping.")
        time.sleep(10)
        continue
    

    if current_price <= conf.threshold:
        print("Alert! Current Bitcoin value has decreased ")
        print("Sending Telegram Alert.....")
        message = "Alert! Current Bitcoin value has decreased " + str(conf.threshold) + \
                  ". The current Bitcoin value is " + str(current_price)
        telegram_status = send_telegram_message(message)
        print("This is the Telegram status:", telegram_status)
        
        print(" Sending SMS Alert....")
		response_sms = sms.send_sms(" Alert! Current Bitcoin value has decreased ")
		print("Response From Twilio" +str(response_sms))
		print("SMS Status : " +str(response_sms.status))
		
		print("Sending Email Alert....")
		response_email = mailer.send_email( " Alert", "Current Bitcoin value has decreased ")
		email_response_text = json.loads(response_email.text)
		print("Response received from Mailgun is: " + str(email_response_text['message']))


    time.sleep(30) 

Пример #14
0
 if not bound:
     required_data_count = conf.FRAME_SIZE - len(history_data)
     print("Not enough data to computation. Need ", required_data_count,
           " more data points")
     history_data.append(int(data['value']))
     time.sleep(5)
     continue
 try:
     if sensor_value > bound[0]:
         Temperature = sensor_value * 0.097
         print("bound[0] value is " + str(bound[0]))
         print(
             "The Temparature level has been Incerased suddenly.Sending SMS"
         )
         response = sms.send_sms(
             "Someone Opened the fridge door. The Current temperature is " +
             str(Temperature) + " degree celsious")
         message = "Alert! The Temparature level has been Increased suddenly.The Current temperature is " + str(
             Temperature) + " degree celsious "
         telegram_status = send_telegram_message(message)
         print("This is the response for SMS & Telegram ", response,
               telegram_status)
     elif sensor_value < bound[1]:
         Temperature = sensor_value * 0.097
         print("Anomaly is Occured due to sudden Change in Temperature")
         print("Sending Alert!")
         response = sms.send_sms("The temperature has decreased to : " +
                                 str(Temperature) + "degree celcius")
         message = "Alert! Sensor value has decreased The current value is " + str(
             Temperature)
         telegram_status = send_telegram_message(message)
        return current_price
    except Exception as e:
        print("Error occured: Below are the details")
        print(e)


while True:
    price = get_bitcoin_price()
    print("Bitcoin price in USD and INR is as follows :\n1. USD : " +
          str(price['USD']) + "\n2. INR : " + str(price['INR']) + "\n")
    try:
        if price['INR'] > maximum_limit or price['INR'] < minimum_limit:

            print("Making request to Twilio to send a SMS")
            response = sms.send_sms(
                "Bitcoin price has crossed your set limits.\nCurrent bitcoin price in USD is "
                + str(price['USD']) + " and in INR is " + str(price['INR']))
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))

            print("Making request to Mailgun to send an email")
            response = mailer.send_email(
                "Bitcoin_Price_Alert",
                "Bitcoin price has crossed your set limits.\nCurrent bitcoin price in USD is "
                + str(price['USD']) + " and in INR is " + str(price['INR']))
            response_text = json.loads(response.text)
            print("Response received from Mailgun is: " +
                  str(response_text['message']))

    except Exception as e:
        print("Error occured: Below are the details")
Пример #16
0
      try:
            sensor_value = int(data['value'])
      except e:
            print("There was an error in parsing the response: ", e)
            continue
      
      bound = compute_bounds(history_data, conf.Frame_size, conf.Mul_factor)
      if not bound:
            required_data_count = conf.Frame_size - len(history_data)
            print("Not enough data to compute the Z-Score, Need ", required_data_count," more points")
            history_data.append(int(data['value']))
            time.sleep(20)
            continue
      
      #this portion of the code can be changed as per your use
      
      try:
            if sensor_value > min_limit and sensor_value < max_limit:
                print("Warning!!!")
                print("Making request to Twilio to send SMS")
                response = sms.send_sms("The Current temperature is: "+str(sensor_value)+\
                          ". Someone has openned the door of the refridgerator.")
                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")
            print(e)
            
      time.sleep(20)
Пример #17
0
import conf, time, json
from boltiot import Bolt, Sms
maximum_limit = 200
minimum_limit = 100
mybolt = Bolt(conf.API_KEY,conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
while True:
	response = mybolt.analogRead('A0')
	data = json.loads(response)
	print(data['value'])
	try:
		sensor_value = int(data['value'])
		print(sensor_value)
		if sensor_value > maximum_limit or sensor_value < minimum_limit:
			response = sms.send_sms("Your light sensor value is " +str(sensor_value))
	except Exception as e:
		print("Error",e)
	time.sleep(10)
Пример #18
0
        required_data_count = conf.FRAME_SIZE - len(history_data)
        print("Not enough data to compute Z-score. Need ", required_data_count,
              " more data points")
        history_data.append(int(data['value']))
        time.sleep(10)
        continue

    try:
        if sensor_value > bound[0]:
            buzz = mybolt.digitalWrite('1', "HIGH")
            print(buzz)
            print("Temperature Altered anomously, sending alerts!")
            """ SMS """
            print("The temperature level increased suddenly. Sending an SMS")
            response = sms.send_sms(
                "Someone Opened the Refrigerator, The temperature has raised to:"
                + str(sensor_value))
            print("This is the response ", response)
            """ MAIL """
            print("Making request to Mailgun to send an email")
            response = mailer.send_email(
                "Alert",
                "The Current temperature sensor value is " + str(sensor_value))
            response_text = json.loads(response.text)
            print("Response received from Mailgun is:" +
                  str(response_text['message']))
            print("Temperature in Degree celsius is " + str(degree))

        elif sensor_value < bound[1]:
            buzz = mybolt.digitalWrite('1', "HIGH")
            print(buzz)
Пример #19
0
    bound = compute_bounds(history_data, conf.FRAME_SIZE, conf.MUL_FACTOR)
    if not bound:
        required_data_count = conf.FRAME_SIZE - len(history_data)
        print("Not enough data to compute Z-score. Need ", required_data_count,
              " more data points")
        history_data.append(int(data['value']))
        time.sleep(10)
        continue

    try:
        if sensor_value > bound[0]:
            print(
                "The temperature level increased suddenly. Sending an SMS and Email Alert."
            )
            response = sms.send_sms("The refrigerator has been opened")
            print("This is the response from Twilio ", response)

            print("Making request to Mailgun to send an email")
            response = mailer.send_email(
                "Alert", "The Current temperature sensor value is " +
                str(sensor_value) + " and temperature is " + str(temperature) +
                " degree Celsius.")
            response_text = json.loads(response.text)
            print("Response received from Mailgun is: " +
                  str(response_text['message']))
        elif sensor_value < bound[1]:
            print(
                "The temperature level decreased suddenly. Sending an SMS and Email Alert."
            )
            response = sms.send_sms("The refrigerator has been closed")
    if not bound:
        required_data_count = conf.FRAME_SIZE - len(history_data)
        print("Not enough data to compute Z-score. Need ", required_data_count,
              " more data points")
        history_data.append(int(data['value']))
        time.sleep(5)
        continue

    try:
        if sensor_value > bound[0]:
            sensor_value1 = sensor_value / 10.24
            print(
                "The Temparature level has been INCREASED suddenly.Sending SMS"
            )
            response = sms.send_sms(
                "Someone Opened the fridge door. The Current temperature is " +
                str(sensor_value1) + " degree celsious")
            response1 = mailer.send_email(
                "RED Alert",
                "Someone opened the fridge door. Because The Temparature of your Refrigarator has been INCREASED suddenly. The Current temperature is "
                + str(sensor_value1) + " degree celsious")
            response2 = sms_whatsapp.send_sms(
                "Someone opened the fridge door. Because The Temparature of your Refrigarator has been INCREASED suddenly. The Current temperature sensor value is "
                + str(sensor_value1) + " degree celsious")
            print("This is the response for SMS ", response)
            print("This is the response for EMAIL ", response1)
            print("This is the response for WHATSAPP ", response2)
        history_data.append(sensor_value)
    except Exception as e:
        print("Error", e)
import conf, json, time
from boltiot import Sms, Bolt

min_limit = 300
max_limit = 350

mybolt = Bolt(conf.akey, conf.did)
Sms = Sms(comf.sid, conf.token, conf.tno, conf.fno)

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'])
        if sensor_value > max_limit or sensor_value < min_limit:
            print("Making quest to twilio to send sms")
            response = Sms.send_sms("The current temp value is " +
                                    str(sensor_value))
            print("Response recived 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(10)
Пример #22
0
        continue

    bound = compute_bounds(history_data, conf.FRAME_SIZE, conf.MUL_FACTOR)
    if not bound:
        required_data_count = conf.FRAME_SIZE - len(history_data)
        print("Not enough data to compute Z-score. Need ", required_data_count,
              " more data points")
        history_data.append(int(data['value']))
        time.sleep(10)
        continue

    try:
        if sensor_value > bound[0]:
            print("Someone is at the Door")
            resp = mybolt.digitalWrite('0', 'HIGH')
            print(resp)
            response = sms.send_sms(
                "Someone is Standing on the door. Open the gate")
            print("This is the response ", response)
        elif sensor_value < bound[1]:
            print("Someone is at the Door")
            resp = mybolt.digitalWrite('0', 'HIGH')
            print(resp)
            response = sms.send_sms(
                "Someone is Standing on the door. Open the gate")
            print("This is the response ", response)
        history_data.append(sensor_value)
    except Exception as e:
        print("Error", e)
    time.sleep(10)  #time interval
return
Пример #23
0
import conf, json, time
from boltiot import Sms, Bolt
minimum_limit = 300
maximum_limit = 600
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    print(data['value'])
    try:
        sensor_value = int(data['value'])
        Temperature = (sensor_value * 100) / 1024
        print(Temperature)
        if sensor_value > maximum_limit or sensor_value < minimum_limit:
            response = sms.send_sms("Current temperature value is " +
                                    str(Temperature))
    except Exception as e:
        print("Error ", e)
    time.sleep(10)
Пример #24
0
     print("This is the error:" + data['value'])
     time.sleep(10)
     continue
 try:
     sensor_value = int(data['value'])
 except Exception as e:
     print("There was an error while parsing the response:", e)
     continue
 value = sensor_value / 10.24
 print("THE CURRENT TEMPERATURE:" + str(value))
 try:
     if sensor_value > max or sensor_value < min:
         mybolt.digitalWrite('0', 'HIGH')
         print("TEMPERATURE CROSSED THE LIMIT")
         response1 = sms.send_sms(
             "TEMPERATURE CROSSED THE LIMIT.THE CURRENT TEMPERATURE IS " +
             str(value))
         response2 = mailer.send_email(
             "ALERT!",
             "TEMPERATURE CROSSED THE LIMIT.THE CURRENT TEMPERATURE IS " +
             str(value))
         print(response2)
         print("Status of SMS at Twilio is:" + str(response1.status))
         response_text = json.loads(response2.text)
         print("Response received from Mailgun is:" +
               str(response_text['message']))
         time.sleep(10)
         mybolt.digitalWrite('0', 'LOW')
 except Exception as e:
     print("Error occured:Below are the details")
     print(e)
Пример #25
0
import conf, json, time
from boltiot import Sms, Bolt

minimum_limit = 100
maximum_limit = 100
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    print(data['value'])
    try:
        sensor_value = int(data['value'])
        print(sensor_value)
        if sensor_value > maximum_limit or sensor_value < minimum_limit:
            response = sms.send_sms("The current value of the sensor is" +
                                    str(sensor_value))
    except Exception as e:
        print("Error", e)
    time.sleep(10)
    except Exception as e:
        print("There was an error while parsing the response: ", e)
        continue

    bound = compute_bounds(history_data, email_conf.FRAME_SIZE,
                           email_conf.MUL_FACTOR)
    if not bound:
        required_data_count = email_conf.FRAME_SIZE - len(history_data)
        print("Not enough data to compute Z-score. Need ", required_data_count,
              " more data points")
        history_data.append(int(data['value']))
        time.sleep(10)
        continue

    try:
        if sensor_value > maximum_limit or sensor_value < minimum_limit:
            response = mailer.send_email(
                "Alert", "The Current temperature is beyond the threshold ")
        if sensor_value > bound[0]:
            print("The temperature increased suddenly. Sending Sms.")
            response = sms.send_sms("Someone opened the chamber")
            print("This is the response ", (response))
        elif sensor_value < bound[1]:
            print("The temperature decreased suddenly. Sending an email.")
            response = mailer.send_email("Someone opened the chamber")
            print("This is the response ", response)
        history_data.append(sensor_value)
    except Exception as e:
        print("Error", e)
    time.sleep(10)
import conf, json, time
from boltiot import Sms, Bolt
minimum_limit = 67  #the minimum threshold of heart rate
maximum_limit = 110  #the maximum threshold of heart rate
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    sensor_value1 = int(data['value'])
    sensor_value1 = sensor_value1
    print("The current Heartbeat of patient is " + str(sensor_value1) +
          " BPM. And the Sensor Value is " + data['value'])
    sensor_value = 0
    try:
        sensor_value = int(data['value'])
    except e:
        print("There was an error while parsing the response: ", e)
        continue
    try:
        if sensor_value > maximum_limit or sensor_value < minimum_limit:
            print("The heartbeat is abnormal.Sending SMS")
            response = sms.send_sms(
                "HeartBeat abnormal. The Current heartbeat is " +
                str(sensor_value1) + " BPM")
            print("This is the response for SMS ", response)
    except Exception as e:
        print("Error", e)
    time.sleep(5)
Пример #28
0
        return sensor_value
    except Exception as e:
        print("Error")
        print(e)
        return -999
        
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'])
        if sensor_value < value4:
            mybolt.digitalWrite(0,"LOW")
        elif sensor_value > value2 or sensor_value < value3:
            print("Making request to TWILIO to sens SMS")
            value = (sensor_value/20)
            response = sms.send_sms("The amount of rainfall is: " +str(value))
            print("Response recieved from TWILIO is: " +str(response_status))
            mybolt.digitalWrite(0,"HIGH")
        elif sensor_value > value1 or sensor_value < value2
            print("Making request to TWILIO to send SMS")
            value = (sensor_value/20)
            response = sms.send_sms("The amount of rainfall is: " +str(value))
            print("Response recieved from TWILIO is: " +str(response_status))
            mybolt.digitalWrite(0,"LOW")
    except Exception as e:
        print("Error")
        print(e)
    time.sleep(10)
Пример #29
0
                             "Pomodoro Clock <mailgun@{}>".format(
                                 os.environ['MAILGUN_URL']),
                             "to": [os.environ['RECIPIENT_EMAIL']],
                             "subject":
                             "ALERT",
                             "text":
                             message
                         })


if (os.environ['IS_ACTIVATED'] == '1'):
    message = "STOP! 45 mins is over. Go take a break!!"
    response = send_simple_message(message)
    print("Response EMAIL", response)

    sms = Sms(os.environ['SSID'], os.environ['AUTH_TOKEN'],
              os.environ['TO_NUMBER'], os.environ['FROM_NUMBER'])
    response = sms.send_sms(message)
    print("Response SMS", response)

    time.sleep(900)

    message = "Time's up, now get back to work!"
    response = send_simple_message(message)
    print("Response EMAIL", response)

    sms = Sms(os.environ['SSID'], os.environ['AUTH_TOKEN'],
              os.environ['TO_NUMBER'], os.environ['FROM_NUMBER'])
    response = sms.send_sms(message)
    print("Response SMS", response)
Пример #30
0
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)