#!/usr/bin/python -u
# coding=utf-8
# "DATASHEET": http://cl.ly/ekot
# https://gist.github.com/kadamski/92653913a53baf9dd1a8
from __future__ import print_function
import serial, struct, sys, time, json, subprocess
DEBUG = 0
CMD_MODE = 2
CMD_QUERY_DATA = 4
CMD_DEVICE_ID = 5
CMD_SLEEP = 6
CMD_FIRMWARE = 7
CMD_WORKING_PERIOD = 8
MODE_ACTIVE = 0
MODE_QUERY = 1
PERIOD_CONTINUOUS = 0
JSON_FILE = '/var/www/html/aqi.json'
MQTT_HOST = ''
MQTT_TOPIC = '/weather/particulatematter'
ser = serial.Serial()
ser.port = "/dev/ttyUSB0"
ser.baudrate = 9600
ser.open()
ser.flushInput()
byte, data = 0, ""
def dump(d, prefix=''):
print(prefix + ' '.join(x.encode('hex') for x in d))
def construct_command(cmd, data=[]):
assert len(data) <= 12
data += [0,]*(12-len(data))
checksum = (sum(data)+cmd-2)%256
ret = "\xaa\xb4" + chr(cmd)
ret += ''.join(chr(x) for x in data)
ret += "\xff\xff" + chr(checksum) + "\xab"
if DEBUG:
dump(ret, '> ')
return ret
def process_data(d):
r = struct.unpack('<HHxxBB', d[2:])
pm25 = r[0]/10.0
pm10 = r[1]/10.0
checksum = sum(ord(v) for v in d[2:8])%256
return [pm25, pm10]
#print("PM 2.5: {} μg/m^3 PM 10: {} μg/m^3 CRC={}".format(pm25, pm10, "OK" if (checksum==r[2] and r[3]==0xab) else "NOK"))
def process_version(d):
r = struct.unpack('<BBBHBB', d[3:])
checksum = sum(ord(v) for v in d[2:8])%256
print("Y: {}, M: {}, D: {}, ID: {}, CRC={}".format(r[0], r[1], r[2], hex(r[3]), "OK" if (checksum==r[4] and r[5]==0xab) else "NOK"))
def read_response():
byte = 0
while byte != "\xaa":
byte = ser.read(size=1)
d = ser.read(size=9)
if DEBUG:
dump(d, '< ')
return byte + d
def cmd_set_mode(mode=MODE_QUERY):
ser.write(construct_command(CMD_MODE, [0x1, mode]))
read_response()
def cmd_query_data():
ser.write(construct_command(CMD_QUERY_DATA))
d = read_response()
values = []
if d[1] == "\xc0":
values = process_data(d)
return values
def cmd_set_sleep(sleep):
mode = 0 if sleep else 1
ser.write(construct_command(CMD_SLEEP, [0x1, mode]))
read_response()
def cmd_set_working_period(period):
ser.write(construct_command(CMD_WORKING_PERIOD, [0x1, period]))
read_response()
def cmd_firmware_ver():
ser.write(construct_command(CMD_FIRMWARE))
d = read_response()
process_version(d)
def cmd_set_id(id):
id_h = (id>>8) % 256
id_l = id % 256
ser.write(construct_command(CMD_DEVICE_ID, [0]*10+[id_l, id_h]))
read_response()
def pub_mqtt(jsonrow):
cmd = ['mosquitto_pub', '-h', MQTT_HOST, '-t', MQTT_TOPIC, '-s']
print('Publishing using:', cmd)
with subprocess.Popen(cmd, shell=False, bufsize=0, stdin=subprocess.PIPE).stdin as f:
json.dump(jsonrow, f)
if __name__ == "__main__":
cmd_set_sleep(0)
cmd_firmware_ver()
cmd_set_working_period(PERIOD_CONTINUOUS)
cmd_set_mode(MODE_QUERY);
while True:
cmd_set_sleep(0)
for t in range(15):
values = cmd_query_data();
if values is not None and len(values) == 2:
print("PM2.5: ", values[0], ", PM10: ", values[1])
time.sleep(2)
# open stored data
try:
with open(JSON_FILE) as json_data:
data = json.load(json_data)
except IOError as e:
data = []
# check if length is more than 100 and delete first element
if len(data) > 100:
data.pop(0)
# append new values
jsonrow = {'pm25': values[0], 'pm10': values[1], 'time': time.strftime("%d.%m.%Y %H:%M:%S")}
data.append(jsonrow)
# save it
with open(JSON_FILE, 'w') as outfile:
json.dump(data, outfile)
if MQTT_HOST != '':
pub_mqtt(jsonrow)
print("Going to sleep for 1 min...")
cmd_set_sleep(1)
time.sleep(60)
Annesinin hastalığı ilerledikçe, genç ve zengin olan oğlu ona mükemmel bir bakıcı tutar. Ancak bakıcının bu varlıklı ailenin bir parçası olmaya çalışmasıyla, hayatları ölümcül bir ilişkiye dönüşmeye başlar. Bryon Feliciano
Marion Cotillard, Mathieu Amalric ve Charlotte Gainsbourg gibi isimlerin başrolünde yer aldığı İsmail’in Hayaletleri, yeni senaryosunu bitirmeye çalışan İsmail ile birlikte yaşadığı Sylvia’nın hayatına Carlotta’nın girmesiyle yaşananları konu ediniyor.Yeni filminin hazırlıklarıyla meşgul olan İsmail (Mathieu Amalric), hayatına kısa zaman önce giren Sylvia (Charlotte Gainsbourg) ile şehirden uzakta sakin bir hayat yaşamaktadır. Ancak çok vakit geçmeden sorunlar baş gösterir. Yazılarında tıkanmaya başlayan İsmail, daha sonra 20 yıl öncesinde bıraktığı bir hayaletin çıkagelmesiyle sarsılır. Yıllar önce habersizce çekip giden karısı Carlotta (Marion Cotillard), geri dönmüştür. İsmail iki kadının arasında gelgitler yaşarken, filmi de tamamlamanın yollarını aramaya başlar.Les fantomes d’Ismael izle….Ismael’s Ghosts izle… Oscar Yankee
Yaklaşık 200 yıldır eleştirmenler, Mormon kitabına şahitlik edenlerin meleklerlerin eski antik yazılı altın plakaları kaldırdıklarını görmesini açıklamaya çalışmaktadır. Yarı belgesel yarı film türünde bir yapımdır. Calvin Vernet
Kuzey Kanada’da keşif yapan bir arkeolog ekibi, onbinlerce yıl öncesine ait bir yapı ile karşılaşır. Ancak kısa süre sonra iletişimi sağlayan tüm cihazları bir bir bozulmaya başlar ve ekip kendini yalnızlığın karanlık yüzü ile karşı karşıya bulur… Royal Babitsch
Haksız yere mahkûm edilen ve hapiste olduğu sırada ailesini kaybeden eski bir hükümlü, kana susamış asistanıyla birlikte intikam peşine düşer. Mason Dudzinski
Hdfilmcehennemi – Türkiye’nin en hızlı hd film izleme sitesi. Tek ve gerçek hdfilmcehennemi sitesi. Heath Bouska
gAItcosinKSvkqG
oobyck
where to buy sildenafil usa
Fullhdfilmizle ile Full HD film izle deneyimi sizlerle! Türkçe dublaj ve Altyazı arşivimizle 1080p kalite kesintisiz film izleme sitesinin tadını çıkar! Jon Ruddell
torasemide vs furosemide
wellbutrin and zoloft together
diflucan and flagyl
medication lisinopril
lasix effect on kidneys
glucophage ulotka
zmax zithromax
gabapentin withdrawal
z pack vs amoxicillin
dog gabapentin dose
is escitalopram safe for pregnancy
bactrim cause yeast infection
ciprofloxacin medication
long term side effects of cephalexin
bactrim ds tablet uses
amoxicillin and clavulanate potassium side effects
side effects of gabapentin
escitalopram get you high
highest dose of citalopram
cozaar muscle cramps spasms
avp ddavp
depakote dr
citalopram vs sertraline
cozaar how long does it take to be effective
ddavp vial
depakote ec
rosuvastatina mas ezetimibe
augmentin with food
a client with raynaud’s phenomenon is prescribed diltiazem. an expected outcome is:
diclofenac breastfeeding
coming off effexor weight loss
can you take flomax at night
contrave 2 pills a day
flexeril for menstrual cramps
allopurinol gout
can you stop amitriptyline cold turkey
cats and aspirin
aripiprazole 2mg tablets
is celebrex addictive
bupropion for smoking cessation dosage
can i drink alcohol while taking augmentin
baclofen side effects mayo clinic
celecoxib medicine
buspirone toxicology
how to wean off celexa 10mg
ashwagandha health benefits
actos generika
vraylar vs abilify
acarbose-ct
tirzepatide or semaglutide
what class of drug is remeron
repaglinide glucuronide
what is protonix 40 mg
what class of drug is robaxin
remeron dosage for appetite
synthroid timing
sitagliptin efficacy
Fullhdfilmizlesene ile en yeni vizyon filmler Full HD ve ücretsiz film sizlerle. Orijinal film arşivimizle en kaliteli film izle fırsatı sunuyoruz. Jessie Brodnex
Film izle, jetfilmizle internetin en hızlı ve güvenilir film, sinema izleme platformudur. Binlerce film seçeneğiyle her zevke uygun filmleri Full HD kalitesinde sunar. Hilario Mcginnis
synthroid tmj
spironolactone 50 mg for acne
why take tamsulosin 30 minutes after a meal
voltaren and afib
2 mg tizanidine
venlafaxine hydrochloride
zyprexa velotab
zetia coupon 2016
reglan or zofran for morning sickness
how long does zyprexa take to work
titrating off wellbutrin
can zofran be crushed