Created
May 20, 2024 01:57
-
-
Save FaliqCytron/818b04de274d5a63768ceff29e9b2589 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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