Snippets Collections
How to Stress Test Your Raspberry Pi
Now it's time to find out what your Pi is really made of. Open up a terminal window and enter the following to download Stress and cpuburn-a53:

sudo apt-get install stress


gcc -o cpuburn-a53 cpuburn-a53.S
Now to run these tests, we're going to be monitoring the ARM CPU frequency to see whether the Pi automatically throttles the speed (indicates temperature of 80C) and the core temperature. Pay close attention to these, and if the temperature gets too hot, be prepared to pull the power. It's a good idea to run these tests on a fresh image of Raspbian to ensure that any important files don't get corrupted in case you need to pull the power (in case of a system freeze, crash or over-temp).

**If you need to shutdown your system while it's non-responsive, try pressing alt prtscr b before pulling the power, if that doesn't work, then remove the power supply**

To run Stress, use the following terminal command:

while true; do vcgencmd measure_clock arm; vcgencmd measure_temp; sleep 10; done& stress -c 4 -t 900s
Monitor the CPU frequency and temperature for 10mins and only move on to cpuburn-a53 if the test is run for 10mins without throttling or 80C temperatures.

import os
import glob

# read the ds18b20 sensor 
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'

def read_temp_raw():
    f = open(device_file, 'r')
    lines = f.readlines()
    return lines
def read_temp():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != 'YES':
        lines = read_temp_raw()
    equals_pos = lines[1].find('t=')
    if equals_pos != -1:
        temp_string = lines[1][equals_pos+2:]
        temp_c = float(temp_string) / 1000.0
        temp_f = temp_c * 9.0 / 5.0 + 32.0
        return temp_c, temp_f
from gpiozero import CPUTemperature

# get the temperature of the CPU of the Raspberry
def getRaspiCpuTemperature():
    tempFile = open("/sys/class/thermal/thermal_zone0/temp")
    cpu_temp =
    return (float(cpu_temp) / 1000)

# get the temperature of the CPU of the Raspberry
# with gpiozero
def getRaspiCpuTemperature02():
    gpiozero_cpu = CPUTemperature()
    return (gpiozero_cpu.temperature)

Sun Jun 26 2022 15:45:14 GMT+0000 (UTC)

#raspberry #pico #python #st7789

Sun Mar 27 2022 17:02:41 GMT+0000 (UTC)

#raspberry #terminal

Thu Dec 31 2020 16:16:12 GMT+0000 (UTC)

#python #ds18b20 #raspberry

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension