Пример #1
0
def shelflifemanagement():
    read()
    cleand = clean()
    newframefinal(cleand)
    createdatabase()
    price(result)
    h = tableshelf()
    return render_template('/ShelfLifeManagement.html', h=h)
Пример #2
0
def ProductDetail():
    print(result)
    print("Reading serial data...")
    read()
    cleand = clean()
    newframefinal(cleand)
    createdatabase()
    z = price(result)
    n = table()
    return render_template('/ProductDetail.html/', z=z, n=n)
Пример #3
0
def main():
    global status
    measurement_number = 0
    sensor_ids = sensor.ids()
    print "IDS: ", sensor_ids

    while True:
        # Refresh Ngrok data and clean up LCD display every 10 measurements
        if measurement_number % 10 == 0:
            display.lcd_init()
            getNgrokTunnel()

        temps = sensor.read()

        if len(temps) != 3:
            display.println(1, "SENSOR ERROR!")
            status = "Sensors avail: %d" % len(temps)
            log("Error: only %d sensors available!" % len(temps))
        else:
            status = "Status: OK :)"

        handleSuccessfulRead(temps)

        sleep(sleep_time)
        measurement_number += 1
Пример #4
0
def task():
    """
    Loop, lees sensoren en update
    """
    global data
    global f
    global hist
    global motor
    geiger=False
    prox=False
    #auto besturen
    motor.speed(speeds.get())
    if bestmodus.get()==1:
        drive()
    else:
        navi.navigate(data, motor)
    #foto nemen
    takePicture()
    #geigerteller uitlezen (moet eerst voor grafiek)
    if sensoren["geiger"].read(data):
        newcpm = data["cpm"]
    else:
        newcpm=False
    if newcpm:
        geiger=True
        hist.append(newcpm)
        hist.pop(0)
        gpxparser.printData(data, f)
    #sensoren uitlezen
    for key, sensor in sensoren.iteritems():
        sensor.read(data)
    #dataveld aanpassen en grafieken herplotten
    changeOutput(prox, geiger)
    #pan/tilt verzetten
    if panpos!=pans.get():
        panpos=pans.get()
        sensoren["proma"].pan(pans.get())
    if tiltpos!=tilts.get():
        tiltpos=tils.get()
        sensoren["proma"].tilt(tilts.get())
    root.after(50, task)  # reschedule event
Пример #5
0
def attractAndScare():
    pygame.mixer.music.load(attractSound)
    pygame.mixer.music.play()
    while pygame.mixer.music.get_busy() == True:
        continue

    pygame.mixer.music.load(punchSound)

    print "Wait for signal"
    for x in range(600):
        result = read()
        time.sleep(0.1)
        if result:
            print "Signal detected"
            scareMe()
            break
        else:
            print "Nobody here"
Пример #6
0
import sensor
import time
from datetime import datetime
from firebase import firebase

firebase_name = 'https://temperature-sensor.firebaseio.com'

def start_writer():
    fb = firebase.FirebaseApplication(firebase_name, None)

    def writer(temperature, humidity):
        nonlocal fb

        try:
            measurement = {"temperature": round(temperature, 2),
                           "humidity": round(humidity, 2),
                           "date": int(time.time() * 1000)}

            result = fb.post('/measurements', measurement)
            print(result)
        except Exception as e:
            print(e)
            print("Trying to reconnect...")
            fb = firebase.FirebaseApplication(firebase_name, None)

    return writer

if __name__ == '__main__':
    sensor.read(start_writer())
Пример #7
0
from firebase import firebase

firebase_name = 'https://temperature-sensor.firebaseio.com'


def start_writer():
    fb = firebase.FirebaseApplication(firebase_name, None)

    def writer(temperature, humidity):
        nonlocal fb

        try:
            measurement = {
                "temperature": round(temperature, 2),
                "humidity": round(humidity, 2),
                "date": int(time.time() * 1000)
            }

            result = fb.post('/measurements', measurement)
            print(result)
        except Exception as e:
            print(e)
            print("Trying to reconnect...")
            fb = firebase.FirebaseApplication(firebase_name, None)

    return writer


if __name__ == '__main__':
    sensor.read(start_writer())
Пример #8
0
import datetime
import sys
import re
import circular_buffer

