03 June 2017

How to Add a Raspberry Pi 1.6" CPUInfo Screen

I have been playing with Raspberry Pi powered web kiosks like this:

but more on that later. I decided to add an LCD display on the front with vital stats, including the IP (since these are going on DHCP networks). I found what I was looking for on eBay for ~$13, but fortunately I also found them for considerably less at GearBest (for ~$7, but it did take 2 weeks to get here from Belgium). Here is what I received:

This simply dropped onto my Raspberry Pi kiosk (after removing the top of the case):

So now to get it to show some information. First off, thanks go out to Raspberry Pi Vietnam for getting me on the right path. Let's start by SSHing into the kiosk, updating it and a little clean up:
 sudo apt-get update
 sudo apt-get upgrade -y
 sudo apt-get autoremove -y
 sudo apt-get autoclean
Then we can install the pre-requisites:
 cd ~  
 git clone git://git.drogon.net/wiringPi  
 cd wiringPi  
 ./build  
and download the code:
 cd ~  
 wget http://www.wsiab.net/cpushow/cpu_show.zip (moved)
 wget https://johnlester.rocks/downloads/cpu_show.zip
 unzip cpu_show.zip  
 cd ~/cpu_show  
Now let's customize the content:
 nano rpi.c  
and customize the lines:
 int contrast = 45;
 bool showLogo = true;
 bool showHeader = true;
 char headerText[15];  
 sprintf(headerText, " SEPHORA NST ");
 bool showUptime = true;
 bool showCPU = true;
 bool showRAM = true;
 bool showTemp = false;
 bool showIP = true;
 char adapter[5];  
 sprintf(adapter, "wlan0");
Once done, we are ready to compile and run this:
 cc -o cpushow rpi.c PCD8544.c -L/usr/local/lib -lwiringPi  
 sudo ./cpushow  
Ta da, you should see the info below:

So now we are ready to make this run at start up. Kill the running cpushow using +C.
 sudo nano /etc/rc.local 
then add this line to the bottom (above any exit command):
 sudo /home/pi/cpu_show/cpushow  
Now reboot and you should be ready to go.
* Note: this method of startup only works if you start the gui (have a monitor attached). If you are using your Raspberry Pi headless you should create a cron job to run cpushow on start up.