Mayank JonejaVKSingh
Published © GPL3+

Bolt IoT CPU Stress-O-Meter

How stressed is your PC? This project asks your CPU if it's too overloaded and indicates the CPU load percentage on LEDs using the Bolt.

BeginnerProtip30 minutes4,780
Bolt IoT CPU Stress-O-Meter

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

Story

Read more

Schematics

Circuit Schematic

2 LEDs for status on the

Code

CPU Stress Level

Python
Run the script on your PC/Server whose CPU load you wish to measure and display on the Bolt IoT device
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

Mayank Joneja

Mayank Joneja

6 projects • 42 followers
Embedded Hardware Development and Robotics. Networked Embedded Systems | IoT | Wireless Sensor Networks | Design Thinking
VKSingh

VKSingh

7 projects • 93 followers
Senior Software Developer

Comments