def getSensorData(): presion = Sensor("1", "presion", bmp085.BMP085().get_pressure(), True) temp = Sensor("2", "temperatura", ds18b20_therm.DS18B20().read_temp(), True) air = Sensor("3", "calidadAire", tgs2600.TGS2600(adc_channel=0).get_value(), True) humidity = Sensor("4", "humedad", HTU21D.HTU21D().read_temperature(), True) metano = Sensor("5", "metano", getMetano(), True) noise = Sensor("6", "ruido", getNoise(), True) air2 = Sensor("7", "calidadAire2", getAirQ(), True) sensors = [presion, temp, air, humidity, metano, noise, air2] requestPost(getState(sensors))
def getSensorData(): presion = Sensor("1","presion",bmp085.BMP085().get_pressure(),"true") requestPost(presion); temp = Sensor("2","temperatura", ds18b20_therm.DS18B20().read_temp(),"true") requestPost(temp) air = Sensor("3","calidadAire",tgs2600.TGS2600(adc_channel = 0).get_value(),"true") requestPost(air) humidity = Sensor("4","humedad",HTU21D.HTU21D().read_temperature(),"true") requestPost(humidity) metano = Sensor("5", "metano",getMetano(),"true") requestPost(metano) noise = Sensor("6","ruido",getNoise(),"true") requestPost(noise) air2 = Sensor("7","calidadAire2", getAirQ(),"true") requestPost(air2)
#!/usr/bin/python3 import time import sys from ISStreamer.Streamer import Streamer import interrupt_client, MCP342X, wind_direction, HTU21D, bmp085, tgs2600, ds18b20_therm import database # requires MySQLdb python 2 library which is not ported to python 3 yet pressure = bmp085.BMP085() temp_probe = ds18b20_therm.DS18B20() air_qual = tgs2600.TGS2600(adc_channel=0) humidity = HTU21D.HTU21D() wind_dir = wind_direction.wind_direction(adc_channel=0, config_file="wind_direction.json") interrupts = interrupt_client.interrupt_client(port=49501) db = database.weather_database() #Local MySQL db wind_average = wind_dir.get_value(10) #ten seconds ambient_temp = humidity.read_temperature() ground_temp = temp_probe.read_temp() air_quality = air_qual.get_value() pressure = pressure.get_pressure() humidity = humidity.read_humidity() wind_speed = interrupts.get_wind() wind_gust = interrupts.get_wind_gust() rainfall = interrupts.get_rain() print("Inserting...") #db.insert(humidity.read_temperature(), temp_probe.read_temp(), air_qual.get_value(), pressure.get_pressure(), humidity.read_humidity(), wind_average, interrupts.get_wind(), interrupts.get_wind_gust(), interrupts.get_rain()) db.insert(ambient_temp, ground_temp, air_quality, pressure, humidity,
EN_SCD30 = False try: temp_probe = ds18b20_therm.DS18B20() except Exception: EN_DS18B20 = False if debug: print("BMP180 : ", EN_BMP180, "\nSI1145 : ", EN_SI1145, "\nSCD30 : ", EN_SCD30, "\nDB18b20 : ", EN_DS18B20, "\n") # TODO : test if sensor connected before handling it if EN_SCD30: scd30 = SCD30() scd30.set_measurement_interval(5) scd30.start_periodic_measurement() if EN_BMP180: BMP180 = bmp085.BMP085() if EN_DS18B20: temp_probe = ds18b20_therm.DS18B20() if EN_SI1145: uv_sensor = si1145.SI1145() # Append the data in the sqlite-database, including a timestamp try: if EN_SI1145: uv_index = float(uv_sensor.readUVIndex()) / 100 ambient_light = uv_sensor.readAmbientLight() IR_light = uv_sensor.readIRLight() if EN_DS18B20: temp_DS18B20 = temp_probe.read_temp() if EN_BMP180: temp_BMP180 = BMP180.get_temperature()
import bmp085 as bmp sensor = bmp.BMP085() print( sensor.get_pressure())