1) Overview
This plate is perfect for when you want to build a stand-alone project with its own user interface. The 4 directional buttons plus select button allows basic control without having to attach a bulky computer.
2) Usage
Plug the LCD Plate onto the Pi, using the 26-pin GPIO header such that the LCD Plate will rest above the Raspberry Pi, as shown in below:
Setting up your Pi for I2C
For a more basic introduction to setting up I2C on your Pi then you may wish to take a diversion to this Adafruit tutorial: http://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c
Type in the command sudo nano /etc/modules in order to edit “modules” file and add the following lines:
i2c-bcm2708
to the end of the file. Then save the file and reboot the Pi (type sudo reboot in the terminal) to enable the hardware I2C driver.
Before you can get started with I2C on the Pi, you’ll need to run through a couple quick steps from the console. Just enter the following commands to add SMBus support (which includes I2C) to Python:
- sudo apt-get install python-smbus
- sudo apt-get install i2c-tools
- sudo i2cdetect -y 0 (if you are using a version 1 Raspberry Pi)
- sudo i2cdetect -y 1 (if you are using a version 2 Raspberry Pi)
Using the example Python code
The easiest way to get the code onto your Pi is to hook up an Ethernet cable, and clone it directly using ‘git‘. Simply run the following commands from an appropriate location (ex. “/home/pi”):
- sudo apt-get install git
- git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
- cd Adafruit-Raspberry-Pi-Python-Code
- cd Adafruit_CharLCDPlate
Testing the Library
Once the code has been downloaded to an appropriate folder, and you have your LCD Plate properly connected, you can start with the basic demo display, which is run by simply executing the library file:
- sudo python Adafruit_CharLCDPlate.py
Adjusting Contrast
The plate uses a character LCD with an external yellow contrast potentiometer. The first time you use it, adjust the potentiometer in the bottom right (with a screwdriver or something similar) until you see the text clearly. If you don’t upload code to the Pi, some boxes may appear instead, or you may see nothing at all.
Using the library code
Interfacing with the python example code is fairly easy! Inside the Adafruit_CharLCDPlate folder you’ll find a testLCD.py python script. The script does a few things, at the top it imports all the sub-modules. You’ll need to have the Adafruit_I2C.py, Adafruit_MCP230xx.py and Adafruit_CharLCDPlate.py python files to be in the same directory so be sure to copy them to your final destination.
Next it initializes the plate with lcd = Adafruit_CharLCDPlate() – this creates the lcd object and starts communicating with the plate to set up the LCD and buttons. After initialization, you can clear the display with lcd.clear() and write text with lcd.message(“text goes here”) don’t forget that its only 16 characters per line, and it does not automatically wrap lines. To insert a newline use the special ‘\n’ character such as shown in the command: lcd.message(“Adafruit RGB LCD\nPlate w/Keypad!”). Next you can set the backlight with lcd.backlight(lcd.COLORNAME) where COLORNAME is RED, YELLOW, GREEN, TEAL, BLUE, VIOLET for RGB LCD’s or for monochrome LCDs, just use ON and OFF.
Finally, you can ask the plate which buttons are pressed with buttonPressed(lcd.BUTTONNAME) where BUTTONNAME is LEFT RIGHT UP DOWN or SELECT. This is not an interrupt-driven library so you can’t have an interrupt go off when a button in pressed, instead you’ll have to query the button in a loop.
That’s it! If you want to make detailed messages, use the python string formatting commands to create a string and then write that string with message()
http://learn.adafruit.com/adafruit-16×2-character-lcd-plus-keypad-for-raspberry-pi/usage
3) Connectivity test
Here is a python script which can test the internet connectivity on your raspberry pi and display whether there is internet connection, by pinging google. It also displays the Pi`s IP Address on the screen.
The code has been adapted from James Wooley`s “Raspberry PI Pentesting Dropbox Slypi” described here: http://www.youtube.com/watch?v=XkT__rRgLc8 and which can be found here “https://github.com/Xtrato/Slypi
To test your internet connection, simply copy and paste the following code into a new python script and save the script in the folder “Adafruit_CharLCDPlate” from the previous chapter. You can do this by the following steps:
a) Navigate to the directory Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate. If you are in /home, type:
- cd Adafruit-Raspberry-Pi-Python-Code
- cd Adafruit_CharLCDPlate
If you did the previous example, you should already be located in this directory
b) Open a new python script by typing nano ConnectivityTest.py (instead of “ConnectivityTest” you can give it any name). A blank file will open in the terminal. Copy and paste the code into this blank file and then save it and close using the Ctrl+x command.
c) Type sudo python ConnectivityTest.py in the terminal. The LCD should show “Connectivity Test” written on the screen. Press “Select” and, if there is connectivity test, a green display should pop-up saying “Testing Connectivity” followed by a yellow screen which will display the IP address of the PI as well as the IP address of ? ?
d) Press Ctrl+c to return to the command line