Esempio n. 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)
Esempio n. 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)
Esempio n. 3
0
    def laser():
        API_KEY = "d1c0747d-cf58-4b22-b97a-cfae6ba9ae2e"
        DEVIVE_ID = "BOLT7487042"
        Mybolt = Bolt(API_KEY, DEVIVE_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('4', 'HIGH')
                    sleep(0)

                else:
                    response = Mybolt.digitalWrite('4', 'LOW')

            except Exception as e:
                print("error", e)
                sleep(10000)
Esempio n. 4
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)
import config    #this file contains the SSID API Key and Bolt device ID
import json,time   
from boltiot import Sms,Bolt     #used to call methods to sen SMS and use Bolt WiFi Module

     

mybolt = Bolt(config.API_KEY, config.DEVICE_ID)        #To configure the Bolt WiFi Module
sms = Sms(config.SSID, config.AUTH_TOKEN, config.TO_NUMBER, config.FROM_NUMBER)       #To configure the Twilio SMS Service

while True:
    response = mybolt.analogRead('A0')     #Read the values
    data = json.loads(response)     #store the response given recieved in JSON format
    if data['success'] != 1:            # To detect if the value recieved contains keyword success and corresponding value should be 1 denoting STATUS OK
        print("There was an error and error is " + data['value'] )
        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 ")
Esempio n. 6
0
    Variance = 0
    for data in history_data:
        Variance += math.pow((data - Mn), 2)
    Zn = factor * math.sqrt(Variance / frame_size)
    High_bound = history_data[frame_size - 1] + Zn
    Low_bound = history_data[frame_size - 1] - Zn
    return [High_bound, Low_bound]


#sensor value=temperature*10.24
minimum_temp_limit = 4 * 10.24
maximum_temp_limit = 20 * 10.24

#api authentication
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_EMAIL,
               conf.RECIPIENT_EMAIL)

history_data = []
while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)

    print("Sensor value : " + data['value'])
    temperature = float(data['value']) / 10.24
    print("Temperature : " + str(temperature))
    sensor_value = 0
    try:
        sensor_value = int(data['value'])
    except Exception as e:
Esempio n. 7
0
        print("An error occurred in sending the alert message via Telegram")
        print(e)
        return False


def get_bitcoin_price():
    URL = "https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR,INR"  # REPLACE WITH CORRECT URL
    respons = requests.request("GET", URL)
    respons = json.loads(respons.text)
    current_price = respons["USD"]
    return current_price


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(
Esempio n. 8
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)
Esempio n. 9
0
import conf,json,time
from boltiot import Bolt,Sms
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
    Variance = 0
    for data in history_data:
        Variance += math.pow((data - Mn), 2)
    Zn = factor * math.sqrt(Variance / frame_size)
    High_bound = history_data[frame_size - 1] + Zn
    Low_Bound = history_data[frame_size - 1] - Zn
    return [High_bound, Low_Bound]


minimum_limit = 4
maximum_limit = 7

mybolt = Bolt(email_conf.API_KEY, email_conf.DEVICE_ID)
mailer = Email(email_conf.MAILGUN_API_KEY, email_conf.SANDBOX_URL,
               email_conf.SENDER_EMAIL, email_conf.RECIPIENT_EMAIL)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)

history_data = []

while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)

    if data['success'] != '1':
        print("There was an error while retriving the data.")
        print("This is the error:" + data['value'])
        time.sleep(10)
        continue

    print("The sensor value is " + (data['value']))
    sensor_value = 0
