Added 4 Sensors

New release 1.2
This commit is contained in:
unixweb 2015-06-05 22:44:20 +02:00
parent 5b7d526b82
commit e2b10ec310
3 changed files with 173 additions and 15 deletions

View File

@ -1,4 +1,10 @@
+++++++++++++++++++++++++
+++++++++++++++++++++++
Version 1.2 June 5 2015
Support now 1 * BMP180 Sensors
Support now 3 * DS18B20 Sensors
+++++++++++++++++++++++
Version 1.1 May 21 2015
Update for scheduler.py, createTable.sql , weather.py

View File

@ -9,10 +9,10 @@ import MySQLdb as mdb
import datetime
from weather import *
databaseUsername="XXXX"
databasePassword="XXXX"
databaseName="XXXX" #do not change unless you named the Wordpress database with some other name
databaseHost="XXXX"
databaseUsername="XXXXX"
databasePassword="XXXXX"
databaseName="XXXXX" #do not change unless you named the Wordpress database with some other name
databaseHost="www.xxx.de"
#check if table is created or if we need to create one
@ -49,7 +49,7 @@ def saveToDatabase(temp1, temp2, temp3, temp4, humidity, pressure, sea_pressure,
now=datetime.datetime.now()
midnight=datetime.datetime.combine(now.date(),datetime.time())
minutes=((now-midnight).seconds)/60 #minutes after midnight, use datead$
print "Minutes",minutes
with con:
cur=con.cursor()
@ -73,6 +73,15 @@ def readInfo():
altitude = Altitude
pressure = Pressure
sea_pressure = Sea_pressure
print "Temp1 : ",temp1
print "Temp2 : ",temp2
print "Temp3 : ",temp3
print "Temp4 : ",temp4
print "Humidity : ",humidity
print "Altitude : ",altitude
print "Pressure : ",pressure
print "Sea Pressure : ",sea_pressure
#return "false"
#temperatureSaved="true"
return saveToDatabase(temp1, temp2, temp3, temp4, humidity, pressure, sea_pressure, altitude)

View File

@ -14,7 +14,10 @@ import Adafruit_BMP.BMP085 as BMP085
#
# For the Beaglebone Black the library will assume bus 1 by default, which is
# exposed with SCL = P9_19 and SDA = P9_20.
sensor = BMP085.BMP085()
sensor1 = BMP085.BMP085()
sensor2 = "/sys/bus/w1/devices/w1_bus_master1/28-041470306aff/w1_slave"
sensor3 = "/sys/bus/w1/devices/w1_bus_master1/28-0414709c63ff/w1_slave"
sensor4 = ""
# Optionally you can override the bus number:
#sensor = BMP085.BMP085(busnum=2)
@ -25,11 +28,151 @@ sensor = BMP085.BMP085()
# consumption are primarily the differences). The default mode is STANDARD.
#sensor = BMP085.BMP085(mode=BMP085.BMP085_ULTRAHIGHRES)
Temp1 = format(sensor.read_temperature())
Temp2 = format(sensor.read_temperature())
Temp3 = format(sensor.read_temperature())
Temp4 = format(sensor.read_temperature())
Pressure = format(sensor.read_pressure()/100)
Sea_pressure = format(sensor.read_sealevel_pressure()/100)
Altitude = format(sensor.read_altitude())
Humidity= 57
#Temp1 = format(sensor.read_temperature())
#Temp2 = format(sensor.read_temperature())
#Temp3 = format(sensor.read_temperature())
#Temp4 = format(sensor.read_temperature())
#Pressure = format(sensor.read_pressure()/100)
#Sea_pressure = format(sensor.read_sealevel_pressure()/100)
#Altitude = format(sensor.read_altitude())
#Humidity= 57
# getTemp1() method
# Sensor1 = BMP085
# Output= Temp1
def getTemp1():
temperature1 = format(sensor1.read_temperature())
if(temperature1==0):
return 0
else:
return temperature1
# getTemp2() method
# Sensor2 = DS18B20
# Output= Temp2
def getTemp2():
while 1:
if sensor2:
tempfile=open(sensor2)
thetext=tempfile.read()
tempfile.close()
tempdata=thetext.split("\n")[1].split(" ")[9]
temperature2=float(tempdata[2:])
temperature2=temperature2/1000
else:
temperature2=0
if(temperature2==0):
return 0
else:
return temperature2
# getTemp3() method
# Sensor3 = DS18B20
# Output= Temp3
def getTemp3():
while 1:
if sensor3:
tempfile=open(sensor3)
thetext=tempfile.read()
tempfile.close()
tempdata=thetext.split("\n")[1].split(" ")[9]
temperature3=float(tempdata[2:])
temperature3=temperature3/1000
else:
temperature3=0
if(temperature3==0):
return 0
else:
return temperature3
# getTemp4() method
# Sensor4 = DS18B20
# Output = Temp4
def getTemp4():
while 1:
if sensor4:
tempfile=open(sensor4)
thetext=tempfile.read()
tempfile.close()
tempdata=thetext.split("\n")[1].split(" ")[9]
temperature4=float(tempdata[2:])
temperature4=temperature4/1000
else:
temperature4=0
if(temperature4==0):
return 0
else:
return temperature4
# getPressure() method
# Sensor1 = BMP085
# Output = Pressure
def getPressure():
pressure=format(sensor1.read_pressure()/100)
if(pressure==0):
return 0
else:
return pressure
# getSeaPressure() method
# Sensor1 = BMP085
# Output = Sea_Pressure
def getSeaPressure():
sea_pressure = format(sensor1.read_sealevel_pressure()/100)
if(sea_pressure==0):
return 0
else:
return sea_pressure
# getAltitude() method
# Sensor1 = BMP085
# Output = Altitude
def getAltitude():
altitude = format(sensor1.read_altitude())
if(altitude==0):
return 0
else:
return altitude
# getHumidity() method
# Sensor1 = BMP085
# Output = Humidity
def getHumidity():
humidity= 57
if(humidity==0):
return 0
else:
return humidity
Temp1=getTemp1()
#print Temp1
Temp2=getTemp2()
#print Temp2
Temp3=getTemp3()
#print Temp3
Temp4=getTemp4()
#print Temp4
Pressure=getPressure()
#print Pressure
Sea_pressure=getSeaPressure()
#print Sea_pressure
Altitude =getAltitude()
#print Altitude
Humidity=getHumidity()
#print Humidity