Build it step by step
0 of 7 doneWire the display
OLED on A4 and A5 with 5V and GND.
Upload the Arduino sketch
The screen shows Waiting for PC.
Install the Python packages
In a terminal, pip install psutil pyserial.
Find the port
In the IDE's Tools menu, note the Nano's port, such as COM3 or /dev/ttyUSB0.
Run the script
python stats.py and the port name. Close the IDE's serial monitor first.
Watch the bars
CPU, RAM and disk load appear and update every second.
Test the timeout
Stop the script and the screen returns to Waiting for PC after 3 seconds.
How do you build a PC stats monitor?
A small OLED beside your monitor shows CPU, RAM and disk load sent from your PC over USB serial. You need Arduino Nano, SSD1306 OLED Display, USB A to micro-USB cable (data) and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 90 minutes.
- Level
- Beginner
- Time
- About 90 min
- Parts
- 4
Parts list
- Development BoardsBuyArduino Nano × 1
- DisplaysBuy
- Cables & WiresBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| OLED VCC and GND | Nano 5V and GND | Display supply |
| OLED SDA | Nano A4 | I2C data |
| OLED SCL | Nano A5 | I2C clock |
| Nano USB | Computer | Power and serial data |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "Adafruit SSD1306" and "Adafruit GFX Library" on the Arduino. On the PC use Python 3 with the psutil and pyserial packages. The PC script is written as comments here: copy it into stats.py and remove the // marks. Close the Arduino serial monitor before running it, because only one program can use the port.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
int cpu = 0, ram = 0, disk = 0;
unsigned long lastData = 0;
String line;
void bar(byte y, const char *label, int value) {
oled.setCursor(0, y); oled.print(label);
oled.drawRect(30, y, 70, 9, SSD1306_WHITE);
oled.fillRect(30, y, map(constrain(value, 0, 100), 0, 100, 0, 70), 9, SSD1306_WHITE);
oled.setCursor(104, y); oled.print(value);
}
void setup() {
Serial.begin(9600);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
oled.setTextColor(SSD1306_WHITE);
}
void loop() {
while (Serial.available()) {
char c = Serial.read();
if (c == '\n') { // line looks like: 42,63,71
int a = line.indexOf(','), b = line.indexOf(',', a + 1);
if (a > 0 && b > a) { cpu = line.substring(0, a).toInt(); ram = line.substring(a + 1, b).toInt(); disk = line.substring(b + 1).toInt(); lastData = millis(); }
line = "";
} else if (c != '\r') line += c;
}
oled.clearDisplay();
if (millis() - lastData > 3000) {
oled.setCursor(10, 28); oled.print("Waiting for PC...");
} else {
bar(6, "CPU", cpu); bar(26, "RAM", ram); bar(46, "DSK", disk);
}
oled.display();
delay(100);
}
// ===== PC script (save as stats.py, then run: pip install psutil pyserial; python stats.py COM3) =====
// import sys, time, psutil, serial
// port = serial.Serial(sys.argv[1], 9600)
// time.sleep(2)
// while True:
// cpu = int(psutil.cpu_percent(interval=1))
// ram = int(psutil.virtual_memory().percent)
// disk = int(psutil.disk_usage('/').percent)
// port.write(f"{cpu},{ram},{disk}\n".encode())Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Start a heavy program | CPU bar rises |
| Open many browser tabs | RAM bar rises |
| Stop the script | Waiting message in 3 seconds |
| Disconnect the Nano | The script reports a serial error |
If it does not work
Waiting for PC forever
The port name is wrong or another program holds it. Close the serial monitor.
Bars stuck at zero
The line format is wrong. Each line must be three numbers separated by commas and end with a newline.
Display blank
Check the OLED address 0x3C and wiring.
Script stops after a while
The Nano reset when the port opened. Wait 2 seconds after opening, as in the script.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the PC stats monitor?
Arduino Nano, SSD1306 OLED Display, USB A to micro-USB cable (data) and Jumper wires male to male (40 pcs, 20 cm).
How long does the PC stats monitor take to build?
About 90 minutes for a beginner maker, in 7 steps.
How do I know the PC stats monitor works?
Start a heavy program: CPU bar rises. Open many browser tabs: RAM bar rises. Stop the script: Waiting message in 3 seconds.
Waiting for PC forever: what should I check?
The port name is wrong or another program holds it. Close the serial monitor.
Bars stuck at zero: what should I check?
The line format is wrong. Each line must be three numbers separated by commas and end with a newline.
Display blank: what should I check?
Check the OLED address 0x3C and wiring.
Script stops after a while: what should I check?
The Nano reset when the port opened. Wait 2 seconds after opening, as in the script.
