-
Notifications
You must be signed in to change notification settings - Fork 3
/
display.py
60 lines (48 loc) · 1.5 KB
/
display.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import json
import Adafruit_CharLCD as LCD
import time
from datetime import datetime
import os
def clearLCD():
lcd.message(" \n")
lcd.message(" \n")
lcd_rs=25
lcd_en=24
lcd_d4=23
lcd_d5=17
lcd_d6=18
lcd_d7=22
lcd_backlight=4
lcd_columns=16
lcd_rows=2
lcd=LCD.Adafruit_CharLCD(lcd_rs,lcd_en,lcd_d4,lcd_d5,lcd_d6,lcd_d7,lcd_columns,lcd_rows,lcd_backlight)
delay_time = 3
while True :
lock_file = '/home/pi/weather_station/weather-station-1/.lock'
if(not(os.path.isfile(lock_file))):
json_file = open('/home/pi/weather_station/weather-station-1/sensors.json', 'r')
json_data = json_file.read()
data = json.loads(json_data)
lcd.message('Time=' + data['date']['time'] + "\n")
# lcd.message('Time=' + time.ctime())
lcd.message(str('\nTemp={0:0.2f}*C\n'.format(data['temperature'])))
time.sleep(delay_time)
lcd.clear();
lcd.message('Time=' + data['date']['time'] + "\n")
lcd.message(str('\nHum={0:0.2f}%\n'.format(data['humidity'])))
time.sleep(delay_time)
lcd.clear();
lcd.message('Time=' + data['date']['time'] + "\n")
lcd.message(str('\nSLP={0:0.2f}Pa\n'.format(data['slp'])))
time.sleep(delay_time)
lcd.clear();
lcd.message('Time=' + data['date']['time'] + "\n")
lcd.message(str('\nPress={0:0.2f}Pa\n'.format(data['pressure'])))
time.sleep(delay_time)
lcd.clear();
lcd.message('Time=' + data['date']['time'] + "\n")
lcd.message(str('\nAlt={0:0.2f}\n'.format(data['altitude'])))
time.sleep(delay_time)
lcd.clear();
json_file.close()
exit(0)