Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: pico_temp.py
- # Author: Jeoi Reqi
- """
- This CircuitPython script performs a one-minute scan of the CPU temperature and voltage.
- It prints real-time values for each 0.25-second interval, providing a dynamic view of the CPU's thermal & electrical characteristics.
- The script concludes by displaying the average temperature and voltage over the scanning period.
- Use it to assess how your CircuitPython device handles temperature and voltage under various conditions.
- Enjoy monitoring the š„temperatureš„ and ā”voltageā” of your CircuitPython device!
- Requirements:
- - CircuitPython compatible device
- - microcontroller library
- - time library
- Usage:
- 1. Connect your CircuitPython compatible device to your computer.
- 2. Copy the script to the device's storage.
- 3. Run the script using a CircuitPython-compatible IDE or command-line interface.
- 4. Observe the real-time CPU temperature and voltage readings for one minute.
- 5. Analyze the average temperature and voltage values at the end of the scan.
- Features:
- - Real-time monitoring: Displays temperature and voltage every 0.25 seconds during the scan.
- - Dynamic view: Provides a dynamic view of the CPU's thermal and electrical characteristics.
- - Average values: Concludes with the display of average temperature and voltage over the scanning period.
- - Insightful assessment: Helps assess how your CircuitPython device responds to temperature and voltage variations.
- Note: This script is specifically designed for Raspberry Pi Pico. Ensure dependencies are met before execution.
- """
- import microcontroller
- from time import sleep
- def temp():
- return microcontroller.cpu.temperature * (9 / 5) + 32
- def voltage():
- return microcontroller.cpu.voltage
- art = '''
- * ) * ) )
- ` ) /( ( ) ` ) /( ( ( /(
- ( )(_))))\ ( ` ) ( )(_))))\( )\())
- (_(_())/((_) )\ '/(/( (_(_())/((_)\(_))/
- |_ _(_)) _((_))((_)_\ |_ _(_))((_) |_
- | | / -_) ' \() '_ \) | | / -_|_-< _|
- |_| \___|_|_|_|| .__/ |_| \___/__/\__|
- |_| + ā” VOLTAGE TESTā”
- '''
- print(art)
- print("Running 1 Minute Temp & Voltage Scan Now... \n")
- temperatures = [temp() for _ in range(240)]
- voltages = [voltage() for _ in range(240)]
- for i, (temperature, voltage) in enumerate(zip(temperatures, voltages)):
- print(f"TMP-{i+1:03d}: {temperature:.2f}Ā° (š„Fahrenheitš„), VLT-{i+1:03d}: {voltage:.2f} (ā”Voltsā”)")
- sleep(0.25)
- print(art)
- average_temp = sum(temperatures) / len(temperatures)
- average_volt = sum(voltages) / len(voltages)
- print(f"\nAverage Temperature: {average_temp:.2f}Ā° (š„Fahrenheitš„), :: Average Voltage: {average_volt:.2f} (ā”Voltsā”)\n")
- print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement