コード例 #1
0
def should_turn_off_fridge():
    """Checks if fridge temp is below target temp"""
    temp_data = read_temp()[1]
    # logging.info('Current temp is: {}, target temp is: {}'.format(temp_data, target_temp))
    print('{} Current temp is: {}, target temp is: {}'.format(
        datetime.now().strftime("%Y-%m-%d %H:%M:%S"), temp_data, target_temp))
    return temp_data < target_temp
コード例 #2
0
ファイル: CombinationCode.py プロジェクト: efinkg/Group3
def tooHot():
    global tmin
    global tmax
    while 1:
        temp = thermometer.read_temp()
        if (temp > tmin):
            print str(tmin)
            print "Temp is too high"
            if (temp < tmax):
                button.buzzerOff()
                global buzzed
                buzzed = 0
                print "Needs moar air"
                dc = int(85 - (50 * (temp - tmin)))
                if (dc <= 0):
                    dc = 0.1
            else:
                print "Needs all of the air"
                button.buzzerOn(buzzed)
                global buzzed
                buzzed = 1
                dc = 0.1
            motor.motorSpeed(dc)
        else:
            motor.motorSpeed(100)
            button.buzzerOff()
コード例 #3
0
def get_state():
    response = jsonify({
        'mode': boiler_switch.get_state(),
        'temperature_c': read_temp()
    })

    return response
コード例 #4
0
async def monitor_temp():
    await client.wait_until_ready()
    global alert
    while not client.is_closed:
        temp = thermometer.read_temp()
        if (low_temp >= temp or temp >= high_temp) and not alert:
            alert = True
        await asyncio.sleep(600)
コード例 #5
0
def the_state_of_the_heating_system():
    global boil
    date_and_time.read_time()
    if GPIO.input(7) == 0:
        print("Čerpadlo je zapnuto.")
    else:
        print("Čerpadlo je vypnuto.")
    if boil == 0:
        print("Bojler je uzavřen.")
    else:
        print("Bojler je otevřen.")

    t6 = thermometer.read_temp(6)
    t14 = thermometer.read_temp(14)

    print("Teplota vody v bojleru je %s °C." % t6)
    print("Teplota kolektoru je %s °C" % t14)
    print(
        "***************************************************************************"
    )
コード例 #6
0
def log():
    """Log the current temperature"""

    current_temp = thermometer.read_temp()

    now = '{0:%a-%d-%b-%H:%M}'.format(datetime.datetime.now())

    print(f"Current datetime is: {now}")

    print(f"Current temp is: {current_temp}")

    data.append_data(now, current_temp)
コード例 #7
0
 def on_message(self, message):
     print("Message Received")
     while True:
         temp = read_temp()
         self.temps.append(temp)
         n_temp = len(self.temps)
         if n_temp > 12:
             self.temps = self.temps[1:]
         payload = {"temp": self.temps}
         message = json.dumps(payload)
         self.write_message(message)
         print(temp)
         time.sleep(5)  #難病に一回データを取るか
コード例 #8
0
ファイル: CombinationCode.py プロジェクト: efinkg/Group3
def setup():
    GPIO.setwarnings(False)
    temp = thermometer.read_temp()
    global temp_room
    temp_room = temp
    global tmin
    tmin = temp_room + 0.25
    global tmax
    tmax = tmin + 0.85
    #motor.motorSpeed(100)
    #motor.stopMotor()
    print "Tmin is " + str(tmin)
    print "Tmax  is " + str(tmax)
コード例 #9
0
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('!hi'):
        await client.send_message(message.channel, 'Hello!')

    if message.content.startswith('!temp'):
        temp = thermometer.read_temp()
        await client.send_message(message.channel,
                                  'Temperature - {}°F'.format(temp))

    if message.content.startswith('!alert'):
        global alert
        await client.send_message(message.channel, '{}'.format(alert))
コード例 #10
0
def set_state():

    body = request.get_json(force=True)
    print body

    if (body['mode'] == 'heat'):
        boiler_switch.turn_on()
    elif (body['mode'] == 'off'):
        boiler_switch.turn_off()
    else:
        abort(400)

    response = jsonify({
        'mode': boiler_switch.get_state(),
        'temperature_c': read_temp()
    })

    return response
コード例 #11
0
def check():
    """Check if the current temperature of the fridge is within certain bounds. If not, it sends alert emails"""
    current_temp = thermometer.read_temp()

    if current_temp >= MAX_TEMP:
        print("Fridge temperature too high")
        subject = "FRIDGE ALERT"
        text = f"The fridge temperature has risen above safe levels, the current temperature is {current_temp}°C."

        for recipient in RECIPIENTS:
            try:
                mail.send_email(sender_email=SENDER_EMAIL,
                                password=SENDER_PASSWORD,
                                receiver_email=recipient,
                                subject=subject,
                                body=text)
                print(f"Sent alert email to: {recipient}")
            except Exception as e:
                print(f"Had error:\n{e}\nwhen sending an email.")
                continue
            print("\n\n")
        print("Sent alert emails")

    elif current_temp <= MIN_TEMP:
        print("Fridge temperature too low")
        subject = "FRIDGE ALERT"
        text = f"The fridge temperature has fallen below safe levels, the current temperature is {current_temp}°C."

        for recipient in RECIPIENTS:
            try:
                mail.send_email(sender_email=SENDER_EMAIL,
                                password=SENDER_PASSWORD,
                                receiver_email=recipient,
                                subject=subject,
                                body=text)
                print(f"Sent alert email to: {recipient}")
            except Exception as e:
                print(f"Had error:\n{e}\nwhen sending an email.")
                continue
            print("\n\n")
        print("Sent alert emails")
    else:
        print("Fridge temperature is within safe levels.")
コード例 #12
0
async def alarm():
    await client.wait_until_ready()
    global alert
    prev_temp = 0
    channel = discord.Object(id=channel_id)
    while alert and not client.is_closed:
        temp = thermometer.read_temp()
        if temp >= high_temp and temp > prev_temp:
            prev_temp = temp
            await client.send_message(channel,
                                      bot_utils.open_message(weeby_id, temp))
        if temp <= low_temp and temp < prev_temp:
            prev_temp = temp
            await client.send_message(channel,
                                      bot_utils.close_message(weeby_id, temp))
        if temp < high_temp and temp > low_temp:
            await client.send_message(channel, bot_utils.normal_temp())
            alert = False
        if alert:
            await asyncio.sleep(900)
コード例 #13
0
def dashboard_p():
    try:
        curs, conn = connection()
        if request.method == "POST":
            for i in range(1, 60):
                bpm = bpm
                temp = read_temp()
                dt = datetime.datetime.now().strftime(dateString)
                curs.execute(
                    "INSERT into {}(DateTime, Temperature, PulseRate) VALUES (%s,%s,%s)"
                    .format(session['username']), (dt, temp, bpm))
                conn.commit()
                time.sleep(1)
        curs.execute("SELECT DateTime,Temperature,PulseRate from %s" %
                     (session['username']))
        data = curs.fetchall()
        curs.close()
        conn.close()
        gc.collect()
        return render_template("dashboard_p.html", data=data)

    except Exception as e:
        return (str(e))
コード例 #14
0
import thermometer
import time

stop = 0
j = 0

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

GPIO.output(24, True)

j = 0
k = 0

while True:
    t1 = thermometer.read_temp(1)  #atmos
    t7 = thermometer.read_temp(7)  #boil
    t11 = thermometer.read_temp(11)  #storage tank
    t15 = thermometer.read_temp(15)  #temperature in boil room

    if ((t7 >= 40) and (j == 0)):
        siren.signal()
        j = j + 1
    elif ((t7 < 40) and (j == 1)):
        j = j - 1
    elif t15 >= 50:
        while True:
            siren.SOS()
    elif ((t1 >= 75) and (t7 < 50) and (k == 0)):
        pump_boil.open()
        servo_boil.open(20)
コード例 #15
0
def test():
    """Gets the current temperature. Acts as the default behaviour"""
    current_temp = thermometer.read_temp()
    print(f"The current temperature reading is {current_temp}°C")
コード例 #16
0
def temperature():
    the_state_of_the_heating_system()
    t1 = thermometer.read_temp(1)
    t2 = thermometer.read_temp(2)
    t3 = thermometer.read_temp(3)
    t4 = thermometer.read_temp(4)
    t5 = thermometer.read_temp(5)
    t6 = thermometer.read_temp(6)
    t7 = thermometer.read_temp(7)
    t8 = thermometer.read_temp(8)
    t9 = thermometer.read_temp(9)
    t10 = thermometer.read_temp(10)
    t11 = thermometer.read_temp(11)
    t12 = thermometer.read_temp(12)
    t13 = thermometer.read_temp(13)
    #t14 = thermometer.read_temp(14)
    t15 = thermometer.read_temp(15)
    print("Teplota kotle je %s °C." % t1)
    print("PŘED trojcestným ventilem je %s °C." % t2)
    print("ZA trojcestným ventilem je %s °C?" % t3)
    print("POD trojcestným ventilem je %s °C." % t4)
    print("Zpátečka z domu má %s °C." % t5)
    print("Vstup do bojleru má %s °C." % t6)
    print("Teplota vody v bojleru je %s °C." % t7)
    print("Zpátečka z bojleru má %s °C." % t8)
    print("Vstup do akumulačních nádrží má %s °C." % t9)
    print("Zpátečka do akumulačních nádrží má %s °C?" % t10)
    print("Akumulační nádrž nahoře má %s °C." % t11)
    print("Akumulační nádrž téměř dole má %s °C." % t12)
    print("Zpátečka z akumulačních nádrží má %s °C." % t13)
    #print ("Teplota kolektoru je %s °C." %t14)
    print("Teplota u stropu je %s °C." % t15)
    print(
        "***************************************************************************"
    )
コード例 #17
0
    if boil == 0:
        print("Bojler je uzavřen.")
    else:
        print("Bojler je otevřen.")

    t6 = thermometer.read_temp(6)
    t14 = thermometer.read_temp(14)

    print("Teplota vody v bojleru je %s °C." % t6)
    print("Teplota kolektoru je %s °C" % t14)
    print(
        "***************************************************************************"
    )


t6 = thermometer.read_temp(6)
t14 = thermometer.read_temp(14)
while True:
    if (t14 >= (t6 + 5)):
        pump_boil.open()
        boil = servo_boil.open(100)
        pump_boil.on()
        the_state_of_the_heating_system()
        while (t14 >= (t6 + 5)):
            time.sleep(200)
            t6 = thermometer.read_temp(6)
            t14 = thermometer.read_temp(14)
    else:
        pump_boil.close()
        boil = servo_boil.open(0)
        pump_boil.off()