Esempio n. 11
0
        return None
    if len(history_data) > frame_size:
        del history_data[0:len(history_data) - frame_size]
    Mn = statistics.mean(history_data)
    Variance = 0
    for data in history_data:
        Variance += math.pow((data - Mn), 2)
    Zn = 0
    Zn = factor * math.sqrt(history_data[frame_size - 1]) + Zn
    Low_bound = history_data[frame_size - 1] - Zn
    High_bound = history_data[frame_size - 1] + Zn
    return [High_bound, Low_bound]


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
history_data = []
while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    if data['success'] != 1:
        print("There was an error while retriving the data.")
        print("This is the error:" + data['value'])
        time.sleep(10)
        continue
    sensor_value = int(data['value'])
    sensor_valuec = sensor_value / 10.24
    print("Current Freezer Temperature is •C  " + str(sensor_valuec))
    sensor_value = 0
    try:
        sensor_value = int(data['value'])
Esempio n. 12
0
        del history_data[0:len(history_data) - frame_size]
        Mn = statistics.mean(history_data)
        variance = 0
        for data in history_data:
            variance += math.pow((data - Mn), 2)
        Zn = factor * math.sqrt(variance / frame_size)
        High_bound = history_data[frame_size - 1] + Zn
        Low_bound = history_data[frame_size - 1] - Zn
        return [High_bound, Low_bound]


history_data = []
min = 20.48
max = 46.08
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
mailer = Email(conf.MAILGUN_API_KEY, conf.SANDBOX_URL, conf.SENDER_EMAIL,
               conf.RECEPIENT_EMAIL)
while True:
    print(
        "==========================================================================================================="
    )
    print("Reading sensor value")
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    if data['success'] != 1:
        print("There was an error while retriving the data.")
        print("This is the error:" + data['value'])
        time.sleep(10)
        continue
    try:
Esempio n. 13
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)
Esempio n. 14
0
        history_data
    )  #it calculates the mean (Mn) value of the collected data points.
    Variance = 0
    for data in history_data:
        Variance += math.pow(
            (data - Mn),
            2)  #This code helps to calculate the Variance of the data points.
    Zn = factor * math.sqrt(Variance / frame_size)
    High_bound = history_data[frame_size - 1] + Zn
    Low_bound = history_data[frame_size - 1] - Zn
    return [High_bound, Low_bound]
    #In the above code we have calculated the Z score (Zn) for the data and use it to calculate the upper and lower threshold bounds required to check if a new data point is normal or anomalous.


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
#Above codes are used to initialize the Bolt and SMS variables, which we will use to collect data and send SMS alerts.
history_data = [
]  #Here we initialize an empty list with the name 'history_data' which we will use to store older data, so that we can calculate the Z-score.

#The following while loop contains the code required to run the algorithm of anomaly detection.
while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    if data['success'] != 1:
        print("There was an error while retriving the data.")
        print("This is the error:" + data['value'])
        time.sleep(10)
        continue
    print("Receiving Data...")
    print("This is the value " + data['value'], "(time :",
        return None

    if len(history_data) > frame_size:
        del history_data[0:len(history_data) - frame_size]
    Mn = statistics.mean(history_data)
    Variance = 0
    for data in history_data:
        Variance += math.pow((data - Mn), 2)
    Zn = factor * math.sqrt(Variance / frame_size)
    High_bound = history_data[frame_size - 1] + Zn
    Low_Bound = history_data[frame_size - 1] - Zn
    return [High_bound, Low_Bound]


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
sms_whatsapp = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_WHATSAPP,
                   conf.FROM_WHATSAPP)
mailer = Email(conf.MAILGUN_API_KEY, conf.SANDBOX_URL, conf.SENDER_EMAIL,
               conf.RECIPIENT_EMAIL)
history_data = []

while True:
    response = mybolt.analogRead('A0')
    response1 = mybolt.analogRead('A0')
    response2 = mybolt.analogRead('A0')
    data = json.loads(response)
    if data['success'] != '1':
        print("There was an error while retriving the data.")
        print("This is the error:" + data['value'])
        time.sleep(5)
