Skip to content

Instantly share code, notes, and snippets.

@Opiprog
Last active March 20, 2016 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Opiprog/2a3cc463329947845bd3 to your computer and use it in GitHub Desktop.
Save Opiprog/2a3cc463329947845bd3 to your computer and use it in GitHub Desktop.
Recording Battery Life of RPi
# By J. Vlaskamp and M. Ali
import os
import sys
import time
import datetime
tstamp = time.time()
st = datetime.datetime.fromtimestamp(tstamp).strftime('Test staterd at %Y-%m-%d %H:%M:%S\n')
print st
filename = "test_output.txt"
file = open(filename,"w")
file.write("Start Test\n")
file.write(st)
file.write("\n")
file.close
i=0
while True:
file.flush() # flush out file
i=i+1
# print i
time.sleep(60) # Delay for 1 minute (60 seconds)
# print i
file = open(filename,"a")
tstamp = time.time()
st = datetime.datetime.fromtimestamp(tstamp).strftime('%Y-%m-%d %H:%M:%S\n')
file.write(st)
file.write(str(i))
print i, st
file.write("\n")
file.close
# test code
# if i==3:
# file = open(filename,"a")
# file.write("test")
# file.write("\n")
# file.close
# break
# sys.exit()
#start 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment