Not Quite Normal

CATaLOG | Adding an LCD

To display status information and give feedback at a glance I decided to add an LCD to CATaLOG. The LCD I used was an Matrix Orbital LK-204-25 that I purchased I while ago to use with my PC but never got round to installing.

The LCD can be interfaced via RS232 and i2c but as noted in the manual, the RS232 method needs a signal voltage of more than +5v to be reliable, which the Arduino cannot provide out of the box. Fortunately, the Ardunio Wire library provides an easy way to talk to devices over i2c and so this method can be used instead.

The biggest stumbling block was determining the i2c address as Matrix Orbital addresses are 8bit hex and the Wire library expects a 7 bit one. Reading a very useful forum post on the subject saved me a lot of time.

When using the Wire library the Arduino talks over i2c via analog input pins 4 (SDA - data line) and 5 (SCL - clock line), so you don't have to sacrifice any digital I/O lines to talk to the LCD.

The following code sets up the LCD:

#include <Wire.h>


Wire.beginTransmission(0x2E); //0x2E = 0x5C in 8bit hex
Wire.send(254); //clear the screen
Wire.send(254); //turn off cursor
Wire.send(254); //setup contrast (0-255 - 150 here)

and the following code will output "Hello World" to the LCD:

Wire.send("Hello World");

Note that the Wire.send() function only queues data for transmission - nothing is actually sent until you call Wire.endTransmission(). I also found I could only send about a line (20 chars) in each data packet.

Below is the LCD running:


Top right is the uptime of the system, and to the right of each cat name is the status and time in that state. The last line will be used for status messages when the system is updating or errors should something go wrong.


← Return to CATaLOG project page