Esempio n. 16
0
        return None

    if len(history_data) > frame_size:
        del history_data[0:len(history_data) - frame_size]
    Mn = statistics.mean(history_data)
    Variance = 0
    for data in history_data:
        Variance += math.pow((data - Mn), 2)
    Zn = factor * math.sqrt(Variance / frame_size)
    High_bound = history_data[frame_size - 1] + Zn
    Low_bound = history_data[frame_size - 1] - Zn
    return [High_bound, Low_bound]


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
history_data = []
mailer = Email(conf.MAILGUN_API_KEY, conf.SANDBOX_URL, conf.SENDER_EMAIL,
               conf.RECIPIENT_EMAIL)

while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    if data['success'] != 1:
        print("There was an error while retriving the data.")
        print("This is the error:" + data['value'])
        time.sleep(10)
        continue

    print("Raw Temperature in Refrigerator is" + data['value'])
    degree = (float(data['value']) / 10.24)
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)
Esempio n. 18
0
import conf, requests, math, time, json
from boltiot import Sms, bolt

value1 = 20
value2 = 500
value3 = 1500
value4 = 500

data = []             #to empty the list for storing value
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
mybolt.digitalWrite(0,"LOW")

def get_sv(pin):
    try:
        response = mybolt.analogRead(pin)
        data = json.loads(response)
        if data["success']!=1:
            print("Request Failed")
            print("Response", data)
            return -999
        sensor_value = int(data["value"])
        return sensor_value
    except Exception as e:
        print("Error")
        print(e)
        return -999
        
while True:
    print("Reading Sensor Value")
    response = mybolt.analogRead('A0')
import conf, json, time
from boltiot import Bolt, Sms

API_KEY = "b42f36a3-9e5b-440c-8fa4-c57de4e5c4ca"
DEVIVE_ID = "BOLT3732040"
Mybolt = Bolt(API_KEY, DEVIVE_ID)
SSID = 'ACce54c48ff0e1271d7d50012d96ec89a3'
AUTH_TOKEN = 'edaf33cf519a6efe6c8991f8bd397047'
FROM_NUMBER = '+15083926124 '
TO_NUMBER = '+918077423699'

sms = Sms(SSID, AUTH_TOKEN, TO_NUMBER, 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('4', 'HIGH')
            break

    except Exception as e:
        print("error", e)
        time.sleep(10000)
Esempio n. 20
0
import math, json, time, conf, statistics
from boltiot import Bolt, Sms

min_limit = 10
max_limit = 100

mybolt = Bolt(conf.API_KEY, conf.device_id)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)

def compute_bounds( history_data, frame_size, factor):
      if len(history_data) < frame_size:
            return None
      if len(history_data) > frame_size:
            del history_data[0:len(history_data) - frame_size]
            
      Mean_value = statistics.mean(history_data)
      Variance = 0
      for data in history_data:
            Variance += math.pow((data - Mean_value), 2)
            
      Zn = factor * math.sqrt(Variance/frame_size)
      High_bound = history_data[frame_size-1] + Zn
      Low_bound = history_data[frame_size-1] - Zn
      return [High_bound, Low_bound]
      
history_data = []

while True:
      print("Reading sensor value: ")
      response = mybolt.analogRead('A0')
      data = json.loads(response)
Esempio n. 21
0
import conf, json, time
from boltiot import Bolt, Sms

minimum_limit = 100
maximum_limit = 1000

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 the LDR sensor value")
    response = myBolt.analogRead('A0')
    data = json.loads(response)
    sensor_value = int(data['value'])
    print("LDR sensor value is :" + str(data['value']))
    try:
        print("try block")
    except Exception as e:
        print("Exception")
Esempio n. 22
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
Esempio n. 23
0
import dest, json, time
from boltiot import Sms, Bolt
import json, time

minimum_limit = 300
maximum_limit = 600

mybolt = Bolt(
    dest.api_key,
    dest.device_id)  #dest is the file which contains apikey,device id ets.
sms = Sms(dest.SID, dest.auth_token, dest.to_number, dest.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)
Esempio n. 24
0
        return None

    if len(history_data) > frame_size:
        del history_data[0:len(history_data) - frame_size]
    Mn = statistics.mean(history_data)
    Variance = 0
    for data in history_data:
        Variance += math.pow((data - Mn), 2)
    Zn = factor * math.sqrt(Variance / frame_size)
    High_bound = history_data[frame_size - 1] + Zn
    Low_bound = history_data[frame_size - 1] - Zn
    return [High_bound, Low_bound]


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
history_data = []

while True:
    mybolt.serialWrite("GetAnalogData")
    response = mybolt.serialRead(10)
    data = json.loads(response)
    if data['success'] != 1:
        print("There was an error while retriving the data.")
        print("This is the error:" + data['value'])
        time.sleep(10)
        continue

    print("This is the value " + data['value'])
    sensor_value = 0
    try:
Esempio n. 25
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)
engine = pyttsx3.init()
f = Figlet(font='slant', width=200)
print(f.renderText('Hello , Welcome To Temperature Monitoring System'))
engine.setProperty('rate', 160)
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
engine.say("Hello, Everyone, Welcome To Temperature Monitoring System")
engine.runAndWait()
engine.say('Please Wait for a while, We are fetching our data')
engine.runAndWait()
time.sleep(2)

