Created
June 10, 2015 16:35
-
-
Save uktechreviews/148b57f3c07cdfdf3e3e to your computer and use it in GitHub Desktop.
Recording temp, pressure and humidity with Astro-Pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from astro_pi import AstroPi | |
import time | |
import sys | |
ap = AstroPi() | |
f = open("data_file.txt", "w") | |
for i in range (0,10): | |
localtime = time.asctime(time.localtime(time.time())) | |
print localtime | |
ap.show_message("Temp: ") | |
temp = str(round(ap.get_temperature(),1)) | |
ap.show_message(temp) | |
ap.show_message("Pres: ") | |
pressure = str(round(ap.get_pressure(),1)) | |
ap.show_message(pressure) | |
ap.show_message("Hum: ") | |
humidity = str(round(ap.get_humidity(),1)) | |
ap.show_message(humidity) | |
ap.clear() | |
f.write (localtime + "|") | |
f.write (temp + "|") | |
f.write (pressure + "|") | |
f.write (humidity + "\n") | |
time.sleep(30) | |
f.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment