Adafruit_Learning_System_Gu.../CircuitPython_Essentials/CircuitPython_Logger.py
2020-12-16 14:46:09 -05:00

28 lines
750 B
Python

"""CircuitPython Essentials Storage logging example"""
import time
import board
import digitalio
import microcontroller
# For most CircuitPython boards:
led = digitalio.DigitalInOut(board.D13)
# For QT Py M0:
# led = digitalio.DigitalInOut(board.SCK)
led.switch_to_output()
try:
with open("/temperature.txt", "a") as fp:
while True:
temp = microcontroller.cpu.temperature
# do the C-to-F conversion here if you would like
fp.write('{0:f}\n'.format(temp))
fp.flush()
led.value = not led.value
time.sleep(1)
except OSError as e:
delay = 0.5
if e.args[0] == 28:
delay = 0.25
while True:
led.value = not led.value
time.sleep(delay)