lcd.init()

last_time = datetime.datetime.now()
last_minute = last_time.minute
probe_minute_01 = circular_buffer.CircularBuffer(size=30)
probe_minute_15 = circular_buffer.CircularBuffer(size=15)
probes_minute_30 = circular_buffer.CircularBuffer(size=30)
probes_minute_60 = circular_buffer.CircularBuffer(size=60)

# initialize buffers
current_temperature = sensor.read()
probe_minute_01.append(current_temperature)
probe_minute_15.append(current_temperature)
probes_minute_30.append(current_temperature)
probes_minute_60.append(current_temperature)

while True:
    try:
        current_time = datetime.datetime.now()
        current_minute = current_time.minute
        current_temperature = sensor.read()

        if current_temperature == 9999:
            lcd.top("Temperature")
            lcd.bottom("Failed to read")
            lcd.cleanup()
Пример #9
0
import config
import ujson
import sensor

def connect_and_subscribe():
    global client_id
    client = MQTTClient(client_id, config.mqtt_server)
    client.connect()
    print('Connected to %s MQTT broker' % (config.mqtt_server))
    return client

def restart_and_reconnect():
    print('Failed to connect to MQTT broker. Reconnecting...')
    time.sleep(10)
    machine.reset()

try:
    client = connect_and_subscribe()
except OSError as e:
    restart_and_reconnect()

while True:
    try:
        time.sleep(config.message_interval)
        temperature, humidity = sensor.read()
        reading = { 'temperature': temperature, 'humidity': humidity, 'name': config.sensor_name }
        client.publish(config.topic_pub, ujson.dumps(reading))
        print('Published', reading, 'to topic')
    except OSError as e:
        restart_and_reconnect()
Пример #10
0
mqttc = mqtt.Client()
# Assign event callbacks
mqttc.on_message = on_message
mqttc.on_connect = on_connect
mqttc.on_publish = on_publish
mqttc.on_subscribe = on_subscribe

# Uncomment to enable debug messages
#mqttc.on_log = on_log

# Connect
mqttc.username_pw_set(passw.user, passw.psw)
mqttc.connect(passw.server, passw.port)
topic = '/cloudmqtt'
# Start subscribe, with QoS level 0
mqttc.subscribe(topic, 0)

# Publish a message
mqttc.publish(topic, boardName + userName + ":led_state:" + str(led_state))
mqttc.publish(topic, boardName + userName + ":sensor_val:" + str(sensor_val))
# Continue the network loop, exit when an error occurs
rc = 0
import time
while rc == 0:
    time.sleep(2)
    sensor_val = sensor.read()
    mqttc.publish(topic,
                  boardName + userName + ":sensor_val:" + str(sensor_val))
    rc = mqttc.loop()
print("rc: " + str(rc))
Пример #11
0
import sensor
import time
import data
import screen
from config import Config

config = Config()

data.Initialise()

while True:
	reading = sensor.read(config)

	print '{0} {1:0.1f}*C, {2:0.1f}%'.format(time.strftime('%Y-%m-%d %H:%M:%S', reading[0]), reading[1], reading[2])

	data.WriteReading(reading[0], reading[1], reading[2])
	
	screen.Write(reading[0], reading[1], reading[2])

	time.sleep(5)
Пример #12
0
import datetime
import sys
import re
import circular_buffer

lcd.init()

last_time = datetime.datetime.now()
last_minute = last_time.minute
probe_minute_01 = circular_buffer.CircularBuffer(size=30)
probe_minute_15 = circular_buffer.CircularBuffer(size=15)
probes_minute_30 = circular_buffer.CircularBuffer(size=30)
probes_minute_60 = circular_buffer.CircularBuffer(size=60)

# initialize buffers
current_temperature = sensor.read()
probe_minute_01.append(current_temperature)
probe_minute_15.append(current_temperature)
probes_minute_30.append(current_temperature)
probes_minute_60.append(current_temperature)

while True:
    try:
        current_time = datetime.datetime.now()
        current_minute = current_time.minute
        current_temperature = sensor.read()

        if current_temperature == 9999:
            lcd.top("Temperature")
            lcd.bottom("Failed to read")
            lcd.cleanup()