A technical blog about open source hardware and software.

Lirc_web v0.0.3

| Comments

August 10, 2014 Update: Latest version is now lirc_web v0.0.8

As part of the Open Source Universal Remote project I’ve been creating a simple and touch friendly user interface for LIRC. In a previous post I covered Controlling LIRC From the Web, where I introduced version 0.0.1 of lirc_web. Lirc_web is a simple NodeJS app I created for controlling LIRC from the web.

Since then, I’ve created a set of UI styles and fixed a number of touch related bugs with the project. I’m excited to announce v0.0.3 of lirc_web which is now on GitHub.

Here is a screen shot of the remote listing page:

Upon tapping on any remote, you’ll be taken to a page that shows all known commands for that remote:

I have a long list of intended improvements, so if you’re interested in contributing to the project please let me know. As always, if you discover any bugs or have any feedback, please let me know in the comments.

RaspberryPi IR Schematic for LIRC

| Comments

Here is a schematic I designed that demonstrates you how you could create an IR transceiver for your RaspberryPi. You can use this schematic with the LIRC software package to create your own universal remote. It’s hosted on Upverter and contains a parts list for where to purchase the parts I used.

June 1st, 2013: Thanks to some feedback and experimentation I’ve updated the schematic. This latest version reflects the best combination of parts I’ve found so far.

June 3rd, 2013: Two more schematic bugfixes.

June 8th, 2013: Read about the finished protoboard build in my Open Source Universal Remote - Parts & Picturse blog post.

Open Source Universal Remote by alexbain f24516375cfae8b9 - Upverter

View the schematic and parts list

If you have any suggestions for improvements feel free to tinker on it and submit them.

Interested in installing LIRC on your RaspberryPi? You may be interested in reading Setting up LIRC on the RaspberryPi and Controlling LIRC From the Web.

Update: Thanks to Steve in the comments for pointing out a few errors I had in the schematic.

Open Source Universal Remote

| Comments

Almost a year ago I decided to teach myself electronics by creating my own WiFi enabled universal remote. Initially I tried to build the project with an Arduino, but later switched to a RaspberryPi. As I’ve made progress on my project I’ve open sourced the software I’ve written and blogged about every step of the process.

To date, I’ve had over nine thousand unique visitors check out the posts related to this project. Based on the positive feedback I’ve received and the questions asked, I believe it makes sense to aggregate all of the data I’ve spread out across numerous blog posts into one guide. Over the coming weeks I’ll be creating a step by step guide for building your own RaspberryPi powered universal remote. In addition, I’ll be creating and open sourcing additional components of the project such as a printed circuit board and a 3D printable case to enclose the project.

Check out the Open Source Universal Remote landing page I created for the project. In the coming weeks I’ll be adding additional content to that page.

If you have any requests or ideas for this project please don’t hesitate to ask in the comments. In addition, if you have hardware engineering experience or industrial design experience and would like to contribute please get in touch.

Controlling LIRC From the Web

| Comments

In this post I will cover how to create a web interface + API for LIRC, the Linux Infrared Remote Control project. I will be using NodeJS and a RaspberryPi in this post, but the ideas generalize to other languages and hardware. This post will serve as Part 3 of my open source universal remote project posts. If you haven’t had an opportunity to read the first two posts, I suggest checking out Universal remote experiments (Part 1) and Setting up LIRC on the RaspberryPi (Part 2) before proceeding. You may also want to read Installing NodeJS on your RaspberryPi, where I cover installing NodeJS.

If you’re completely new to the RaspberryPi and want to learn more I wrote a RaspberryPi Quickstart post which covers everything from purchasing the parts to configuring the WiFi. Check that out if you’re new to the RaspberryPi ecosystem.

With that out of the way, let’s get started!

Why a web interface + API?

LIRC is an awesome open source project that handles all of the low level requirements of sending and receiving Infrared commands from a Linux computer. It’s well documented, well supported, and thanks to the work of the open source community there is now a lirc_rpi driver included in the latest version of RaspbianOS. This means that, as long as you’re running a RaspberryPi with the latest OS and firmware, LIRC can interface with the RaspberryPi GPIO pins. Fantastic.

Once you have LIRC installed and configured (which I cover in my Setting up LIRC on the RaspberryPi post), you can use LIRC executables like irsend and irrecord to send and record IR commands for all your IR devices - right from the command line! This is great fun, but not very user friendly.

