This project allows to connect a small text LCD display to the host PC using the standard HID-compliant protocol over the USB, and print a processed output of any shell command, that can be executed on the host PC. The text on the LCD screen you see on the photo has been combined from the output of 2 shell commands (using Ubuntu host for testing):
date "+%d%m%y %T"
and
sensors -u | grep --no-messages -A 3 coretemp-isa | grep temp1_input | awk '{print $2}' | awk '{printf("%d\n",$1 + 0.5);}'
The commands are configurable so the output can be anything, including but not limited to CPU temp, GPU temp, available RAM, CPU load, FAN speed, current date/time etc. There is no limitation on which commands can be used - basically anything that you can type in the terminal and get some output, can be displayed on the LCD.
Let me share some background why I started this project. My initial need was to add a small LCD monitor to my home theater PC, which is also used as a gaming rig and an AI training device since it has 2 powerful GPU on board. Sometimes CPU and GPU were getting pretty hot so I wanted to have a small display on the box itself showing its temperature and other parameters continuously.
I came across one project here on Project Hub, which did the CPU/GPU temp monitoring however I did not like the fact that it is using a virtual serial port for communication between the Arduino board and the host PC. This approach may work ok, however it does not utilize the benefits of USB protocol and does not support plug-and-play. So I decided to develop my own solution, which is further exploring the idea of connecting different devices to the PC using the standard HID protocol. Another requirement was to make the solution configurable so that the displayed information is not limited to a predefined set of monitored parameters.
Long story short, I bought a 16x02 display and started my experiments. Connecting LCD to Arduino was easy so I'm not going to repeat it here. You can find lots of articles considering it in details - for example, this one. I used the schematic diagram from there but had to adjust the pins since I'm using Arduino Pro Micro.
The architecture of the solution is represented below:
The solution is consisted of 2 parts - the HID-compliant LCD display and the host. The host part contains the auxdisplay service, the HIDLCD driver and the HIDAPI library.
The LCD Display part is to be deployed on your Arduino board with the LCD connected to it. Please follow the Readme for HIDAuxiliaryDisplay repository.
If you have done everything as per the manual, you will see the text on the LCD display right away, no further configuration needed. I tested the solution on Ubuntu 18.04 LTS and Mac OS X Big Sur it worked without any issue.
If you want to change the information displayed on the LCD, you need to edit the /etc/auxdisplay.conf configuration file. The default configuration for Linux is below:
# Auxiliary Display Configuration file
# VID and PID of the Aux Display
vendorid = 0x2341;
productid = 0x8036;
# Refresh rate in milliseconds
refresh = 1000;
# delay between execution of display output sections, in milliseconds
cmddelay = 10;
# Display output
# The purpose of this section is to configure, which information is going to be printed on the display
# Each element of the 'display' collection ('output' section) will be executed sequentially. Execution will
# be triggered with the interval specified by the 'refresh' parameter. The delay between output section
# execution is specified by the 'cmddelay' parameter and is designated for aligning the slow speed of USB LCD
# and the host computer.
#
# Parameters of the display output section explained below:
#
# output - can be a plain text or a shell command, depending on the 'type' parameter. This parameter is
# estimated as a C/C++ string so all special characters in it have to be escaped.
# type - an integer parameter specifying how the 'output' will be interpreted. Possible options:
# 0 - the 'output' line will be printed on the display as-is
# 1 - the 'output' line is intrerpreted as a system shell command. The result of the output will
# be printed on the display.
# posx - X-coordinate of the LCD display position where the cursor shoudl be moved before the output.
# posy - Y-coordinate of the LCD display position where the cursor shoudl be moved before the output.
# If the value of X or Y coordinate is negative, the cursor will not be moved. This means that
# the output will be printed after the last output.
display =
(
{ output = "date \"+%d%m%y %T\"";
type = 1;
posx = 0;
posy = 0; },
# { output = "date \"+%T\"";
# type = 1;
# posx = 0;
# posy = 0; },
{ output = "CPU Temp. ";
type = 0;
posx = 0;
posy = 1; },
{ output = "sensors -u | grep --no-messages -A 3 coretemp-isa | grep temp1_input | awk '{print $2}' | awk '{printf(\"%d\\n\",$1 + 0.5);}'";
type = 1;
posx = -1;
posy = -1; }
);
The purpose of each parameter is explained above so you can modify the "output" lines and place your own shell commands there. Please note that commands need to be in double quotes because they are passed to the shell strings. If you need to use double quotes (' " ') or backslash ('\') in the command itself, you need to add another backslash before the symbol: (' \" ') and ('\\'), respectively.
Please note that the auxdisplay service does not perform any syntax check of your commands so it is better to test them in the command shell before adding to the auxdisplay configuration file.
Testing of other types of displays, on other Linux distros and porting to Windows is still in plans, to be continued...
Please follow this post for updates.
UPDATE 16-02-22
Added support of 2004A (20x4 monochrome) display. The solution works on it practically without modification - you only need to load a correspoding sketch from the examples of the HIDAuxiliaryDisplay library.
The result is below, achieved om Mac OSX with the following commands:
- CPU temperature: "/usr/local/bin/osx-cpu-temp -c | awk '{print $1;}'";
- GPU temperature: "/usr/local/bin/osx-cpu-temp -g | awk '{print $1;}'"
- Fan 1: "/usr/local/bin/osx-cpu-temp -f | grep 'Fan 0' | awk '{print $7;}'";
- Fan 2: "/usr/local/bin/osx-cpu-temp -f | grep 'Fan 1' | awk '{print $7;}'";
Please note that these commands require osx-cpu-temp utility to be installed in your system.
Comments