Ultimate Raspberry Pi Expansion Board

Aug 11

When I first saw the Raspberry Pi about a year ago I immediately started thinking of all the cool things we could do with this device if we connect it up to the real world.

But in all my searching I found many expansion boards with screw terminals, many with relays, a LCD header etc. etc., but I could never find one that had relays and digital I/O with screw terminals (and a LCD header and analogue I/O) all on the same board, so I decided to build one!

The idea behind this board is that you can use the RPi in a real world application by attaching one and only one expansion board. Yes you can do this with multiple boards, but think about the time you will save if you can just use the same board with the same features and the same code every time?

So this board has:

  • 4 Relays with screw terminals that can switch high voltage and current devices.
  • 3 Digital outputs with screw terminals, one of which is hardware PWM capable.
  • 4 Digital inputs with screw terminals and jumper selectable pull up/down resistors and over voltage protection.
  • 4 Analogue inputs with screw terminals.
  • 1 Analogue output with a screw terminal.
  • LCD header for connecting directly to a standard parallel LCD.
  • UART header for connecting serial devices.
  • I2C header for connecting other I2C devices.
  • SPI header for connecting other SPI devices.

I believe splitting out the headers make the cabling easier and hence development of real world applications faster. Just connect your devices to the screw terminals or headers and you are up and running in no time.

I’m hoping to have this to market within the next two weeks and to have it selling for less than the price of the Raspberry Pi.  I am already planning on using these boards in a real world application with over 150 units.

USB HID barcode readers in embedded Linux

Jul 28

Nowadays many devices such as barcode scanners, NFC readers etc. come with USB interfaces and can emulate a USB HID keyboard. This is great for interactive applications that read barcodes from STDIN, but for an embedded device (such as the Raspberry Pi) with background processes reading the barcodes this can be a nightmare.

Even though Linux exposes the device under /dev/input and as /dev/hidrawX when you read from those devices what you get is a lot more complicated than simply the contents of the barcode and hence it makes programming a lot more complex.

Virtual Consoles and inittab to the rescue!

Provided that your embedded Linux supports virtual consoles, you can write your application to simply read barcodes etc. from STDIN, test it in an interactive terminal and once it works set up inittab to run your application on a virtual console automatically every time your device starts! Your application will be receiving the decoded barcodes on STDIN or from /dev/tty and whoala!


  • Comment out the existing getty on tty2 from inittab and
  • Add a line to run your application on the second virtual console (tty2) automatically
    1. #2:23:respawn:/sbin/getty 38400 tty2
    2. 2:23:respawn:/bin/openvt -c 2 -f -s -w -- /path/to/your/application

    This will run your application on tty2 automatically when your embedded device starts, switch to that virtual console and send all the input from all USB HID keyboards to the STDIN of your application. Yes! You can have multiple HID USB keyboard emulating devices attached and they will all work.

    Known drawbacks

    • If your HID device(s) somehow manages to send Ctrl+C your application will receive EOF and probably terminate, but init will simply restart it again right away.
    • If your application reads lines you will need to program your HID device to append CR to the end of any barcode scanned or other input generated.

    You can read up on the openvt command using “man openvt”, but shortly the options do the following:

    • -c 2, select tty2, second virtual console
    • -f, force even if something else is attached to tty2 already
    • -s, switch to tty2 every time this command starts – this is vital as an inactive virtual console receives nothing
    • -w, wait for the process to complete before respawning it again
    • –, end of openvt options

Not unto the swift…

The race is not to the swift or the battle to the strong, nor does food come to the wise or wealth to the brilliant or favor to the learned; but time and chance happen to them all.
— Ecclesiates 9:11 (NIV)