I wanted a way to control LIRC from the web. I wanted a web application that enabled me to interact with LIRC from any web connected device. If I had that, I could create a mobile web app for my phone, a regular web app for a desktop, and a RESTful API for web services. The API would give me a way to connect LIRC with any external web service - opening the door for future integrations. All I needed to do was find a way to call LIRC commands from within a web application.

Which brings us to the meat of this post. Getting NodeJS and LIRC to talk.

Getting LIRC and NodeJS to talk

To make LIRC usable from the web I needed a client library in a language I could build a web application in. The client library would provide some way to make calls from the web application to LIRC. This would give me the building blocks I needed to build a web application. The usual web languages include PHP, Python, Ruby, and NodeJS.

For this project I chose to work in NodeJS. If you would prefer to implement a web application in a different language, I found two existing LIRC client libraries. Sadly, neither seem maintained. I found lircr for Ruby and pyLirc for Python.

Since I could not find an existing NodeJS LIRC client library, and the existing libraries I did find were not up to date, I built my own. I created lirc_node, a lightweight NodeJS client library that interfaces with LIRC. v0.0.1 of lirc_node only supports irsend. This allows you to send IR commands to devices that LIRC knows about.

Before trying to install and use lirc_node make sure you have completed these steps:

  • Purchased, setup, and configured a RaspberryPi to join a network
  • Wired up an IR LED and an IR Receiver to your RaspberryPi
  • Installed and configured LIRC to interface with your IR LED and IR Receiver
  • Programmed LIRC to understand your remote controls
  • Installed NodeJS on your RaspberryPi

If you have not completed all of those steps scroll back to the top of this post and check out my earlier posts. I have written detailed step by step guides to get you through each of those steps.

All caught up? Great! We’re ready to install a basic web application for LIRC.

Creating a NodeJS web application using lirc_node and lirc_web

The easiest way to setup a NodeJS web application using lirc_node is to use v0.0.1 of lirc_web, a sample NodeJS application I wrote as a proof of concept for lirc_node. This web application is extremely basic, and only proves that lirc_node works. I have plans to grow this application with additional functionality and an improved interface. You may also use the basic API included in this web application to connect your universal remote with services like Tasker or IFTTT.

January 17th 2015 Update: lirc_web is now at v0.0.8 and contains bugfixes and additional functionality. The user interface has been improved since v0.0.1, as well.

To download and install lirc_web:

mv lirc_web-master lirc_web
cd lirc_web
npm install
node app.js

That should do it. Now, visit http://raspberrypi:3000/ (or the IP address of your RaspberryPi) to confirm the sample web application shows all of the remotes and commands LIRC knows about. Clicking any of the links will tell LIRC to send that IR command via the API endpoint.

November 2nd 2013 Update: I have posted a follow up post that discusses how to ensure the lirc_web project automatically starts on boot and is accessible via port 80. Check out Running lirc_web with Nginx and Upstart to learn more.


At this point, assuming you’ve been able to get each step working, you should have a web application you can use to control any IR device that LIRC knows about.

What’s next?

In the coming months I hope to:

  • Create an open hardware schematic and PCB board that anyone can use for the hardware.
  • 3D print an enclosure for the RaspberryPi + expansion board.
  • Improve the web application and give it a proper mobile web interface.
  • Write about how to connect lirc_web to Tasker or IFTTT.

If you have any questions, suggestions, or run into any issues - please let me know.

Installing NodeJS on Your RaspberryPi

| Comments

Here’s how I installed NodeJS on my RaspberryPi:

Upgrade to the latest OS / Firmware

If you have not already upgraded to the latest version of Raspbian OS and the latest RaspberryPi firmware, I recommend following my RaspberryPi Quickstart.

Getting and Compiling NodeJS

Once your RaspberryPi is up to date, here’s how to download and compile NodeJS:

# Install some prerequisites
sudo apt-get install python g++ make

# Grab the latest version of NodeJS
mkdir ~/nodejs && cd $_
wget -N
tar xzvf node-latest.tar.gz && cd `ls -rd node-v*`

# Compile and install to your RaspberryPi
sudo make install

Please note that it takes about two hours to compile NodeJS.

Confirming Installation

You can confirm that NodeJS was installed correctly by running:

node -v
npm --help

That’s it! You’re ready to begin development.

Additional Reading:

If you’d like to do some additional reading about NodeJS or ways to access the GPIO pins on the RaspberryPi, check out:

  • NodeJS - NodeJS home page
  • pi-gpio - “node.js based library to help access the GPIO of the Raspberry Pi”
  • GpiO - “Talk to your Raspberry Pi’s GPIO”

