Skip to content

Instantly share code, notes, and snippets.

@uktechreviews
Created June 10, 2015 16:35
Show Gist options
  • Save uktechreviews/148b57f3c07cdfdf3e3e to your computer and use it in GitHub Desktop.
Save uktechreviews/148b57f3c07cdfdf3e3e to your computer and use it in GitHub Desktop.
Recording temp, pressure and humidity with Astro-Pi
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