Пример #1
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)
Пример #2
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)
Пример #3
0
class CarLight:
    def __init__(self):
        # Enter your own generated bolt API Key & Your own Device Id
        self.api_key = "638f9a4d-809a-4e47-ac2a-4436e195b503"
        self.device_id = "BOLT290339"

        # Setting Threshold value
        self.maximum_limit = 170

        ## Connecting to the bolt IoT Module
        self.mybolt = Bolt(self.api_key, self.device_id)
        print(format("Automatic Car light Controller and Adjuster", '_^50'))
        self.error = '{"success": "0", "message": "A Connection error occurred"}'
        self.offline = '{"value": "offline", "time": null, "success": 1}'

    def start(self):
        #  Checking Bolt Device is offline or Online
        result = self.mybolt.isOnline()
        if result == self.error:
            print(
                "\n Check weather your computer or bolt device is connected to Internet....."
            )
        elif result == self.offline:
            print("\n Bolt Device is offline")
        else:
            while True:
                print("\n Collecting Value from Sensor")
                # Collecting Response from the sensor
                response = self.mybolt.analogRead('A0')
                data = json.loads(response)
                if data['value'].isnumeric():
                    intent = int(data['value'])
                    print("value from sensor is: " + str(intent))
                    # Comparing Light Intensity & Threshold Value
                    if intent > self.maximum_limit:
                        # If light Intensity is Higher Than Threshold Value Then Dipper is On.
                        analog_ack = self.mybolt.analogWrite('1', '120')
                        digital_ack = self.mybolt.digitalWrite('0', 'LOW')
                        print("Car's Dipper light is On ")
                    else:
                        # Else Main Headlight is On & Dipper is Off
                        analog_ack = self.mybolt.digitalWrite('0', 'HIGH')
                        digital_ack = self.mybolt.digitalWrite('1', 'LOW')
                        print("Car's main Headlight is On")
                else:
                    print(f"[Error] {data['value']}")
                time.sleep(1)
Пример #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)
Пример #5
0
import email_conf
from boltiot import Email, Bolt
import json
import time

minimum_limit = 300  # the minimum threshold of light value
maximum_limit = 600  # the maximum threshold of light value

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)

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 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']))
    except Exception as e:
        print("Error occured: Below are the details")
        print(e)
    time.sleep(10)
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 ")
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(
            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"
import conf
from boltiot import Bolt
import json, time
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)


def convert(sensor_value):
    led_intensity = 255 - (sensor_value * 255 / 1024)
    return led_intensity


while True:
    print("Reading Sensor Value")
    response_ldr = mybolt.analogRead('A0')
    data = json.loads(response)
    print("Sensor value is: " + str(data['value']))
    try:
        sensor_value = int(data['value'])
        print("Calculating required Light Intensity for LED")
        led_value_float = convert(sensor_value)
        led_value = int(led_value_float)
        print(led_value)
        mybolt.analogWrite('1', led_value)
    except Exception as e:
        print("Error occured: Below are the details")
        print(e)
    time.sleep(5)
Пример #9
0
#Since Receiver should be always ready,hence permanent loop
while 1:
    response = mybolt.digitalRead('3')  #ACK PIN
    data = json.loads(response)

    #Low ACK pin means active transission
    if int(data['value']) == 0:
        print("Found Info!!")
        flag = 1
        #Is kept high because on transmitter part there might be delay mismatch so it waits for data
        while flag:
            time.sleep(10)
            response = mybolt.digitalRead('1')  #Corona Pin
            data = json.loads(response)
            time.sleep(10)
            response = mybolt.analogRead('A0')  #Corona Recovery Pin
            data1 = json.loads(response)
            if int(data['value']) == 1:
                flag = 0
                print("Corona Case!!")
                send_telegram_message("Alert!!Corona Case in your Area")
                response = mybolt.digitalWrite('4', 'LOW')
            elif int(data1['value']) >= 255:
                flag = 0
                print("Corona Recovery Case!!")
                time.sleep(10)
                send_telegram_message("Corona Case Recovered in your Area")
                response = mybolt.digitalWrite('2', 'LOW')

        #flag=0 means data has been received
        if flag == 0:
Пример #10
0
import conf, json, time
from boltiot import Bolt, Email

#Setting up device
device = Bolt(conf.api_key, conf.device_id)

minimum = 71.68
maximum = 153.6

mailer = Email(conf.mailgun_key, conf.sandbox_url, conf.sender_email,
               conf.receiver_email)

while 1:
    print("Reading sensor value")
    response = device.analogRead('A0')
    data = json.loads(response)
    print("Sensor value is: " + str(data['value']))
    try:
        sensor_value = int(data['value'])
        temperature = (100 * sensor_value) / 1024
    except Exception as e:
        print("Error occured: details are")
        print(e)

    if sensor_value > maximum or sensor_value < minimum:
        print("Making request to Mailgun to send an email")
        response = mailer.send_email(
            "Alert", "The Current temperature value is out of desired range" +
            str(temperature))
        print("Response received from Mailgun is:" + response.text)
    time.sleep(10)
Пример #11
0
min_li = 10
max_li = 80


blt = Bolt(config.API_KEY, config.DEVICE_ID)

mailer = Email(config.MAILGUN_API_KEY, config.SANDBOX_URL,
               config.SENDER_EMAIL, config.RECIPIENT_EMAIL)

sms = Sms(config.SSID, config.AUTH_TOKEN,
          config.TO_NUMBER, config.FROM_NUMBER)

history_data = []

while True:
    resp = blt.analogRead('A0')
    data = json.loads(resp)

    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 light intensity is {}'.format(data['value']))
    try:
        val = int(data['value'])
        if val < min_li or val > max_li:
            resp = mailer.send_email(
                "Caution", "The Current Intensity is beyond range, its value is " + str(val))
            print('Value out of range : {}, mail sent'.format(val))
Пример #12
0
        Variance += math.pow((data - Mn), 2)

    Zn = int(factor) * math.sqrt(int(Variance) / int(frame_size))
    High_bound = history_data[int(frame_size) - 1] + Zn
    Low_bound = history_data[int(frame_size) - 1] - Zn
    return [High_bound, Low_bound]


tempo = Bolt(conf.API_KEY, conf.DEVICE_ID)
mailer = Email(conf.MAILGUN_API_KEY, conf.SANDBOX_URL, conf.SENDER_EMAIL,
               conf.RECEIPENT_EMAIL)
history_data = []

while True:
    print("Collecting sensor response")
    response = tempo.analogRead('A0')
    data = json.loads(response)
    print("Sensor value " + str(data['value']))
    try:
        sensor_value = int(data['value'])
        if sensor_value > max_lim or sensor_value < min_lim:
            print("Making request to Mailgun to send email")
            respo = mailer.send_email(
                "ALERT:", "Temperature exceeds from threshold limit")
            response_text = json.loads(respo.text)
            print("Response received from mailgun is: " +
                  str(response_text['message']))
    except Exception as e:
        print("ERROR: Below are the details")
        print(e)
    time.sleep(10)