Hardware components | ||||||
![]() |
| × | 1 | |||
![]() |
| × | 2 | |||
Software apps and online services | ||||||
![]() |
| |||||
![]() |
|
How do you feel after working for an entire day without any break? it feels pretty stressed, right? The same scenario is with your PC. The PC also feels stressed after working for hours. CPU stress-teller directly check the stress level of your CPU, so we can see how much load our CPU is experiencing.
Hardware
HARDWARE SETUP.
The hardware connections are quite straightforward if you've already gone through the steps in the Quickstart guide to set up the Bolt device.
https://cloud.boltiot.com/docs
There are two LEDs which we use in the project. The Green LED is on if the CPU load is less than the threshold. Once the CPU load goes above the threshold, the Red LED comes on.
The Green LED is connected between digital pin 0 and GND.
The Red LED is connected between digital pins 1 and 2. When pin 1 is High and 2 is Low, the Red LED comes on. In order to switch it off, we toggle pin 1 to Low while 2 remains low.
The hardware connections are quite straightforward if you've already gone through the steps in the Quickstart guide to set up the Bolt device.
https://cloud.boltiot.com/docs
There are two LEDs which we use in the project. The Green LED is on if the CPU load is less than the threshold. Once the CPU load goes above the threshold, the Red LED comes on.
The Green LED is connected between digital pin 0 and GND.
The Red LED is connected between digital pins 1 and 2. When pin 1 is High and 2 is Low, the Red LED comes on. In order to switch it off, we toggle pin 1 to Low while 2 remains low.
![](https://hackster.imgix.net/uploads/attachments/1176710/schematics_tFfSoLmlch.jpg)
Software
SOFTWARE SETUP.
In order to control the BOLT IOT Module, we will be using BOLT-IOT cloud.
http://www.cloud.boltiot.com
Clicking the above link you will be taken to BOLT IOT Webpage.
Copy the API Key and the Bolt Device ID after setting up your Bolt IoT Cloud account from the dashboard. In case this is unclear, have a look at one of our previous posts like the one about a Crypto/Bitcoin Price Notification system
Other than that, run the Python script on your machine by running the below command on your PC or remote server and you're done!
And so, this is it! The easiest way to bridge the cyber with the physical world to let you know if your CPU is having a hard day.
In order to control the BOLT IOT Module, we will be using BOLT-IOT cloud.
http://www.cloud.boltiot.com
Clicking the above link you will be taken to BOLT IOT Webpage.
Copy the API Key and the Bolt Device ID after setting up your Bolt IoT Cloud account from the dashboard. In case this is unclear, have a look at one of our previous posts like the one about a Crypto/Bitcoin Price Notification system
Other than that, run the Python script on your machine by running the below command on your PC or remote server and you're done!
And so, this is it! The easiest way to bridge the cyber with the physical world to let you know if your CPU is having a hard day.
Python code
PythonIt is a normal pyhton code, but before using this code you should have Bolt Iot device ID and API Key. To get your device ID and API key visit the following link
https://cloud.boltiot.com/
https://cloud.boltiot.com/
import psutil
from boltiot import Bolt
api_key = "API KEY"
d_id = "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')
Comments