Raspberry Pi Vibe Coding 1: Build a CLI Dashboard for CPU Load ๐Ÿ“

A Simple CLI Dashboard Tool: Show CPU Load

 

Raspberry Pi Vibe Coding 1: Build a CLI Dashboard for CPU Load ๐Ÿ“

A Simple CLI Dashboard Tool: Show CPU Load


#AI #RaspberryPi #VibeCoding


Podcast ๐ŸŽง • Video ๐Ÿ“ฝ


Vibe Coding with Raspberry Pi ๐Ÿง‘‍๐Ÿ’ป

Welcome to our vibe coding series!

In this series, we're going to build own our tools for Raspberry Pi using your favorite AI!

In the past, if you wanted a program you had to build it manually or find it somewhere online.

Today, you can use AI to build your tools, exactly the way you want!

Let's walk through a series of steps to use AI to vibe code a tool you can use on your Raspberry Pi.

Note: When you prompt your favorite AI to create a program, it may look a bit different than the program described here. That's okay! If you have any questions on this tutorial or the program you build yourself, just ask your favorite AI for help.


Today's Project: A CLI Dashboard for CPU Load ๐Ÿ“ˆ

Today’s dashboard item is small, useful, and easy: CPU load averages.

Knowing your Pi's CPU load helps you spot when it's struggling — before it freezes or crashes.

Just one thing.
Just one script.
Just one win.


Terms:

  • CLI — Command Line Interface. This is the Linux terminal.
  • Dashboard — This is a program that gives you a tidy system display.
  • CPU Load — A measure of how busy your Pi's processor is. Higher numbers mean more work. We'll use the Linux uptime command in our script.

1. Tell Yourself What You Want to Build ๐Ÿ’ก

I want a tiny shell script that prints the Raspberry Pi’s CPU load averages (1‑minute, 5‑minute, 15‑minute).
Plain text. No colors. No formatting tricks.


2. Imagine the Output ๐Ÿ’ป

Think about what you want your tool to display. You can just imagine it, or you can describe it with words.

Here's what the output of our program might look like.

=== CPU LOAD ===
Load averages: 0.12, 0.08, 0.02

3. Type the Prompt Into Your AI ๐Ÿ’ก

This is a sample prompt you might give to your favorite AI:

Write a simple shell script for Raspberry Pi that prints the CPU load averages (1‑minute, 5‑minute, 15‑minute). No colors, no formatting, just plain CLI output. Include pseudocode headings as comments in the source code for each major code block.

Your AI will most likely give you the shell script in a code box that you can copy. Press the copy button, and paste your shell script into a Linux text editor program called nano.

Here's how to save your file in Linux using nano.

cd ~ # navigate to your home directory
nano show-cpu-load.sh  # save your script, then exit nano
chmod +x show-cpu-load.sh  # make your shell script executable

Ask your favorite AI if you need help with saving the file to Linux.


4. Inspect the Source Code ๐Ÿ”Ž

Before running the script, peek inside it using more.

AI usually writes good code, but good programmers always inspect code before running it. So, run this following command in the Linux terminal.

Command to inspect the script

more show-cpu-load.sh

What you’ll see inside the file

#!/bin/bash

# CPU LOAD SCRIPT
# 1. Print header
# 2. Extract load averages from `uptime`
# 3. Print load averages

# 1. Print header
echo "=== CPU LOAD ==="

# 2. Extract load averages from `uptime`
LOAD_AVG=$(uptime | awk -F'load average:' '{print $2}')

# 3. Print load averages
echo "Load averages:$LOAD_AVG"

The pseudocode tells you the actual steps the program takes to produce the dashboard display.

Once the program looks good, we move on.


5. Test the Program ๐Ÿ’ป

To run your script, type the following:

./show-cpu-load.sh

You should see:

=== CPU LOAD ===
Load averages: 0.12, 0.08, 0.02

That’s it.
One tiny dashboard item.
One tiny win.


Try This Yourself Now ๐Ÿงช

You've seen the output.
You've inspected the code.
Now it's your turn.

Open your terminal and run through the steps:

  1. Prompt your AI — Use the sample prompt or write your own
  2. Save the script — Paste it into nano show-cpu-load.sh
  3. Make it executable — chmod +x show-cpu-load.sh
  4. Run it — ./show-cpu-load.sh

Did it work? Great!

Did you get an error? That's even better — copy the error message, paste it back to your AI, and ask for a fix. Debugging is where the real learning happens.

Once you've got it running, you're ready for what's next.

Coming Next

CPU temperature monitoring — how to keep your Pi cool under pressure.
Stay tuned!





Aaron Rose is a software engineer and technology writer at tech-reader.blog

Catch up on the latest explainer videos, podcasts, and industry discussions below.


Popular posts from this blog

Insight: The Great Minimal OS Showdown—DietPi vs Raspberry Pi OS Lite

Running AI Models on Raspberry Pi 5 (8GB RAM): What Works and What Doesn't