software: front panel temperature sensor and process monitor

for the hardware/casemod part of this system, have a look at this page.

temperature probe and OLED

the w1_therm and w1_gpio kernel modules are needed to read from the DS18B20 temperature probe. assuming they are present in the kernel (they are in Raspbian) they can be loaded with the modprobe command. if this works correctly you can add them to /etc/modules with your preferred text editor to ensure that they are loaded at boot time.

with the kernel modules loaded and the probe hooked up to GPIO, the serial data from the probe is presented to the Pi as the file /sys/bus/w1/devices/[some-unique-identifier-string]/w1_slave. using some quick and dirty python, I repeatedly get the temperature from there and draw it to the little OLED display. the SSD1306 OLED driver library from Adafruit provides all kinds of useful example code and documentation for that.

to start the script when the Pi boots (which it does automatically when the PC is powered on), I set it up as a systemd service. to do that, I created a tempdisplay.service file in /etc/systemd/system/ specifying the script and some other parameters. to cause systemd to recheck this directory: systemctl daemon-reload. then to enable the service: systemctl enable tempdisplay.service.

HDMI display and process monitor

without any configuration the default Raspbian desktop displays at native resolution on the 7" touchscreen, and the touch HID works as you'd expect. on this, I wanted to display the processes running on the PC in a dynamic list like htop. the PC runs Windows as its primary OS, but it is sometimes necessary to boot other operating systems and so I wanted the front panel display to be OS agnostic. also as this feature is 95% aesthetic anyway, I wanted it to look cool. I had previously used Swordfish90's excellent cool-retro-term and decided it was perfect for this. (images from the cool-retro-term github):

image of cool-retro-term, from its github page image of cool-retro-term, from its github page

cool-retro-term runs on boot in fullscreen mode using cron. in cool-retro-term's launch options it's set to run this command.

$ ssh user@$(nmap -sP >/dev/null && arp -an | grep "[mac-address-here]" | awk '{print $2}' | sed 's/[()]//g') -t "ntop -s CPU% || htop || top" || echo "ntop, htop and top failed, or the SSH connection failed. check the keys."

this command first ping scans the local area network and greps the arp table for the MAC address of the PC's primary NIC to get the target IP address for the next section. this is important, as the IP/hostname will be different if the computer is temporarily running a secondary OS for a task that requires it. then it runs ntop over SSH (with an argument to sort processes by CPU usage). if this hits the Windows host, it will run properly and display system process information as ntop is installed there. if it succeeds the SSH connection but the ntop command fails, it will try htop and then top, at least one of which should run correctly if it hits Linux. if top or the SSH connection fails, it prints an error prompting me to sort out the SSH keys.