If you have any other recommended resources please let me know!

Use Your RaspberryPi to Power a Company Dashboard

| Comments

Here are five steps to follow if you want to start using a RaspberryPi to power a company dashboard. I’ve just finished putting this together at my office. We’re using Geckoboard for the web interface:

0: Make sure your RaspberryPi is fully updated

Before you get started I highly recommend you follow my RaspberryPi Quickstart guide to get your RaspberryPi updated to the latest OS and Firmware. That post also includes links to the case and peripherals I purchased for this project.

1: Install Chromium

First, you’ll want to install Chromium on your RaspberryPi. We’ll be using Chromium to load the dashboard. I’ve also included the ttf-mscorefonts-installer package so things render nicely.

sudo apt-get install chromium ttf-mscorefonts-installer

2: Boot into X11 automatically

You’ll want to make sure your RaspberryPi immediately boots into X11.

sudo raspi-config

Scroll down to boot_behavior and hit enter. Make sure “Yes” is marked and hit enter again.

You’re done here, so scroll to Finish (right arrow key) and hit enter.

3: Start Chromium on boot

Third, you’ll want to make sure Chromium starts in kiosk (full screen, no user interface) as soon as your RaspberryPi boots up.

Create (or modify) ~/.config/lxsession/LXDE/autostart and add the line:

chromium --kiosk --incognito

Kiosk mode boots Chromium into full screen mode, by default. Incognito mode prevents a “Chrome did not shutdown cleanly” message from appearing on the top if the RaspberryPi loses power.

4: Make sure the screen does not go to sleep

Dashboards aren’t very useful if the screen goes into standy after ten minutes.

Edit /etc/xdg/lxsession/LXDE/autostart and make sure the @xscreensaver line is commented out. In addition, we’ll be adding three options that prevent the screen from going blank:

#@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank

I also needed to modify /etc/lightdm/lightdm.conf. Add this line to the [SeatDefaults] section:

xserver-command=X -s 0 dpms

5: Hide the mouse cursor

There’s no reason to keep the mouse cursor stuck in the middle of the screen. We’ll use the unclutter utility to hide it after boot.

sudo apt-get install unclutter

You’ll need to add this to your ~/.config/lxsession/LXDE/autostart file:

unclutter -idle 0


Reboot your RaspberryPi and it should:

  • Boot directly into X11
  • Start Chromium in kiosk mode and load up your dashboard
  • Prevent the screen from going to sleep after 10 minutes
  • Hide the mouse cursor

Please let me know if you have any questions or comments.

Setting Up LIRC on the RaspberryPi

| Comments

June 8th 2013 Update: I have completed a soldered circuit prototype, complete with a full parts list and high resolution build pictures. Please read Open Source Universal Remote - Parts & Picturse to learn more.

March 9th 2013 Update: I have formalized the schematic and parts list that I’m using and have made it available on Upverter. Please read RaspberryPi IR Schematic for LIRC for more details.

March 4th Update: I’ve written a follow up post that describes how to control your RaspberryPi universal remote from the web. Please check out Controlling LIRC from the web for instructions on how to install and configure the software.


In July 2012 I wrote a post called Universal remote experiments about creating a web controlled universal remote from the electronics up. The first platform I started with was an Arduino Uno. After much experimentation I learned that asking an Arduino to maintain a WiFi connection, maintain a TCP socket with a host computer, and send/receive IR signals was a bit much. With the limited memory and storage I had a hard time managing memory and keeping the system stable. I was, however, able to build a functional prototype:

At the end of that post I had decided to rebuild the project on a RaspberryPi. I chose the RaspberryPi because I wanted a single device to host a web server in addition to being able to handle the IR transmitting and receiving. Given that the RaspberryPi runs Linux I could rely on it’s stable TCP/IP implementation and use open source software packages like nginx and NodeJS to build a web application.

This post will serve as ‘part two’ of that project and cover how to install and configure LIRC on a RaspberryPi.

LIRC - Linux Infrared Remote Control

LIRC is a mature and stable open source library that provides the ability to send and receive IR commands. Thanks to the contributions of ar0n, LIRC support is now included by default in the latest version of Raspbian OS. If you’d like to see the details of the RaspberryPi GPIO integration check out the pull request he opened for it a while back.

Setting up LIRC on the RaspberryPi

Getting LIRC setup on the RaspberryPi is significantly easier now than it was six months ago.

