Photo from Flickr cc-by by arduinolabs |
Step 1: The acquisition
I found on the Internet a site reselling the PCD8544 for few euros (dx.com). After a moment of hesitation, I decided to give a try and I purchased it. It was the 16th of may.
The 27th of may, I received a e-mail saying that my purchase was partially shipped, one element is no more available (I've been reimbursed) and a last element will be sent later...
I finally received all my good 4 weeks after the initial purchase order. This site doesn't contradict its reputation: It delivers the good but you have to be patient... very patient ;-).
Step 2: The connection
Schema made with Fritzing (fritzing.org) |
Note: If you want to reproduce this assembly, check carefully the pin order, it may be different.
Step 3: The preparation
My first goal is to test this new display. I look on the internet and find different solution using Python or C. After few tries, I decided to use Python based on the information shared into this post.
To use the PCD8544 display we need to install few software and load a kernel module.
First, let's install wiringpi2 from drogon.net
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
Once wiringpi is installed, it is possible to test it with the following command:
gpio readall
+-----+-------+------+----+-Rev2-----+----+------+-------+-----+ | wPi | Name | Mode | Val| Physical |Val | Mode | Name | wPi | +-----+-------+------+----+----++----+----+------+-------+-----+ | | 3.3v | | | 1 || 2 | | | 5v | | | 8 | SDA | IN | Lo | 3 || 4 | | | 5V | | | 9 | SCL | IN | Lo | 5 || 6 | | | 0v | | | 7 | GPIO7 | IN | Lo | 7 || 8 | Lo | ALT0 | TxD | 15 | | | 0v | | | 9 || 10 | Lo | ALT0 | RxD | 16 | | 0 | GPIO0 | IN | Hi | 11 || 12 | Hi | OUT | GPIO1 | 1 | | 2 | GPIO2 | IN | Lo | 13 || 14 | | | 0v | | | 3 | GPIO3 | IN | Hi | 15 || 16 | Lo | OUT | GPIO4 | 4 | | | 3.3v | | | 17 || 18 | Lo | OUT | GPIO5 | 5 | | 12 | MOSI | ALT0 | Hi | 19 || 20 | | | 0v | | | 13 | MISO | ALT0 | Hi | 21 || 22 | Hi | IN | GPIO6 | 6 | | 14 | SCLK | ALT0 | Hi | 23 || 24 | Lo | ALT0 | CE1 | 10 | | | 0v | | | 25 || 26 | Lo | ALT0 | CE1 | 11 | +-----+-------+------+----+----++----+----+------+-------+-----+
Now, install the python binding of wiringpi:
sudo apt-get install python-dev python-imaging python-imaging-tk python-pip
sudo pip install wiringpi2
The program we will use require spidev to be activated. The kernel module should then be activated.
To do so, comment the line blacklist spi-bcm2708 by adding a heading # in the file /etc/modprobe.d/raspi-blacklist.conf then reboot the Raspberry Pi to activate this module.
To do so, comment the line blacklist spi-bcm2708 by adding a heading # in the file /etc/modprobe.d/raspi-blacklist.conf then reboot the Raspberry Pi to activate this module.
Finally install spidev python library:
sudo pip install spidev
The prerequisite are now installed. In next chapter we will see how to install the python library in charge of driving the PCD8544 LCD and how to use it.
Step 4: The installation
Into Raspberry Pi forum, an interesting post catch my attention. I used it as the base to control the LCD.
The library written Richard Hull's is also interesting I then took this as a example to create module that can be directly installed on the Raspberry Pi.
This pcd8544 library resulting is available into its own dedicated repository in github.
To install it, execute the following commands:
Step 4: The installation
Into Raspberry Pi forum, an interesting post catch my attention. I used it as the base to control the LCD.
The library written Richard Hull's is also interesting I then took this as a example to create module that can be directly installed on the Raspberry Pi.
This pcd8544 library resulting is available into its own dedicated repository in github.
To install it, execute the following commands:
git clone https://github.com/XavierBerger/pcd8544.git
cd pcd8544
./setup.py clean build
sudo ./setup.py installYou can now test the installation with the proposed examples:
cd examples
./pi_logo.pyIf installation works properly, you should see the following screen:
You can try to execute other examples to see what the library is capable to do with this LCD.
Step 5: The utilization
As I said in introduction, RPi-Monitor is gathering a lot of information and some of them may be interesting to have without having to start a PC. Information are made available from the embedded web server. To get and display the information we then just have to create a web client and use the library to display.
For people interesting about learning development I did comment my code:
This code is dedicated to extract the living room temperature and humidity from RPi-Monitor information.
Copy this code into a file (rpimonitor-testlcd.py) the make this file executable (chmod +x rpimonitor-testlcd.py) then execute (./rpimonitor-testlcd.py) it to see:
first of all, thanks for the rpi-monitor, a great application with lots of possibilities. I've bought myself an lcd screen, tested with your tutorial and it works! now I'm going to implement more rpimonitor functionality into it.
ReplyDeleteI did start the same kind of project: RPi-Monitor-LCD. If you are curious about my current development, you can have a look to my github repository. Nothing is documented yet but some feature are starting to be operational... to be continued ;-)
DeleteI'll definitely have a look at your work. Thanks
DeleteNearly good ... I had to change this :
ReplyDeletesudo pip install wiringpi2 to install the wiringpi in addition (the python script are calling wiringpi and not wiringpi2 module)
Thanks for this :-)
Good point, I'll fix that either in this doc or in code.
DeleteIt's the pcd8544 library that causes the problem. It uses the wiringpi library, not wiringpi2
DeleteExactly, I took some time to fix it but it is done now
DeleteI've mingled into your code for displaying data onto LCD screen and came up with my own script that doesn't depend on RPi-Monitor (though it is a GREAT tool!). Here it is: http://www.bartbania.com/index.php/lcd-display-with-rpi-and-room-temperature/
ReplyDeleteThanks for the inspiration!
Very nice work!
ReplyDeleteI just forked the pcd8544 library and did a port to java, since I use Java for my robot project.
Thanks for sharing!
Daniel