Go Down

Topic: LCD System Display for Linux Appliances (Read 3035 times) previous topic - next topic

pazu

Feb 21, 2015, 12:37 am Last Edit: Feb 24, 2015, 12:38 pm by pazu
Hi all,

This may be of some interest to some of you, I run a Sophos UTM box at home as my router, I wanted to display system information on a small LCD, in my case a HD44870 powered 20x4 lcd. Easy I thought, bit of arduino code, usbserial and away I go.

The issue I had was that these types of services are locked down a LOT by the vendors as they aren't designed for these sorts of setups (no USBSerial in my case). Sophos used to support LCD4Linux, which is what I first tried to get working, but it required modifying the system significantly, which I didn't want to do.

I then set myself the challenge of using existing utilities on the server to accomplish the same. The result is the following, slightly unorthodox way of doing it :) Might be of interest so some out there.

I have put together a method for using an LCD screen like a HD44780 based 16x2 or 20x4. I had tried to use LCD4Linux, but couldn't get it working properly, and the more I stuffed around with the system the more problamatic it became.

It goes without saying that the below is NOT supported in any way shape or form and may void any support contracts, however I am using this in an Home UTM environment, so that suits me fine. You do not need to install any 3rd party utilities or programs on the system, only a small bash script and a crontab entry.

The concept:
Instead of a USB connected device, I have gone for a network based LCD running off an Arduino with an ethernet shield. I send a small HTTP request to the arduino, which converts the data into something that can be displayed on an LCD. This gives me a LOT of flexibility in customizing both the data sets and the LCD display itself, as well as possible expansion to multiple screens (not to mention it can be mounted away from the server itself).

I don't claim to be an expert in any of this, but it works, and works well, so I'm open to other ideas for improvement!

What you need:
Linux server of some description
Arduino with an Ethernet shield (few options out that there but I'm using an Uno with Ethernet Shield)
HD44870 LCD (I'm using a 20x4 via 2IC, and you can actually use any display you want, you just need to change the libraries used with the arduino)

Arduino Configuration:
Nice and easy and I won't go into detail, but plug in the ethernet shield to the arduino, then, if you are using a 2IC model LCD, plug in VCC, GND, and SDA/SCL and that's it.

Arduino Code is attached (too big to post the actual code in post)

Linux Server configuration:

You will need to update my below code based on the location of your scripts, but it is easy enough to follow. For the purpose of the below, the scripts are simply in /home/login/

create a file called statupdate in the /home/login directory

Open the file and copy/paste the following script, update the IP address with the IP address of the Arduino (I suggest a DHCP reservation (static)).

Code: [Select]


#!/bin/bash -x
IP='10.0.0.185'
while :
do
#echo "Start Loop"
DN=$(S=1; F=/sys/class/net/ppp0/statistics/rx_bytes; X=`cat $F`; /bin/sleep $S; Y=`cat $F`; BPS="$(((Y-X)/S))"; /bin/echo $BPS)
UP=$(S=1; F=/sys/class/net/ppp0/statistics/tx_bytes; X=`cat $F`; /bin/sleep $S; Y=`cat $F`; BPS="$(((Y-X)/S))"; /bin/echo $BPS)
CPU=$(/usr/bin/uptime | /bin/grep -oh "load average: [0-9].[0-9][0-9]")
CPU=$(/bin/echo $CPU | /bin/sed -r 's/^.{14}//')
UPTIME=$(/bin/cat /proc/uptime)
UPTIME=$(/bin/echo $UPTIME | cut -f1 -d" ")
#echo $DN
#echo $UP
#echo $CPU
#echo $UPTIME
#echo /usr/bin/curl $IP/?$DN/$UP/$CPU/$UPTIME!
/usr/bin/curl $IP/?$DN/$UP/$CPU/$UPTIME!
/bin/sleep 1
#echo "Finished Loop"
done


You can uncomment the Echos for debugging if needed, and change the interface you want to monitor (I'm using ppp)

Save the file and then set the execution permissions:

Code: [Select]
sudo chmod u+x /home/login/statupdate 

Lastly, you need to add the script to crontab so that it starts on reboot.

Login to your server via SSH and run the following:

Code: [Select]
Sudo crontab -e

Hit I for insert when VI loads, then copy/paste (or type) the following:

Code: [Select]
@reboot /home/login > /tmp/lcdstat.log

Hit ESC, then type :wq and hit enter.

Hit reboot and you should be done, your LCD should now start updating every 5-6 seconds.


Hopefully someone finds this useful!


arssant


Hi.

Nice work.
I came to arduino world a few months ago for same propose as you.
Using arduino and LCD to get real time info from some linux server based system.
Not over TCP-IP, but over serial connection.

I posted basic info of one of my test.
As I tested all work over dd-wrt based routers. I made a fancy mod for my wl500gP v2 .

http://forum.arduino.cc/index.php?topic=277163.0

pazu

Cheers, and yeah would have preferred USB Serial, which I have done a few times (both Linux and windows boxes), unfortunately the linux server I'm using can't use USB Serial connections, so that was ruled out. This was an interesting work around for me. The good thing is, the logic is the same, take in a string, analyse each character and then do something with it. I'm just pulled in a URL request rather than a serial input.

pazu

Just a quick note, I updated the bash script to a better version for running under crontab.

Also, here is a new arduino code file that includes the option for 3 RGB LEDs that are linked to WAN Link UP/Down and CPU load, they change colour depending on the status.

Wiring is simple, pins 2-10 for the colour lines and then +5V line (using 270 ohm resistors) to pins 30 - 32. You WILL need an Arduino Mega or PWM expansion module as you need 9 PWM outputs.

Go Up