You must be running on the latest firmware and OS for this guide to work. If you’re new to the RaspberryPi, or you haven’t upgraded to the latest firmware and OS, I recommend following my RaspberryPi Quickstart guide to get your RaspberryPi up and running on the latest OS and firmware.

First, we’ll need to install and configure LIRC to run on the RaspberryPi:

sudo apt-get install lirc

You have to modify two files before you can start testing the receiver and IR LED. I modified these files based on a thread I found on the RaspberryPi forums. If you would like to read more about these changes please check out the LIRC GPIO driver for homebrew adapter thread. In particular, read through the posts by rudiratlos on page five, as he posts his configuration files.

Add this to your /etc/modules file:

lirc_rpi gpio_in_pin=23 gpio_out_pin=22

Change your /etc/lirc/hardware.conf file to:

# /etc/lirc/hardware.conf
# Arguments which will be used when launching lircd

# Don't start lircmd even if there seems to be a good config file

# Don't start irexec, even if a good config file seems to exist.

# Try to load appropriate kernel modules

# Run "lircd --driver=help" for a list of supported drivers.
# usually /dev/lirc0 is the correct setting for systems using udev

# Default configuration files for your hardware if any

Now restart lircd so it picks up these changes:

sudo /etc/init.d/lirc stop
sudo /etc/init.d/lirc start

January 25th 2015: Marc W. in the comments pointed out that in the 3.18.x RaspberryPi firmware you must modify one additional file for the lirc-rpi kernel extension to be loaded:

Edit your /boot/config.txt file and add:


Reboot your RaspberryPi after making this change.

Wiring up the IR transceiver

June 8th 2013 Update: I’ve finished a more permanent build and documented the process in my Open Source Universal Remote - Parts & Picturse blog post.

March 9th 2013 Update: I have formalized the schematic and parts list that I’m using and have made it available on Upverter. Please read RaspberryPi IR Schematic for LIRC for more details.

To send and receive IR signals from your RaspberryPi you’ll need to wire up an IR LED and an IR receiver and tell LIRC where to find them. Here are the parts I purchased for my own project:

If you don’t already have wires and a breadboard to prototype with, you may be interested in:

For this project I wired up the IR LED to GPIO pin 22 and the IR Receiver to GPIO pin 23. You’ll see that mentioned in the /etc/modules file above.

Please check out these diagrams for information and schematics about how to wire everything up:

Here’s a picture of my initial schematic (view the updated one here) wired up to my RaspberryPi with all of the components tested and working:

Testing the IR receiver

Testing the IR receiver is relatively straightforward.

Run these two commands to stop lircd and start outputting raw data from the IR receiver:

sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0

Point a remote control at your IR receiver and press some buttons. You should see something like this:

space 16300
pulse 95
space 28794
pulse 80
space 19395
pulse 83
space 402351
pulse 135
space 7085
pulse 85
space 2903

If you don’t, something is probably incorrectly configured. Triple check that you’ve connected everything properly and haven’t crossed any wires. I highly recommend referring to the schematics I linked to above. There is also some trouble shooting advice in the RaspberryPi Forum thread I linked to above. Finally - you may want to do this in a dark room. I found that my desk lamp and overhead light would cause the IR receiver to think it was receiving valid signals.

Testing the IR LED

You’re going to need to either find an existing LIRC config file for your remote control or use your IR receiver to generate a new LIRC config file. In my case I created a new LIRC config file. To do this, read the documentation on the irrecord application that comes with LIRC.

When using irrecord it will ask you to name the buttons you’re programming as you program them. Be sure to run irrecord --list-namespace to see the valid names before you begin.

Here were the commands that I ran to generate a remote configuration file:

# Stop lirc to free up /dev/lirc0
sudo /etc/init.d/lirc stop

# Create a new remote control configuration file (using /dev/lirc0) and save the output to ~/lircd.conf
irrecord -d /dev/lirc0 ~/lircd.conf

# Make a backup of the original lircd.conf file
sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf

# Copy over your new configuration file
sudo cp ~/lircd.conf /etc/lirc/lircd.conf

# Start up lirc again
sudo /etc/init.d/lirc start

Once you’ve completed a remote configuration file and saved/added it to /etc/lirc/lircd.conf you can try testing the IR LED. We’ll be using the irsend application that comes with LIRC to facilitate sending commands. You’ll definitely want to check out the documentation to learn more about the options irsend has.

Here are the commands I ran to test my IR LED (using the “yamaha” remote configuration file I created):

