コード例 #1
0
    def __init__(self, app, window):
        self._app = app
        self._window = window
        self._labelDate = QCustomLabel('initializing')
        self._labelTimes = []
        self._labelForecastTimes = []
        self._labelForecastWeathers = []
        self._labelForecastTemps = []
        self._labelForecastRains = []
        self._labelTemperature = QCustomLabel('  ')
        self._labelHumidity = QCustomLabel('  ')
        self._labelPressure = QCustomLabel('   ')
        self._labelUpload = QCustomLabel(' ')
        self._labelDownload = QCustomLabel(' ')
        self._labelPing = QCustomLabel(' ')

        self._labelForecastTimesUnit = QCustomLabel('時')
        self._labelForecastWeathersUnit = QCustomLabel('天気')
        self._labelForecastTempsUnit = QCustomLabel('℃')
        self._labelForecastRainsUnit = QCustomLabel('mm')
        self._labelTemperatureUnit = QCustomLabel('℃')
        self._labelHumidityUnit = QCustomLabel('%')
        self._labelPressureUnit = QCustomLabel('hPa')
        self._labelUploadUnit = QCustomLabel('Mbps')
        self._labelDownloadUnit = QCustomLabel('Mbps')
        self._labelPingUnit = QCustomLabel('ms')

        self._1SecCount = 1
        self._10SecCount = 1
        self._60SecCount = 1
        self._halfHourCount1 = 0
        self._fullMode = False
        self._bme = object

        self._valDateTime = 0
        self._valTemperature = 0
        self._valHumidity = 0
        self._valPressure = 0
        self._valUpload = 0
        self._valDownload = 0
        self._valPing = 0
        self._valCpuUsage = 0
        self._valCpuTemp = 0

        if USE_BME == True:
            self._bme = bme280()

        self.setNightMode()
        self.__initializeDisplayItems()
        self.__initializeDisplayItemsScale()
        self.__initializeDisplayLayout(layout)
コード例 #2
0
from acc import bmx055  #

pi = pigpio.pi()

#ポート番号の定義
Sw_pin = 23  #変数"Sw_pin"に23を格納

pi.set_mode(Sw_pin, pigpio.INPUT)
pi.set_pull_up_down(Sw_pin, pigpio.PUD_DOWN)

x_on = 0

BME280_ADDR = 0x76
I2C_CH = 1

sensor = bme280.bme280(pi, I2C_CH, BME280_ADDR)
sensor.setup()

############### ここからGPS受信部分です ######################
gps = micropyGPS.MicropyGPS(9, 'dd')
# 出力のフォーマットは度数とする
gps.coord_format = 'dd'


def run_gps():
    """
    GPSモジュールを読み、GPSオブジェクトを更新する
    :return: None
    """
    # GPSモジュールを読み込む設定
    #    s = serial.Serial('/dev/serial0', 115200, timeout=10)
コード例 #3
0
ファイル: example.py プロジェクト: Jeremie-C/python-bme280
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import bme280

if __name__ == '__main__':
    bme = bme280.bme280()
    # Read Data
    bme.get_data()
    tc = bme.get_temperature()
    tf = bme.get_temp_f()
    pp = bme.get_pressure()
    ph = bme.get_press_mmhg()
    h = bme.get_humidity()
    dc = bme.get_dewpoint()
    df = bme.get_dewpoint_f()
    am = bme.get_altitude()
    af = bme.get_altitude_ft()
    sp = bme.get_pasealevel()
    sh = bme.get_pasealevel_mmhg()
    chipid = bme.get_chip_id()

    print "Temperature: %f C" % tc
    print "Temperature: %f F" % tf
    print "Pressure: %f hPa" % (pp / 100)
    print "Pressure: %f mmHg" % ph
    print "Humidity: %f %%" % h
    print "Dewpoint: %f C" % dc
    print "Dewpoint: %f F" % df
    print "Altitude: %f m" % am
    print "Altitude: %f ft" % af
コード例 #4
0
from microbit import display as d, Image, sleep
import os, utime as t, bme280 as b280
from micropython import const
bme = b280.bme280()
alt = bme.altitude
s = 0
td = 0
launch = False
data = None
n = len(os.listdir())
d.show(Image.HAPPY)
sleep(1000)
alt()
sleep(1000)
duration = const(120000)
bme.set_qnh(bme.pressure())
lh = alt()
while True:
    h = alt()
    if not launch and h > lh:
        data = open("alt{}.csv".format(n - 2), "w")
        s = t.ticks_ms()
        launch = True
    if launch:
        d.show(Image.TRIANGLE)
        td = t.ticks_diff(t.ticks_ms(), s)
        data.write("{},{}\n".format(td, h))
        if td > duration:
            d.show(Image.YES)
            data.close()
            break
