Lahari Immanni
Published © GPL3+

CPU Stress Detector

CPU stress detector detects the stress levels that your PC feels.

BeginnerShowcase (no instructions)1 hour316
CPU Stress Detector

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LED (generic)
LED (generic)
×2

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App
VMware Software

Story

Read more

Schematics

circuit diagram

Hardware connections

Code

CPU stress Detector code

Python
Run the code in the VMware software on the which PC you want to detect the CPU stress
import psutil
from boltiot import Bolt

api_key = "YOUR_API_KEY"
d_id = "YOUR_DEVICE_ID"

cpu_red_threshold = 0.4
client= Bolt(api_key, d_id)

#interval in seconds to check cpu usage
interval = 5

def control_green_led(pin, value):
    response = client.digitalWrite(pin, value)

def control_red_led(pin, value):
    response = client.digitalWrite(pin, value)

while True:
    cpu_usage = psutil.cpu_percent(interval = interval)
    print("CPU usage is"),cpu_usage
    if cpu_usage > cpu_red_threshold:
        control_green_led('0','LOW')
        control_red_led('1', 'HIGH')
        control_red_led('2', 'LOW')
    else:
        control_green_led('0', 'HIGH')
        control_red_led('1', 'LOW')

Credits

Lahari Immanni

Lahari Immanni

1 project • 0 followers

Comments