Subversion Repositories yaws

Rev

Rev 1 | Rev 13 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 6
Line 19... Line 19...
19
#  along with this program; if not, write to the Free Software
19
#  along with this program; if not, write to the Free Software
20
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
#  MA 02110-1301, USA.
21
#  MA 02110-1301, USA.
22
#  
22
#  
23
#  
23
#  
-
 
24
import database as db
24
from database import samples
25
from gpiozero import CPUTemperature
-
 
26
import time
-
 
27
import sensors
Line -... Line 28...
-
 
28
 
-
 
29
AirTemp = None
-
 
30
GndTemp = None
-
 
31
Pressure = None
-
 
32
Humidity = None
-
 
33
WindSpeed = None
-
 
34
WindDirection = None
-
 
35
Rain =  None
-
 
36
Rainfall = None
-
 
37
Sunlight = None
Line 25... Line 38...
25
 
38
CPUTemp = None
26
 
39
 
-
 
40
def main(args):
-
 
41
    conn = create_connection(dbPath)
-
 
42
    while True:
-
 
43
        # get Air tph
-
 
44
        data = sensors.tph.read_tph()
-
 
45
        AirTemp = data[0]
-
 
46
        Pressure = data[1]
-
 
47
        Humidity = data[2]
-
 
48
        
-
 
49
        # get Ground temperature
-
 
50
        
-
 
51
        # get Rain info
-
 
52
        data = sensors.rain.read_rain()
-
 
53
        Rain = data[0]
-
 
54
        Rainfall = data[1]
-
 
55
        
-
 
56
        # get Wind info
-
 
57
        data = sensors.wind.read_wind()
-
 
58
        WindDirection = data[0]
-
 
59
        WindSpeed = data[1]
-
 
60
        
-
 
61
        # get light level
-
 
62
        Sunlight = sensors.light.read_light()
-
 
63
        
-
 
64
        # get CPU Temp
-
 
65
        CPUTemp = CPUTemperature()
-
 
66
        
-
 
67
        Sample = db.Samples(airtemp = AirTemp, gndtemp = GndTemp,
-
 
68
            pressure = Pressure, humidity = Humidity, windspeed = WindSpeed,
-
 
69
            direction = WindDirection, rain = Rain, rainfall = Rainfall,
-
 
70
            sunlight = Sunlight, cputemp = float(CPUTemp.temperature))
-
 
71
        db.session.add(Sample)
-
 
72
        db.session.commit()
Line 27... Line 73...
27
def main(args):
73
        time.sleep(60)
28
    conn = create_connection(dbPath)
74
    return 0
29
 
75
 
30
if __name__ == '__main__':
76
if __name__ == '__main__':