26,33 → 26,27 |
) |
cfg.initialize() |
|
print "LTS01 temperature sensor module example \r\n" |
print "Temperature Humidity[%%] \r\n" |
print "Frequency counter readout example \r\n" |
fcount = cfg.get_device("counter") |
time.sleep(0.5) |
frequency = fcount.get_freq() |
|
#### Data Logging ################################################### |
|
tune = 143050000 |
set_freq = 10000000 |
|
try: |
while True: |
now = datetime.datetime.now() |
if (now.second == 15) or (now.second == 35) or (now.second == 55): |
frequency = fcount.get_freq() |
f = open('/sys/bus/i2c/devices/7-0055/frequency', 'a', buffering = 0) |
# set_freq = set_freq + (tune - frequency) |
with open("temperature.log", "a") as f: |
while True: |
now = datetime.datetime.now() |
if (now.second == 15) or (now.second == 35) or (now.second == 55): |
frequency = fcount.get_freq() |
now = datetime.datetime.now() |
|
if (tune > frequency): |
set_freq = set_freq + 1 |
else: set_freq = set_freq - 1 |
f.write(str(int(set_freq))) |
sys.stdout.write("frequency:" + str(frequency) + "\r\n") |
f.close() |
sys.stdout.write("frequency: " + str(frequency) + " Hz Time: " + str(now.second) + "\r") |
f.write("%d\t%s\t%.3f\n" % (time.time(), datetime.datetime.now().isoformat(), frequency)) |
|
sys.stdout.write("Time:" + str(now.second) + "\r\n") |
sys.stdout.flush() |
time.sleep(1) |
sys.stdout.flush() |
time.sleep(1) |
except KeyboardInterrupt: |
sys.stdout.write("\r\n") |
sys.exit(0) |
f.close() |