we are sending a weather ballon to space with a raspberry pi sense hat and rasp pi camera V2 we have the code written to save to file
This is the code to take pictures
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.start_preview()
camera.start_preview(alpha=200)
camera.rotation = 180
for i in range(3):
sleep(5)
camera.capture('/home/pi/Desktop/image%s.jpg' % i)
camera.stop_preview()
and this is the code to sense the enviroment
from sense_hat import SenseHat
import time
sense=SenseHat()
file = open("Datafile.csv","a")
file.write("Time, Humidity, Temperature, Pressure")
print ("Time, Humidity, Temperature, Pressure")
for n in range(60 ):
humidity = sense.get_humidity()
humidity = round(humidity, 2)
file.write(time.strftime('%X'))
file.write(",")
file.write(str(humidity))
file.write("/n")
temperature = sense.get_temperature()
temperature = round(temperature, 2)
print (time.strftime('%X'),humidity)
file.write(time.strftime('%X'))
file.write(",")
file.write(str(temperature))
file.write("/n")
temperature = sense.get_temperature()
temperature = round(temperature, 2)
print (time.strftime('%X'),temperature)
pressure = sense.get_pressure()
pressure = round(pressure, 2)
file.write(time.strftime('%X'))
file.write(",")
file.write(str(pressure))
file.write("\n")
print (time.strftime('%X'),pressure)
time.sleep(1)
file.close()
Both work we are just now trying to combine them. Please help!!