add tsl, veml and mcp sensors
parent
9359546bb4
commit
54abb9d6cb
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import numpy as np
|
||||
import os, serial,time,socket,sys,json,logging,requests,getopt
|
||||
from meas_data import meas_data
|
||||
# import the server implementation
|
||||
# import ADC
|
||||
#import vedirect
|
||||
#import upload_osm
|
||||
|
||||
configfile="config.json"
|
||||
cf=open(configfile,"r")
|
||||
log_conf=json.load(cf)
|
||||
cf.close()
|
||||
|
||||
parameter={"device":socket.gethostname(),"mean_count":5,"ring_length":10,"wait":0.5,"sigma":2}
|
||||
for n in parameter:
|
||||
if n in log_conf:
|
||||
parameter[n]=log_conf[n]
|
||||
|
||||
bmcp9808=False
|
||||
if "mcp9808" in log_conf:
|
||||
bmcp9808=True
|
||||
if "enable" in log_conf['mcp9808']:
|
||||
if log_conf['mcp9808']['enable'] == 0:
|
||||
bmcp9808=False
|
||||
if bmcp9808:
|
||||
import Adafruit_MCP9808.MCP9808 as MCP9808
|
||||
try:
|
||||
sens_9808 = MCP9808.MCP9808()
|
||||
except:
|
||||
bmcp9808 = False
|
||||
else:
|
||||
sens_9808.begin()
|
||||
mcp_sigma=parameter['sigma']
|
||||
if "sigma" in log_conf['mcp9808']:
|
||||
mcp_sigma=int(log_conf['mcp9808']['sigma'])
|
||||
if mcp_sigma < 1:
|
||||
mcp_sigma=1
|
||||
mcp_data=meas_data(var_name="temperature",ring_length=parameter['ring_length'],device=parameter['device'],sensor="MCP9808",i2c=0,store_file="/home/pi/log/data_temperature",sigma=mcp_sigma)
|
||||
if "sqlserver" in log_conf:
|
||||
hostname="banana"
|
||||
if "host" in log_conf['sqlserver']:
|
||||
hostname=log_conf['sqlserver']['host']
|
||||
port=24048
|
||||
if "port" in log_conf['sqlserver']:
|
||||
port=int(log_conf['sqlserver']['port'])
|
||||
mcp_data.set_sql(host=hostname,port=port)
|
||||
if "opensensemap" in log_conf['mcp9808']:
|
||||
osm=log_conf['mcp9808']['opensensemap']
|
||||
if "sensebox_id" in osm:
|
||||
sid=osm['sensebox_id']
|
||||
if "sensors" in osm:
|
||||
if "temperature" in osm['sensors']:
|
||||
mcp_data.set_sensebox(sid,osm['sensors']['temperature'])
|
||||
|
||||
|
||||
if bmcp9808:
|
||||
while True:
|
||||
|
||||
# read bme280 (temperature, humidity, pressure)
|
||||
mcp_data.append(int(1000*sens_9808.readTempC()))
|
||||
time.sleep(parameter['wait'])
|
||||
|
||||
|
||||
# close the client
|
||||
print("done")
|
||||
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import numpy as np
|
||||
import os, serial,time,socket,sys,json,logging,requests,getopt
|
||||
from meas_data import meas_data
|
||||
# import the server implementation
|
||||
# import ADC
|
||||
#import vedirect
|
||||
#import upload_osm
|
||||
|
||||
configfile="config.json"
|
||||
cf=open(configfile,"r")
|
||||
log_conf=json.load(cf)
|
||||
cf.close()
|
||||
|
||||
parameter={"device":socket.gethostname(),"mean_count":5,"ring_length":10,"wait":0.5,"sigma":2}
|
||||
for n in parameter:
|
||||
if n in log_conf:
|
||||
parameter[n]=log_conf[n]
|
||||
|
||||
btls=False
|
||||
if "tsl2591" in log_conf:
|
||||
btls=True
|
||||
if "enable" in log_conf['tsl2591']:
|
||||
if log_conf['tsl2591']['enable'] == 0:
|
||||
btls=False
|
||||
if btls:
|
||||
import tsl2591
|
||||
tsl_port=1
|
||||
if "port" in log_conf['tsl2591']:
|
||||
tsl_port=int(log_conf['tsl2591']['port'])
|
||||
tsl_add=0x29
|
||||
if "address" in log_conf['tsl2591']:
|
||||
tsl_add=int(log_conf['tsl2591']['address'],16)
|
||||
try:
|
||||
tsl = tsl2591.Tsl2591(i2c_bus=tsl_port,sensor_address=tsl_add) # initialize
|
||||
except:
|
||||
btls=False
|
||||
else:
|
||||
tsl_sigma=parameter['sigma']
|
||||
if "sigma" in log_conf['tsl2591']:
|
||||
tsl_sigma=int(log_conf['tsl2591']['sigma'])
|
||||
if tsl_sigma < 1:
|
||||
tsl_sigma=1
|
||||
tsl_data=meas_data(var_name="lux",ring_length=parameter['ring_length'],device=parameter['device'],sensor="TSL2591",i2c=tsl_add,store_file="/home/pi/log/data_lux",sigma=tsl_sigma)
|
||||
if "sqlserver" in log_conf:
|
||||
hostname="banana"
|
||||
if "host" in log_conf['sqlserver']:
|
||||
hostname=log_conf['sqlserver']['host']
|
||||
port=24048
|
||||
if "port" in log_conf['sqlserver']:
|
||||
port=int(log_conf['sqlserver']['port'])
|
||||
tsl_data.set_sql(host=hostname,port=port)
|
||||
if "opensensemap" in log_conf['tsl2591']:
|
||||
osm=log_conf['tsl2591']['opensensemap']
|
||||
if "sensebox_id" in osm:
|
||||
sid=osm['sensebox_id']
|
||||
if "sensors" in osm:
|
||||
if "lux" in osm['sensors']:
|
||||
tsl_data.set_sensebox(sid,osm['sensors']['lux'])
|
||||
|
||||
|
||||
if btls:
|
||||
while True:
|
||||
|
||||
# read bme280 (temperature, humidity, pressure)
|
||||
tsl_full,tsl_ir=tsl.get_full_luminosity()
|
||||
tsl_data.append(int(1000*tsl.calculate_lux(tsl_full,tsl_ir)))
|
||||
time.sleep(parameter['wait'])
|
||||
|
||||
|
||||
# close the client
|
||||
print("done")
|
||||
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import numpy as np
|
||||
import os, serial,time,socket,sys,json,logging,requests,getopt
|
||||
from meas_data import meas_data
|
||||
# import the server implementation
|
||||
# import ADC
|
||||
#import vedirect
|
||||
#import upload_osm
|
||||
|
||||
configfile="config.json"
|
||||
cf=open(configfile,"r")
|
||||
log_conf=json.load(cf)
|
||||
cf.close()
|
||||
|
||||
parameter={"device":socket.gethostname(),"mean_count":5,"ring_length":10,"wait":0.5,"sigma":2}
|
||||
for n in parameter:
|
||||
if n in log_conf:
|
||||
parameter[n]=log_conf[n]
|
||||
|
||||
bveml=False
|
||||
if "veml6070" in log_conf:
|
||||
bveml=True
|
||||
if "enable" in log_conf['veml6070']:
|
||||
if log_conf['veml6070']['enable'] == 0:
|
||||
bveml=False
|
||||
if bveml:
|
||||
import veml6070
|
||||
veml_port=1
|
||||
if "port" in log_conf['veml6070']:
|
||||
veml_port=int(log_conf['veml6070']['port'])
|
||||
try:
|
||||
veml = veml6070.Veml6070(i2c_bus=veml_port)
|
||||
except:
|
||||
bveml=False
|
||||
else:
|
||||
tsl_sigma=parameter['sigma']
|
||||
if "sigma" in log_conf['veml6070']:
|
||||
tsl_sigma=int(log_conf['veml6070']['sigma'])
|
||||
if tsl_sigma < 1:
|
||||
tsl_sigma=1
|
||||
tsl_data=meas_data(var_name="uv",ring_length=parameter['ring_length'],device=parameter['device'],sensor="VEML6070",i2c=veml_port,store_file="/home/pi/log/data_uv",sigma=tsl_sigma)
|
||||
if "sqlserver" in log_conf:
|
||||
hostname="banana"
|
||||
if "host" in log_conf['sqlserver']:
|
||||
hostname=log_conf['sqlserver']['host']
|
||||
port=24048
|
||||
if "port" in log_conf['sqlserver']:
|
||||
port=int(log_conf['sqlserver']['port'])
|
||||
tsl_data.set_sql(host=hostname,port=port)
|
||||
if "opensensemap" in log_conf['tsl2591']:
|
||||
osm=log_conf['veml6070']['opensensemap']
|
||||
if "sensebox_id" in osm:
|
||||
sid=osm['sensebox_id']
|
||||
if "sensors" in osm:
|
||||
if "uv" in osm['sensors']:
|
||||
tsl_data.set_sensebox(sid,osm['sensors']['uv'])
|
||||
|
||||
|
||||
if bveml:
|
||||
while True:
|
||||
|
||||
# read bme280 (temperature, humidity, pressure)
|
||||
veml.set_integration_time(veml6070.INTEGRATIONTIME_1T)
|
||||
tsl_data.append(int(1000*veml.get_uva_light_intensity()))
|
||||
time.sleep(parameter['wait'])
|
||||
|
||||
|
||||
# close the client
|
||||
print("done")
|
||||
|
||||
|
Loading…
Reference in New Issue