Skip to content

Instantly share code, notes, and snippets.

@FaliqCytron
Created May 20, 2024 01:57
Show Gist options
  • Select an option

  • Save FaliqCytron/818b04de274d5a63768ceff29e9b2589 to your computer and use it in GitHub Desktop.

Select an option

Save FaliqCytron/818b04de274d5a63768ceff29e9b2589 to your computer and use it in GitHub Desktop.
import board, digitalio, time, microcontroller, os
led = digitalio.DigitalInOut(board.LED)
led.switch_to_output()
file_name = "temperature.csv"
max_file_size = 400000 #400kB
with open(file_name, "a") as datalog:
while True:
file_size = os.stat(file_name)[6]
if file_size < max_file_size:
temp = microcontroller.cpu.temperature
datalog.write("{0:.1f}\n".format(temp))
datalog.flush()
led.value = not led.value
time.sleep(1)
else:
led.value = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment