Ejemplo n.º 1
0
def _do_click_V1001_TEMPERATURE(server, fromUser, toUser, doc):
    import dht11
    c, g = _cpu_and_gpu_temp()
    h, t = dht11.read(0)
    reply_msg = u'CPU : %.02f℃\nGPU : %.02f℃\n湿度 : %02.02f\n温度 : %02.02f' % (
        c, g, h, t)
    return server._reply_text(fromUser, toUser, reply_msg)
Ejemplo n.º 2
0
def ouput_val(pin):
    pin_hash = str(pin)
    try:
        (humidity, temperature) = dht11.read(pin)
        measurements_buffer[pin_hash] = (humidity, temperature)
    except:
        if pin_hash in measurements_buffer:
            (humidity, temperature) = measurements_buffer[pin_hash]
        else:
            (humidity, temperature) = (-1, -1)
            return

    print '--------PIN {}----------'.format(pin)
    print 'Humidity: {}%'.format(humidity)
    print 'Temperature: {}°C'.format(temperature)
    print '------------------------'
    data = {'id': pin, 'temperature': temperature, 'humidity': humidity}
    headers = {
        'Content-type': 'application/json',
        'Accept': 'application/json'
    }
    requests.put('http://localhost:9092/api/sensors/dht/{}/'.format(pin),
                 data=json.dumps(data),
                 headers=headers,
                 auth=('andrea', 'andrea'))
Ejemplo n.º 3
0
def update_screen():
    date = datetime.datetime.now()
    print("Last valid input: " + str(date))

    # 전체 화면을 clear 함.
    d.rectangle(0,
                0,
                w,
                h,
                color="light blue",
                outline=True,
                outline_color="white")

    m = w / 10
    x = m
    y = h / 2 - 20
    text = "%d월 %d일" % (date.month, date.day)
    d.text(x, y, text, color="white", font="Helvetica 24 bold", size=36)

    y = y + 60
    text = "%02d분 %02d초" % (date.minute, date.second)
    d.text(x, y, text, color="white", font="Helvetica 24 bold", size=50)

    x = w * 3 / 5
    d.line(x, h / 10, x, h * 9 / 10, color="white", width=4)

    # 온도 습도 데이터 읽기
    result = dht11.read()

    global temperature
    global humidity

    if result.is_valid():
        temperature = result.temperature
        humidity = result.humidity
        print("Temperature: %d C" % temperature)
        print("Humidity: %d %%" % humidity)
    else:
        print("WARN: dht11 data is invalid!")
    pass

    if temperature > -1000:
        text = "%s" % temperature
    else:
        text = "__"
    pass

    x = w * 3 / 5 + 100
    y = h / 2 - 10
    d.text(x, y, text, color="white", font="Helvetica 24 bold", size=50)

    x = w * 3 / 5 + 200
    d.text(x, y, "°C", color="white", font="Helvetica 24 bold", size=20)

    # 1000 mili sec 후에 시간을 업데이트 한다.
    d.after(1000, update_screen)
Ejemplo n.º 4
0
def ouput_val(pin):
    pin_hash = str(pin)
    try:
        (humidity, temperature) = dht11.read(pin)
        measurements_buffer[pin_hash] = (humidity, temperature)
    except:
        if pin_hash in measurements_buffer:
            (humidity, temperature) = measurements_buffer[pin_hash]
        else:
            (humidity, temperature) = (-1, -1)
            return

    print '--------PIN {}----------'.format(pin)
    print 'Humidity: {}%'.format(humidity)
    print 'Temperature: {}°C'.format(temperature)
    print '------------------------'
    data = {'id':pin, 'temperature': temperature, 'humidity': humidity}
    headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
    requests.put('http://localhost:9092/api/sensors/dht/{}/'.format(pin),
        data=json.dumps(data), headers=headers, auth=('andrea', 'andrea'))
Ejemplo n.º 5
0
import RPi.GPIO as GPIO
import dht11
import time
import datetime
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.cleanup()
dht11 = dht11.DHT11(pin=4)
while True:
    result = dht11.read()
    if result.is_valid():
        print("Last valid input: " + str(datetime.datetime.now()))
        print("Temperature: %d C" % result.temperature)
        print("Humidity: %d %%" % result.humidity)
    time.sleep(1)
Ejemplo n.º 6
0
def _do_click_V1001_TEMPERATURE(server, fromUser, toUser, doc):
    import dht11
    c, g = _cpu_and_gpu_temp()
    h, t = dht11.read(0)
    reply_msg = u'CPU : %.02f℃\nGPU : %.02f℃\n湿度 : %02.02f\n温度 : %02.02f' %(c, g, h, t)
    return server._reply_text(fromUser, toUser, reply_msg)
from microbit import *
import Obloq
import dht11
import speech
#DH11接在pin16

IP="192.168.43.184"
PORT="8080"
SSID="jf"
PASSWORD="******"

uart.init(baudrate=115200, bits=8, parity=None, stop=1, tx=pin2, rx=pin1)

while Obloq.connectWifi(SSID,PASSWORD,10000) != True:
  display.show(".")

display.scroll(Obloq.ifconfig())
Obloq.httpSet(IP,PORT) 

while True:
  temp,hum=dht11.read(16)
  errno,resp=Obloq.get("input?id=1&val="+str(temp),10000) 
  if errno == 200:
    display.scroll(resp)
    if resp="0":
      speech.say("Be careful,Be careful")
      display.scroll("SOS")
  else:
    display.scroll(str(errno))
  sleep(1000*5)
Ejemplo n.º 8
0
# temp_monitor.py

import wiringpi as pi
import time
import sys
import dht11
import requests
import ambient

pi.wiringPiSetupGpio()
dht11 = dht11.DHT11(pin=4)
am = ambient.Ambient(****, ‘'**********’) 

try:
    while True:
        r = dht11.read()
        if r.is_valid():
            r = am.send({"d1": r.temperature, "d2": r.humidity})
        time.sleep(10)
except KeyboardInterrupt:
    sys.exit(0)