Skip to main content

Posts

Showing posts with the label get the CPU temperature using ADB

How to get the CPU temperature using ADB?

import os # Function to get the CPU temperature using ADB def get_cpu_temperature():     try:         # Run the ADB command and redirect the output to a temporary file         os.system("adb shell cat /sys/class/thermal/thermal_zone0/temp > temp.txt")         # Read the temperature from the temporary file and convert to Celsius         with open("temp.txt", "r") as file:             temperature = int(file.read().strip()) / 1000.0             return temperature     except Exception as e:         print("Error:", e)         return None     finally:         # Remove the temporary file         os.remove("temp.txt") # Function to check temperature and trigger alarm if necessary def check_temperature_and_notify(threshold):     temperat...