agus_prayogo
Published

Display for PC RAM, VRAM, CPU & GPU with gauges

Instead of having numbers floating around your screen to see your pc performance, here you can use an arduino with lcd to display it to you

BeginnerFull instructions provided722
Display for PC RAM, VRAM, CPU & GPU with gauges

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
any arduino board should be fine
×1
LCD 16X2
basic lcd 16x2 display
×1
USB-A to B Cable
USB-A to B Cable
to connect the board to pc
×1
Rotary Potentiometer, 1 Mohm
Rotary Potentiometer, 1 Mohm
any potentiometer should work. to control brightness and contrast for the display
×2
Jumper wires (generic)
Jumper wires (generic)
for connect all the components
×12

Story

Read more

Schematics

image_2022-07-16_142937414_XTeOYaJOsg.png

Code

lcd_work2.ino

Arduino
/*
  LiquidCrystal Library - Serial Input

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch displays text sent over the serial port
 (e.g. from the Serial Monitor) on an attached LCD.

 The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 modified 7 Nov 2016
 by Arturo Guadalupi

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystalSerialDisplay

*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

char sheh;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
char heh=0;
char input[99]={};
int count=0;
int realsize=0;
//char dummy[99]={};
String dummy;
int cnt=0;
int cnt2=0;
int parsed[4]={};
float parsedbar[4]={};

byte blocks0[8] = {
    0b10000,
    0b10000,
    0b10000,
    0b10000,
    0b10000,
    0b10000,
    0b10000,
    0b10000
  };
byte blocks1[8] = {
    0b11000,
    0b11000,
    0b11000,
    0b11000,
    0b11000,
    0b11000,
    0b11000,
    0b11000
  };
byte blocks2[8] = {
    0b11100,
    0b11100,
    0b11100,
    0b11100,
    0b11100,
    0b11100,
    0b11100,
    0b11100
  };
byte blocks3[8] = {
    0b11110,
    0b11110,
    0b11110,
    0b11110,
    0b11110,
    0b11110,
    0b11110,
    0b11110
  };
byte blocks4[8] = {
    0b11111,
    0b11111,
    0b11111,
    0b11111,
    0b11111,
    0b11111,
    0b11111,
    0b11111
  };
byte cpu[8] = {
    0b00000,
    0b11111,
    0b10001,
    0b10101,
    0b10001,
    0b11111,
    0b00000,
    0b00000
  };
byte ram[8] = {
    0b10101,
    0b10101,
    0b10101,
    0b10101,
    0b10101,
    0b10101,
    0b10101,
    0b10101
  };
byte gpu[8] = {
    0b00000,
    0b00000,
    0b11111,
    0b11111,
    0b10000,
    0b00000,
    0b00000,
    0b00000
  };
byte internet[8] = {
    0b00000,
    0b00100,
    0b01010,
    0b10001,
    0b00100,
    0b01010,
    0b10001,
    0b00000
  };
void setup() {
  
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  lcd.createChar(0,blocks0);
  lcd.createChar(1,blocks1);
  lcd.createChar(2,blocks2);
  lcd.createChar(3,blocks3);
  lcd.createChar(4,blocks4);
  lcd.createChar(5,cpu);
  lcd.createChar(6,ram);
  lcd.createChar(7,gpu);
  // initialize the serial communications:
  lcd.setCursor(0,0);
  lcd.write(byte(6));
  lcd.setCursor(8,0);
  lcd.write(byte(5));
  lcd.setCursor(0,1);
  lcd.print("V");
  lcd.setCursor(8,1);
  lcd.write(byte(7));
//  lcd.createChar(4,blocks4);
  Serial.begin(9600);
}

void loop() {
  // when characters arrive over the serial port...
  cnt=0;
  cnt2=0;
  memset(input, 0, sizeof(input));
  memset(parsed, 0, sizeof(parsed));
  dummy="";
//  memset(dummy, 0, sizeof(dummy));
  count=0;
  realsize=0;
  
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
//    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      
      // display each character to the LCD
      heh=Serial.read();
      if(heh!='\n'){
        input[count]=heh;
//        Serial.print("count = ");
//        Serial.print(count);
//        Serial.print(heh);
        count++;
//        lcd.write(heh);
        Serial.print(heh);
      }
      
    }
    for(int i=0;i<sizeof(input);i++){
      if(input[i]){
        realsize++;
//        Serial.print(input[i]);
      }
      else{
        break;
      }
      
    }
    for(int i=0;i<=realsize;i++){
      if(input[i]=='-'||i==realsize){
        Serial.println("space");
        cnt=0;
        parsed[cnt2]=dummy.toInt();
        Serial.println(parsed[cnt2]);
        dummy="";
//        memset(dummy, 0, sizeof(dummy));
        cnt2++;
      }
      else{
        Serial.println("data");
        dummy+=input[i];
        Serial.println(dummy);
      }
    }
    Serial.print("realsize= ");
    Serial.println(realsize);
    Serial.println(sizeof(input));
    Serial.println("parsed results:");
    for(int i=0;i<4;i++){
      Serial.println(parsed[i]);
    }
    cnt=0;
    
    // loop over the columns:\
    cnt=0;
    for (int  thisRow = 0; thisRow < 2; thisRow++) {
      // loop over the rows:
      for (int thisCol = 1; thisCol < 16; thisCol+=8) {
        // set the cursor position:
        lcd.setCursor(thisCol, thisRow);
        // print the letter:
        if(parsed[cnt]>99){
          lcd.print("XX");
        }
        else{
          if(parsed[cnt]<10){
            lcd.print(" ");
          }
          lcd.print(parsed[cnt]);
        }
        cnt++;
        
      }
    }
    cnt=0;
    
    for(int i=0;i<2;i++){
      for(int j=3;j<16;j+=8){
        parsedbar[cnt]=parsed[cnt]*25;
        parsedbar[cnt]/=100;
        Serial.print("before round");
        Serial.println(parsedbar[cnt]);
        parsedbar[cnt]=ceil(parsedbar[cnt]);
        Serial.print("after round");
        Serial.println(parsedbar[cnt]);
        lcd.setCursor(j, i);
        cnt2=0;
        while(true){
          if(parsedbar[cnt]>5){
            lcd.write(byte(4));
            parsedbar[cnt]-=5;
            cnt2++;
          }
          else if(parsedbar[cnt]>0){
            lcd.write(byte(parsedbar[cnt]-1));
            cnt2++;
            break;
          }
          else{
            break;
          }
        }
        Serial.print(cnt2);
        Serial.print("asdf");
        
        cnt2=5-cnt2;
        Serial.print(cnt2);
        for(int k=0;k<cnt2;k++){
          lcd.print(" ");
        }
//        lcd.print(parsedbar[cnt]);
        cnt++;
      }
    }
  
   memset(parsed, 0, sizeof(parsed));
  }
}

yes.py

Python
this is the python file i use to get the data and send it to serial.
first, you need to install all the library needed
- serial
- psutil
- GPUtil

and make sure to use com port your arduino use
import serial
import psutil
import GPUtil 

ser=serial.Serial('COM7',9600,timeout=1)
#change the port accordingly

while True:
    a=psutil.cpu_percent(interval=1)
    b=psutil.virtual_memory().percent
    c=GPUtil.getGPUs()
    d=c[0].memoryUtil
    c=c[0].load
    c*=100
    d*=100
    a=round(a)
    # print(a)
    b=round(b)
    # print(b)
    d=round(d)
    a=str(a)
    b=str(b)
    c=str(c)
    d=str(d)
    x=b+'-'+a+'-'+d+'-'+c
    x=bytes(x,'ascii')
    ser.write(x)

Credits

agus_prayogo

agus_prayogo

0 projects • 0 followers

Comments