Here is the code I already have:
Code: Select all
import time
import colorama
from colorama import *
import Adafruit_BMP.BMP085 as BMP085
sensor = BMP085.BMP085()
colorama.init()
starttemp= None
startpress = None
for i in range(0,6):
print('\n')
time.sleep(3)
print(Fore.RED + Style.BRIGHT + Back.YELLOW + "Welcome to the raspberry pi weather station!" + Style.RESET_ALL)
time.sleep(5)
try:
while True:
temp = sensor.read_temperature()
pressure = sensor.read_pressure()
car = "%.2f millibars" % (pressure / 100.0)
bus = "%.2f *F" % ((temp * 1.8) + 32)
if starttemp is None:
starttemp=bus
if startpress is None:
startpress=car
tp = "Temperature: %.2f *F" % ((temp * 1.8) + 32)
pp = "Pressure: %.2f millibars" % (pressure / 100.0)
p1 = str(pp)
t1 = str(tp)
print(Fore.MAGENTA + p1)
print(Fore.BLUE + t1 + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + Style.RESET_ALL)
time.sleep(1)
except KeyboardInterrupt:
endtemp = t1
endpress = p1
print("\n\n\n")
print(Fore.RED + "The starting temperature was: " + starttemp)
print(Fore.BLUE + "The starting presure was: " + startpress)
print(Fore.GREEN + "\n\n" + "The ending " + endtemp)
print(Fore.MAGENTA + "The ending " + endpress)
print("\n")
Any help would be appreciated.