Ankit Mahesh Kumar
Published © GPL3+

BOLT IOT based CPU usage monitor

Ever wanted to know how much of your CPU is being used?! A live CPU monitor which will give you visual feed back of usage using an LED

BeginnerFull instructions provided1 hour312
BOLT IOT based CPU usage monitor

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Resistor 330 ohm
Resistor 330 ohm
×1
LED (generic)
LED (generic)
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Windows 10
Microsoft Windows 10
psutils
Python

Story

Read more

Schematics

Connections

Please use 330 ohm resistor for safety

Code

Cpu usage with LED brightness

Python
LED Brightness indicates the cpu usage.
import psutil as ps

from boltiot import Bolt, Sms
import  time

API_KEY='YOUR API KEY'
DEVICE_ID='YOUR DEVICE ID'
SSID='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='Your phone number'
mybolt=Bolt(API_KEY,DEVICE_ID)'''creates a boltiot object to access the functions of the library'''
sms = Sms(SSID, AUTH_TOKEN, TO_NUMBER, FROM_NUMBER)'''creates sms object to access functions'''
response = mybolt.isOnline()'''returns if device is online or no'''
print (response)
while(1):'''infinite loop'''

	cpu_usage = ps.cpu_percent(interval = 5)'''gets cpu usage using psutil lib'''
	print(cpu_usage)
	val=int(2.55*cpu_usage)'''converts cpu usage from 0-100 to 0-255'''
	print (val)
	if cpu_usage>10:
		response=sms.send_sms("Usage greater than 10 percent.")'''sends sms request'''
		print('This is what happened:',response)'''prints response returned'''
	response=mybolt.analogWrite('0',str(val))'''writes analog val to LED'''
	print(response)

Credits

Ankit Mahesh Kumar
1 project • 0 followers

Comments