Muskaan Maan
Created June 19, 2020

CPU Stress Monitoring using Bolt IoT

This project will help you monitor your PC's performance by keeping check on the CPU usage.

BeginnerProtip2 hours8
CPU Stress Monitoring using Bolt IoT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LED (generic)
LED (generic)
×1
Buzzer
Buzzer
×1
Resistor 330 ohm
Resistor 330 ohm
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App

Story

Read more

Schematics

CPU Stress Monitor Circuit

Buzzer for Stress indication and LED for stress under threshold

Code

Configuration File

Python
SID = 'You can find SID in your Twilio Dashboard'
AUTH_TOKEN = 'You can find  on your Twilio Dashboard'
FROM_NUMBER = 'This is the no. generated by Twilio. You can find this on your Twilio Dashboard'
TO_NUMBER = 'This is your number. Make sure you are adding +91 in beginning'
API_KEY = 'This is your Bolt Cloud accout API key'
DEVICE_ID = 'This is the ID of your Bolt device'

Final Code

Python
import psutil, details, time
from boltiot import Bolt, Sms

mydevice = Bolt(details.API_KEY, details.DEVICE_ID)
sms = Sms(details.SID, details.AUTH_TOKEN, details.TO_NUMBER, details.FROM_NUMBER)

cpu_stress_threshold = 5.0

# interval after which cpu usage will be checked
interval = 5

def led(pin, value):
    response = mydevice.digitalWrite(pin, value)

def buzzer(pin, value):
    response = mydevice.analogWrite(pin, value)


while True:
    cpu_usage = psutil.cpu_percent(interval = interval)
    print ("CPU usage is", cpu_usage)
    try:

       if cpu_usage > cpu_stress_threshold:
        led('0','LOW')
        buzzer('1', '255')
        buzzer('2', '0')
        # Now a message is sent to your mobile through twilio
        response = sms.send_sms("The Current CPU usage is " + str(cpu_usage))      
        print("Response received from Twilio is: " + str(response))
        print("Status of SMS at Twilio is :" + str(response.status))

       else:
        led('0', 'HIGH')
        buzzer('1', '0')
    except Exception as e:
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

Credits

Muskaan Maan

Muskaan Maan

0 projects • 0 followers

Comments