"Task Man": DIY Hardware Resource Monitor W/ Graphs!

by maxybar88 in Circuits > Computers

61 Views, 0 Favorites, 0 Comments

"Task Man": DIY Hardware Resource Monitor W/ Graphs!

DSC_3032 (1).jpg

This is a guide for building a Task Manager style resource monitor called "Task Man" using an rp2040 microcontroller and a SSD1306 OLED display. I came up with this idea when I wanted to see my CPU and GPU Utilization of my computer without having to open a new window, taking me out of the immersion of my fullscreen gaming experience.


Features:

  • Graphs: 4 graphs tracking CPU, GPU, network, and disk performance, along with side bar showing ram utilization.
  • Optional Button: to cycle through fullscreen graphs of individual statistics, and power off the device.
  • Auto Power Off: when data isn't received for 3 seconds.


How It Works:

A python script runs on startup and collects data using the psutil library. It then sends this over a COM port through USB to the physical device, an rp2040 based microcontroller connected to a SSD1306 OLED display, to be graphed in real time!


Drawbacks:

  • Currently does not support AMD or Intel graphics cards, only Nvidia.
  • Untested on Mac or Linux, but should work. Check psutil docs for more info.


Extra:

Keep in mind that I am no expert in any of this. I have created something that I use every day, and I hope to share it with you. Some of methods I use are probably 'incorrect'. However, I hope that does not undermine this project, or prevent you from taking inspiration from this, and then doing it the 'right' way. This is a peer to peer guide. NOT teacher to student.

For the 'Build a Tool' contest, I am 16 years old, and a student of Franklin High School in Portland, Oregon.

Supplies

rp2040-zero-2.jpg
1_1teZZlF6Jh2IxDniujdrWQ.jpg
  • Computer with supported OS and Nvidia graphics card
  • Microcontroller more powerful than an Arduino UNO (Not enough ram) I used a "Waveshare rp2040-zero" from AliExpress
  • SSD1306 Display, supports 128x64 and 128x32
  • Optional: headers to plug in button and:
  • unused pc case switch
  • button with female connector to plug in
  • Suitable case
  • you will have to make this yourself, or leave it open!
  • USB-C Cable
  • Soldering iron

Estimated cost: $5-$10 dollars.

My cost: $9 with shipping.

Prototype Hardware

Screenshot 2024-06-10 234059.png
DSC_3075.jpg

The first step I recommend is to prototype the physical circuit. For a microcontroller, I recommend using an rp2040 based MCU, although a Mega2560 or an ESP32 would likely work as well.

Requirements:

  • SSD1306 OLED display connected to appropriate pins on microcontroller.
  • Optional button from any digital pin to gnd (I used a digital output to supply ground).

Code Microcontroller

  1. Download the latest release source code from the github repo and unzip the file.
  2. If using windows and it is desired, download the exe file as well. This file will likely trigger antivirus, but it was made using pyinstaller.
  3. Open the .ino file in the Arduino IDE.
  4. You might need to install the required libraries through the library manager.
  5. If you are using a rp2040 board you will need to use a port. I use arduino-pico by Earle Philhower. Installation Guide
  6. Change any configuration variables or definitions you want:
  7. Pins:
  8. If not using a button, choose an unused pin.
  9. If using a board that does not require manual i2c pin assignment, comment out lines 7,8,93, and 94.
  10. Use lines 15 and 16 to set certain pins high or low, allowing you to solder the display directly to four digital pins, and then use two of them for vcc and gnd... or leave empty.
  11. Timing: If desired, change the timing (all in milliseconds) of the board.
  12. BOUNCE is the debounce duration.
  13. HOLD is the time required holding the button to turn the device off.
  14. TIMEOUT is the amount of time to wait for new data until automatically powering off.
  15. OLED parameters: width, height, and i2c address.
  16. 128x64 and 128x32 will work, 128x64 looks much nicer.
  17. The i2c address should be 0x3C or 0x3D.
  18. Upload!


Testing:

To test, open the serial monitor and send a message like: <C98|G34|M32|D50|U3|R210|W123|>

When you send it, you should see the data appear on screen as shown in the photo, if it does, you're ready to move on to the python program! If not, check that the display is properly connected, the correct i2c address is used, and the serial communication is functioning properly.

If using a button, you can press it to cycle through screens, hold it to power it off, and the press it again to turn back on.

Python Program

Screenshot 2024-06-10 220822.png
Screenshot 2024-06-10 221303.png
Screenshot 2024-06-10 234450.png
Screenshot 2024-06-10 223723.png
Screenshot 2024-06-10 223729.png
  1. In the previously downloaded folder from the github repo, open up the .pyw file in IDLE or your preferred development environment.
  2. Use the requirements.txt file to install the dependencies.
  3. Run the command in cmd: pip install -r requirements.txt
  4. I think the correct way to do this is something about a virtual environment but I'm a beginner to that 🤷‍♂️
  5. Open the config file in a text editor like notepad, and enter your config info:
  6. Line 1: Serial port
  7. Line 2: Update period (in seconds)
  8. Line 3: GPU index (usually zero)
  9. Line 4: Disk read maximum speed (MB/s) (Maximum speeds are the level that the top of the graph is, any value above this will get clipped to the top.)
  10. Line 5: Disk write maximum speed (MB/s)
  11. Line 6: Download maximum speed (Mbps)
  12. Line 7: Upload maximum speed (Mbps)
  13. Line 8: Disk name (Usually PhysicalDrive0) or 'ALL' in order to take the sum of all disk activity. Use psutil.disk_io_counters(perdisk=True) in the IDLE shell to decide on a disk if not using 'ALL'.
  14. Now run the program, you should see the data in the shell, and also on the OLED screen.
  15. You will likely get an error "nvml.dll not found":
  16. create a folder NVSMI in C:\Program Files\NVIDIA Corporation\
  17. Then copy nvml.dll from C:\Windows\System32 to C:\Program Files\NVIDIA Corporation\NVSMI
  18. OPTIONAL: If desired, package the python file into an exe using pyinstaller.
  19. Alternatively, you can use the .pyw file, or download the .exe file from github.
  20. Run the command: pyinstaller Task_Man.pyw -F
  21. The exe file will be in the dist folder.
  22. Now put all the files in a folder. I put this folder in my documents folder. Ensure you have:
  23. Task_Man.pyw
  24. replace with Task_Man.exe if created in optional previous step
  25. Task_Man_Config.txt
  26. TM.ico
  27. The remaining files can stay here as well.
  28. Create a shortcut to the .pyw/.exe file
  29. Place this shortcut in %AppData%\Microsoft\Windows\Start Menu\Programs\Startup
  30. This makes the program run on startup.
  31. When the program runs, a tray icon will appear. In order to stop the program, right click the tray icon, and and click Stop Task Man
  32. In order to start the program after stopping it, double click the .pyw/.exe file.

Assemble

Screenshot 2024-06-11 000637.png
Screenshot 2024-06-11 000730.png
Screenshot 2024-06-11 000858.png
DSC_3032 (1).jpg
  • Begin by soldering together all the components.
  • I unfortunately do not have the plans for my original CNC milled wooden enclosure. You will have to design and create your own case.
  • Plug it in an you are done!

I hope that you consider creating this project. I would be happy to answer any questions you have in the comments.

Downloads