minimum_limit = 400  #39.06 Degree Celsius
maximum_limit = 600  #58.59 Degree Celsius
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)

while True:
    fb = open("TempData1.txt", "a")
    fa = open("DangerTemp1.txt", "a")
    resp = mybolt.analogRead('A0')
    data = json.loads(resp)
    try:
        sensor_value = int(data['value'])
        Temperature = (100 * sensor_value) / 1024

        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(
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)
    if len(history_data) > frame_size:
        del history_data[0:len(history_data) - frame_size]
    Mn = statistics.mean(history_data)
    Variance = 0
    for data in history_data:
        Variance += math.pow((data - Mn), 2)
    Zn = factor * math.sqrt(Variance / frame_size)
    High_bound = history_data[frame_size - 1] + Zn
    Low_bound = history_data[frame_size - 1] - Zn
    return [High_bound, Low_bound]


critical_limit = 20  #the critical_value of temperature
maximum_limit = 35  #the maximum_value of temperature
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
mailer = Email(email_conf.MAILGUN_API_KEY, email_conf.SANDBOXURL,
               email_conf.SENDER_EMAIL, email_conf.RECIPIENT_EMAIL)
history_data = []

while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    if data['success'] != 1:
        print("There was an error while retriving the data.")
        print("This is the error:" + data['value'])
        time.sleep(10)
        continue

    print("This is the value " + data['value'])
    sensor_value = 0
Esempio n. 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)
import time, json, math
from boltiot import Bolt, Sms

API_KEY = "b42f36a3-9e5b-440c-8fa4-c57de4e5c4ca"
DEVIVE_ID = "BOLT3732040"  # SELF NOTE need to change
SSID = 'ACce54c48ff0e1271d7d50012d96ec89a3'
AUTH_TOKEN = 'edaf33cf519a6efe6c8991f8bd397047'
FROM_NUMBER = '+15083926124 '
TO_NUMBER = '+918077423699'
Diameter = 14

Mybolt = Bolt(API_KEY, DEVIVE_ID)
twillioMessage = Sms(SSID, AUTH_TOKEN, TO_NUMBER, FROM_NUMBER)

status = Mybolt.isOnline()
print(status)
previousWaterLevel = 0
totalWaterConsumed = 0
criticalConsumption = 15  # Try 1
errorMaxValue = 350


def messageToUser(level='CRITICAL LEVEL'):
    twillioMessage.send_sms("ALERT!!!!!!! \nDear User, " + str(level) +
                            " is crossed. Control excess water usages.")
    print('msg sent')


while True:
    if status: