Thursday, January 11, 2018

I recently purchased a 7 Segment Display from Sparkfun, model COM-11629. I was interested in using my Raspberry Pi to control some external devices, and this seemed like the perfect fit. It’s controllable via I2C, SPI, and serial. So far I’m able to communicate with the device via I2C and SPI. Sparkfun provides a lot of great information on the display here. It seems to be well supported on Arduino, but I was interested in a python implementation that could run on my Raspberry Pi. You’ll need to set up a few things before you’re able to interface with the display. I’ll cover the software first.

Enable I2C and SPI on Raspberry Pi

1. First you’ll need to enable the Kernel modules that provide I2C and SPI functionality. It’s disabled by default on Rasbian (the distro I’m using). First type:

$ lsmod

If you see i2c_dev and i2c_bcm2708, you’re ready to go, if not, edit /etc/modprobe.d/raspi-blacklist.conf. Comment out (or delete) the following lines:

blacklist spi-bcm2708
blacklist i2c-bcm2708

You should then reboot and run lsmod again to verify that the drivers are loaded on boot:

Check the GPIO pinout for the PI here, so that you can see which pins on the headers I’m referring to. You should only connect one of these buses at a time. This example makes connections to 3.3v. You can however hook the display up to 5v (which will make it brighter), but you’ll need to use a Logic Level Converter to go from the Pi’s 3.3v to the display’s 5v. You can’t just connect the Pi directly to 5v, or you’ll damaging your Pi. Note: I did try to use a Logic Level Converter to connect the display at 5v, but I was unable to get it to work properly with I2c (didn’t try SPI). More investigation required. If using I2C:

RASPBERRY PI

SPARKFUN 7 SEGMENT DISPLAY

SDA

SDA

SCL

SCL

3.3v

+

GND

-

Make sure that you can see the device on the I2C bus, by default it’s address is 0x71. I’m using a rev. 1.0 Raspberry Pi Model B (256MB version), which means that the I2C is wired to bus 0. If you’re using a newer rev. 2.0 Model B (512MB version), you’ll want to use bus 1. For 256MB Pis:

Running the Clock Example

Now that your connections are checked out you run the clock example software. It’s implemented in python and uses a library (written by me) that you can use to write additional applications that use this display. Note, that this software is not a Sparkfun product and I am not responsible if it messes up your display or your Pi.

Notes

I2C at the moment seems less reliable than SPI and I occasionally get IOError exceptions when talking to it. This could be the result of my wiring setup. It’s enitrely possible I botched things horribly when soldering on the headers that allow me to plug the device into my breadboard. I’ve added retry mechanism when writing commands via I2C in order to compensate for this, but it’s probably something that I need to look into further.

I’ve been wanting to be able to compile software for my NAS, the DNS-323 from D-Link, and I found instructions at a couple of different places on the internet. In order to do this, you’ll need a cross compilation toolchain, which you can either download or build yourself.

I found some good information on the dns 323 wiki, but ultimately those instructions didn’t work for me, on firmware 1.08. Which incidentally, can be downloaded from D-Link’s website, ftp://gpl.dlink.com/DNS-323/dns323_GPL_v1.08_12182009.tgz. The pre-built toolchain provided on the wiki, didn’t have libstdc++, and the instructions for building your own failed for me (couldn’t get binutils to build).

I found very good instructions here for how to build the toolchain, complete with modifications to enable dynamic linking of libraries. Binaries are provided on that site, but they were for x86-64, and I’m on a 32-bit host.

So, I used Ubuntu Hardy Heron running in a VirtualBox VM to build it for myself. Read on for instructions on how to build it on your machine.

Cross Compile Instructions

First you’ll need to set up some build dependencies. The toolchain requires an older (3.x) gcc in order to build. gcc 4.x may work, but most of what I’ve read seems to indicate that it probably does not. You can set the /usr/bin/gcc symlink back to it’s original when you’re done.