SSD1306 i2c UPM Library with the Intel Edison

UPDATE October 6, 2015.

The current version of UPM (4.0) includes this driver. However, UPM 4.0 requires MRAA 8.0. It is pretty simple to install both of these on your Edison. I have updated this guide to use the latest library.

End Update.

The SSD1306 is a very common display driver. There are tons of SSD1306 based devices to be found on Ebay and Amazon – some very inexpensive. Adafruit has several versions for sell that can easily be added to a Edison project. The main stumbling block to using these low cost displays has been the lack of an easy to use driver. Well that problem has been solved. I have recently contributed to the intel-iot-devkit UPM library an implementation of an i2c driver for this device. As of 1-Sept-15 I have been told it will be accepted and be available in the next release.

Why the UPM library? The UPM library provides a set of commonly used drivers that can be used in multiple languages. Each driver can be made available for C/C++, nodejs, java and python. The library I implemented is configured for all supported languages but only tested on C++ and nodejs. If someone uses the driver on java or python I’d like to hear about the results.

But what if we want to use the library in node before the next release? Well that is the topic of this blog post. We will go through the steps needed to compile the driver and install it on an Edison.

For C++ utilizing the driver is simpler than nodejs, python and java. All you need to do is add the source files to your iot dev kit project. The files needed are:

  1. hd44780_bits.h
  2. lcd.h
  3. lcd.cxx
  4. ssd.h
  5. ssd1306.h
  6. ssd1306.cxx

All are available in the repo  in the src/lcd directory. There is a C++ test file in the examples directory. (Make sure you are in the ssd1306 branch). If you need help configuring the iot dev kit check out this link.

If we want to use nodejs or one of the other languages we have a little more work to do.

As always, lets unsure we have the latest version of the Yocto on our system. To check your version login to your Edison and run the following:

configure_edison --version

You will need to be on version 159 to use this driver. If you need to update I find it is really easy to use the flash tool for Edison.

Once we are up to date we need to install git on our Edison. The instructions for installing git are here.

Install MRAA

Next we need to clone the MRAA repo from git hub:

git clone https://github.com/intel-iot-devkit/mraa.git

Change to the mraa directory and  checkout the 8.0 version.

git checkout tags/v0.8.0

Then we are ready to build. We will used the same out of tree build as described in the MRAA documentation.

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr 
make
sudo make install

Install UPM:

Change back to your home directory and run the following:

git clone https://github.com/intel-iot-devkit/upm.git

Then cd to the upm directory and checkout the 4.0 version with this command:

git checkout tags/v0.4.0

We will again be using the out of tree build as described in the documentation. Enter these commands to build and install:

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr
make 
sudo make install

There is a test script for nodejs in my repo.  Simply load this up in the XDK and run it on your device. This script will run through all the functions available in the SSD1306 driver.

Installing the SSD1306 driver is a little complicated but not that difficult to accomplish. I hope these instructions make it easy for you do get this working. If you have problems feel free to let me know in the comments and I’ll see if I can help.

This should be considered the initial implementation of this driver. I have plans to add further functionality to the driver after I get a few other things done. I’d like to have the driver handle multiple display geometries (currently it only accommodates 128*64) as well and add some graphics drawing abilities. The current implementation is very functional though, and fits my requirements pretty well.

Leave a Reply