# List all of the commands that LIRC knows for 'yamaha'
irsend LIST yamaha ""

# Send the KEY_POWER command once
irsend SEND_ONCE yamaha KEY_POWER

# Send the KEY_VOLUMEDOWN command once

I tested that this was working by pointing the IR led at my Yamaha receiver and testing whether I could turn it on and adjust the volume.


That’s it! You’ve now successfully installed and configured LIRC on your RaspberryPi. You can add additional remote control configuration files to your /etc/lirc/lircd.conf file to control multiple remotes.


Here’s a few resources to explore if you’d like to learn more:

My next steps

The next step for my web controlled universal remote project is going to be finding or creating remote files for all of the IR devices in my house. Once I’ve gathered all of those files together and placed them in the lircd.conf file I’ll begin work on the web application server.

I’ll cover all of that in a future post.

Questions? Comments?

Please let me know if you have any questions or run into any trouble while running through these steps. All of these steps were tested and working on the date this post was published.

RaspberryPi Quickstart

| Comments

I recently had the opportunity to purchase and setup a second RaspberryPi system. Here’s a very brief shopping list and collection of links to get your own RaspberryPi system setup.

Parts List

Setting up the SD card

  1. Download the latest Rasbian linux image.
  2. Setup the SD card by following the RPi Easy SD Card Setup guide.

Booting it all up

Plug everything in, boot up the system. If you’re planning to SSH into the RaspberryPi via Ethernet (instead of using a keyboard/mouse/monitor) you’ll have to log into your router and determine what it’s IP address is.

The default RaspberryPi login is username pi with password raspberry. You’ll probably want to change this.

Expanding the root partition

Update: April 12th 2013: Thanks to Conky (and Kevin) for suggesting this.

Once your RaspberryPi boots up, you’ll want to adjust the root partition to take up the entire SD card. This will help prevent errors about the file system being full once you start updating packages and installing new packages:

# Open the RaspiConfig tool:
sudo raspi-config

# Navigate to the "expand_rootfs" option and select it
# Quit out of the raspi-config screen

# Reboot the system:
sudo shutdown -r now

Setting up the WiFi

Assuming everything booted up okay, you’re ready to setup the wireless. To setup the wireless card to connect to your WPA/WPA2 secured wireless network, edit /etc/network/interfaces and add this to the bottom of the file. You may need to remove some existing configuration for wlan0.

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
    wpa-ssid YOUR_SSID
    wpa-psk YOUR_PASSWORD

Save this file, and run:

sudo ifdown wlan0
sudo ifup wlan0

Run ifconfig and you should see that wlan0 has an IP address.

Setting up NTP

Accurate time is useful.

sudo apt-get install ntpdate
sudo ntpdate -u

Updating Raspbian OS

After everything is setup you’ll probably want to update Raspbian to the latest packages and version.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Updating the RaspberryPi’s firmware

To update the firmware to the latest version, we’ll use Hexxeh’s rpi-update script.

sudo apt-get install git-core
sudo wget -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo rpi-update

You’re done!

At this point you should be completely setup and operational.

If you had any troubles with this please let me know in the comments.

More reading

Here are some resources to do further reading:

Spreadsheets to Websites

| Comments

This morning I came across a two interesting JavaScript libraries designed to help make Google Spreadsheets a data source for websites. Given how simple it is to get started creating a spreadsheet it seems like a great way to make that data available for public viewing.

I can imagine this being extremely useful for someone who already maintains a spreadsheet with carefully tabulated and calculated data who isn’t interested in repeatedly exporting / importing it into a database for web viewing.


Tabletop takes a Google Spreadsheet and makes it easily accessible through Javascript.


Sheetsee.js is a javascript library mashup that allows you to fill a website with content from a Google Spreadsheet. The web content and visualizations will update with every auto save by Google.

User Agent Stylesheets and Border-box

| Comments

Recently I was trying to troubleshoot why all of the inputs on a project had box-sizing: border-box applied to them. It turns out that a user agent stylesheet rule that I don’t normally see was being applied to all input elements. This user agent stylesheet rule was being applied in Chrome, Firefox, and Safari.

Here is the user agent stylesheet rule that was being applied:

input:not([type="image"]), textarea {
  box-sizing: border-box;

After some troubleshooting it turns out this rule was being applied due to a typo in the DOCTYPE for the project. After changing the DOCTYPE back to the correct HTML5 doctype (<!doctype html>) everything loaded correctly.