コード例 #5
0
ファイル: air_sensor.py プロジェクト: atsushik/air_quality
import json
import mhz19b
import bme280

if __name__ == '__main__':
    air_quality = {}

    mhz19b = mhz19b.mhz19b()
    data = mhz19b.read_co2()
    for key in data.keys():
        air_quality[key] = data[key]
    # print json.dumps(air_quality)

    bme280 = bme280.bme280()
    data = bme280.readData()
    for key in data.keys():
        air_quality[key] = data[key]

    if "temperature" in air_quality.keys() and "humidity" in air_quality.keys(
    ):
        t = air_quality["temperature"]["value"]
        H = air_quality["humidity"]["value"]
        discomfort_index = 0.81 * t + 0.01 * H * (0.99 * t - 14.3) + 46.3
        air_quality["discomfort_index"] = {
            "value": discomfort_index,
            "unit": None
        }

    print json.dumps(air_quality)
コード例 #6
0
from microbit import display as d, Image, sleep, pin2
from os import listdir
from utime import ticks_ms, ticks_diff
import bme280

st = 0
f = None
b = bme280.bme280()
state = 0


def setup():
    d.show(Image.HAPPY)
    b.set_qnh(b.pressure())
    return 1


def ready():
    return 2


def launch():
    global f, st
    n = len(listdir())
    f = open("alt{}.csv".format(n - 2), "w")
    st = ticks_ms()
    d.show(Image.TRIANGLE)
    return 3


def fly():
コード例 #7
0
import bme280
import wiringpi as pi
import statistics
import time

bme280_addr = 0x76

pi.wiringPiSetupGpio()
i2c = pi.I2C()
weather = bme280.bme280(i2c, bme280_addr, 1013)
weather.setup()

s_press_sample = []
for i in range(0, 100):
    s_press_sample.append(weather.get_press_value())

s_press = statistics.median(s_press_sample)

weather = bme280.bme280(i2c, bme280_addr, s_press)
weather.setup()

while True:
    alt = []
    for i in range(0, 3):
        alt.append(weather.altitude_cal())
    alt_median = statistics.median(alt)
    print(alt_median)
    print("[m]\n")
    time.sleep(1)
コード例 #8
0
from bme280 import bme280
from microbit import display, Image, running_time

bme = bme280()
p0 = bme.pressure()
bme.set_qnh(p0)
display.show(Image.YES)

while True:
    if not running_time() % 100:
        print((bme.altitude(), ))
        print('\n')
コード例 #9
0
def main(saveData,now,scriptWD):

    bme = bme280.bme280()
    (temperature,pressure,humidity) = bme.readBME280All()
    print("Temperature : ", temperature, "C")
    print("Pressure : ", pressure, "hPa")
    print("Humidity : ", humidity, "%")
    del bme

    ds = ds18b20.ds18b20()
    temp_c = ds.readDS18b20All()
    for n in range(len(temp_c)):
        print("Senor # : ", n)
        print("Sensor ID : ", temp_c[n][1])
        print("Sensor name :", temp_c[n][2])
        print("Temperature : ", temp_c[n][3], "C")
        if temp_c[n][2] == 'Water bucket':
            tempInBucket = temp_c[n][3]
    del ds

    jsn = jsn_sr0t4_2.jsnsr0t4(tempInBucket)
    (currentDepth, currentH20Content) = jsn.readJSNSR0T4()
    print('current water level : ', currentDepth, ' cm')
    print('current water content : ', currentH20Content, ' l')
    del jsn

    time.sleep(1.) # wait a second for the read LED to switch off
    import tsl2591 # has to be imported here, otherwise jsn_sr0t4 script gives error
    tsl = tsl2591.tsl2591()
    (lux,infrared,visible,full_spectrum) = tsl.readTSL2591All()
    print("Total light : ", lux, "lux")
    print("Infrared light : ", infrared)
    print("Visible light : ", visible)
    print("Full spectrum (IR + visible) light : ", full_spectrum)
    del tsl

    minutes = int(now.strftime("%M"))
    rainfallScraped = False
    if (minutes > 19) and (minutes < 29): # scrape rainfall only once per hour at 20 min
        fullHour = now.strftime("%Hh00")
        rf = scrapeRainfall.scrapeRainfall(fullHour)
        (pluie, hour) = rf.getRainfallData()
        print("Measurement hour :", hour)
        print("Rainfall in mm   :", pluie)

        waterChange = rf.getDifferenceInWaterButtContent(now)
        print("Water in butt changed by : %s l between %02dh and %02dh" % (waterChange[0],waterChange[1],waterChange[2]))
        rainfallScraped = True


    if saveData:
        dFile = open("%s/data/terraceWeather_%s.data" % (scriptWD, now.strftime("%Y-%m")), "a")
        dFile.write("%s %s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (now.strftime("%Y-%m-%d"), now.strftime("%H:%M:%S"), temperature,np.round(pressure, 2),np.round(humidity, 2),temp_c[0][3],temp_c[1][3],np.round(currentDepth, 3), np.round(currentH20Content, 3),np.round(lux,4),infrared,visible,full_spectrum))
        dFile.close()
        print('data saved to file')

        # send data to initial state
        streamer = Streamer(bucket_name=ITA.BUCKET_NAME, bucket_key=ITA.BUCKET_KEY, access_key=ITA.ACCESS_KEY)
        #print(np.round(humidity, 2),np.round(pressure, 2),temperature,temp_c[0][3],temp_c[1][3],np.round(currentH20Content, 3),np.round(lux,4))
        streamer.log(SENSOR_LOCATION_NAME + " Humidity (%)", np.float(np.round(humidity, 2)))
        streamer.log(SENSOR_LOCATION_NAME + " Pressure (hPa)", np.round(pressure, 2))
        streamer.log(SENSOR_LOCATION_NAME + " Chip Temperature (C)", temperature)
        streamer.log(SENSOR_LOCATION_NAME + " Water Bucket Temperature (C)", temp_c[0][3])
        streamer.log(SENSOR_LOCATION_NAME + " Outside Temperature (C)", temp_c[1][3])
        streamer.log(SENSOR_LOCATION_NAME + " Water Content (l)", np.round(currentH20Content, 3))
        streamer.log(SENSOR_LOCATION_NAME + " Luminosity (lux)", np.round(lux,4))
        if rainfallScraped:
            if pluie is not None:
                streamer.log(SENSOR_LOCATION_NAME + " Rainfall (mm)", pluie)
            streamer.log(SENSOR_LOCATION_NAME + " Water Change (l)", np.round(waterChange[0],4))

            dFile = open("%s/data/rainfallWaterChange_%s.data" % (scriptWD,now.strftime("%Y-%m")),"a")
            dFile.write("%s %s\t%s\t%s\n" % (now.strftime("%Y-%m-%d"),now.strftime("%H:00"),pluie,np.round(waterChange[0],4)))
            dFile.close()
            print('rainfall and water change data saved to file')

        streamer.flush()
        print('Upload code finished')
コード例 #10
0
import wiringpi as pi
import time
import bme280

bme280_addr = 0x76

pi.wiringPiSetupGpio()
i2c = pi.I2C()
weather = bme280.bme280(i2c, bme280_addr)
weather.setup()

while True:
    (temp, humi, press) = weather.get_value()

    print("Temperature:", temp, "C Humidity:", humi, "% Pressure:", press,
          "hPa")
    time.sleep(1)
コード例 #11
0
ファイル: sequence.py プロジェクト: SaharaCan/monochrome
today_date = datetime.date.today()  #ログのセットアップ
filename = 'log' + today_date + '.csv'
f = open(filename, "w")
header = [
    'TIME', 'ACCELERATION', 'ALTITUDE', 'LATITUDE', 'LONGITUDE', 'DISTANCE'
]
writer = csv.writer(f, lineterminator="\n")
writer.writerow(header)

location = gps.gps(BAUD_RATE, TIMEOUT, DISTANCE_LAT, DISTANCE_LNG)  #GPSのセットアップ

pi.wiringPiSetupGpio()  #GPIOピンのセットアップ

i2c = pi.I2C()  #BME280とMPU6050のセットアップ
acc = mpu6050.mpu6050(i2c, mpu6050_addr)
press = bme280.bme280(i2c, bmp280_addr, s_press)
acc.setup()
press.setup()

pi.pinMode(MOTOR_R_1PIN, pi.OUTPUT)  #駆動部のセットアップ
pi.pinMode(MOTOR_R_2PIN, pi.OUTPUT)
pi.pinMode(MOTOR_L_1PIN, pi.OUTPUT)
pi.pinMode(MOTOR_L_2PIN, pi.OUTPUT)
pi.softPwmCreate(MOTOR_R_1PIN, 0, 100)
pi.softPwmCreate(MOTOR_R_2PIN, 0, 100)
pi.softPwmCreate(MOTOR_L_1PIN, 0, 100)
pi.softPwmCreate(MOTOR_L_2PIN, 0, 100)
pi.softPwmWrite(MOTOR_R_1PIN, 0)
pi.softPwmWrite(MOTOR_R_2PIN, 0)
pi.softPwmWrite(MOTOR_L_1PIN, 0)
pi.softPwmWrite(MOTOR_L_2PIN, 0)