this import line was removed without checking, because it caused a pylint message.
30 lines
872 B
Python
30 lines
872 B
Python
# SPDX-FileCopyrightText: 2017 Limor Fried for Adafruit Industries
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
import time
|
|
|
|
import board
|
|
import digitalio
|
|
import microcontroller
|
|
|
|
# pylint: disable=unused-import
|
|
import mount_sd # You must create a module mount_sd.py that mounts your sd card!
|
|
|
|
led = digitalio.DigitalInOut(board.D13)
|
|
led.direction = digitalio.Direction.OUTPUT
|
|
|
|
# Use the filesystem as normal! Our files are under /sd
|
|
|
|
print("Logging temperature to filesystem")
|
|
# append to the file!
|
|
while True:
|
|
# open file for append
|
|
with open("/sd/temperature.txt", "a") as f:
|
|
led.value = True # turn on LED to indicate we're writing to the file
|
|
t = microcontroller.cpu.temperature
|
|
print("Temperature = %0.1f" % t)
|
|
f.write("%0.1f\n" % t)
|
|
led.value = False # turn off LED to indicate we're done
|
|
# file is saved
|
|
time.sleep(1)
|