Building a Raspberry Pi system monitor for PC can help you to track your computer crucial metrics such RAM, CPU usage and status of your network connection. It also involves a combination of hardware and software components
Raspberry Pi system allows you to monitor your PC's performance and optimize its performance by early detection of potential issue and display all the necessary information on a small screen connected to a Raspberry Pi. In this post, we are going to discuss step-by-step guidance how you can build a Raspberry Pi system monitor for PC.
Materials required for Building a Raspberry Pi system monitor for PC:
1.A PC running Windows
2.Raspberry Pi (You can use any mode, but a Raspberry Pi 3 or Raspberry Pi 3 is highly recommended for better performance)
3.MicroSD card with Raspberry Pi OS installed (8GB or higher)
4.Power supply for Raspberry Pi
5.HDMI cable to connect the Raspberry Pi and screen
6.USB keyboard and mouse
7.Monitor with HDMI input
8.Reliable Internet connection
9.Small screen which is compatible with Raspberry Pi such as such as LCD, OLED, or e-ink display
10.Jumper wires for connecting the screen and Raspberry Pi (if necessary)
How to Set up Raspberry Pi for your PC:
1. Insert the microSD card into your PC and format it by using the SD Card Formatter tool which is available at sdcard.org.
2. Now you can download the latest version of the Raspberry Pi OS from the www.raspberrypi.org which is official Raspberry Pi website.
3. Now use the Raspberry Pi Imager tool to write the OS image to the microSD card which is you get from www.raspberrypi.org/software).
4. After that insert your microSD card into the Raspberry Pi, connect the HDMI cable to your monitor, and connect the USB keyboard and mouse.
5. Now Power up the Raspberry Pi by plugging in the power supply.
How to Configure Raspberry Pi:
Now follow the on-screen prompts to set up the Raspberry Pi OS, Connect to the internet using either Wi-Fi or Ethernet. Then Open the terminal on Raspberry Pi (you can find it in the taskbar or use the shortcut Ctrl+Alt+T) and Update the system by running the following commands one by one:
sudo apt update
sudo apt upgrade
Now install required software:
In the terminal, install the required software by running the following command:
sudo apt install python3-pip
Once the installation is complete, install the psutil library by running the following command:
sudo pip3 install psutil flask
How to Connect the display to Raspberry Pi:
If your display requires jumper wires, connect them according to the manufacturer's instructions. Otherwise, skip this step. Connect the display to the Raspberry Pi's GPIO pins or the appropriate connector as per your display's specifications.
Write the code:
Create a new Python script using your preferred text editor on the Raspberry Pi. For example, you can run:
nano monitor.py
Write the code to retrieve the system information and display it on the screen. Here's a basic example to get you started:
import psutil
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
cpu_percent = psutil.cpu_percent(interval=1)
mem = psutil.virtual_memory()
return f"CPU: {cpu_percent}%<br>Memory: {mem.percent}%"
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
Note: The exact code will depend on the
type of display you are using. Refer to the display's documentation for
specific instructions on how to interface with it.
Run the script: Save the script and exit from the text editor. In the terminal, navigate to the directory where you saved the script and run the following command:
python3 monitor.py
Your script should start running, retrieving system information, and displaying it on the connected screen.
On your PC,
open a web browser and enter the Raspberry Pi's IP address followed by :8000
(e.g., http://raspberry_pi_ip_address:8000). You should now see the system
monitor displaying CPU and memory usage.
This is the whole process. Now you have successfully built a Raspberry Pi system monitor for your Computer. On the basis of your requirements for additional information or enhancing the user interface, you can also customize the code.
0 Comments