Raspberry Pi GPIO with Erlang

Raspberry Pis are super cool. One of the neat things about them is that they have a ton of general purpose input/output (GPIO) pins, so you can use them to control all sorts of external devices. Unfortunately, most of the examples and applications are written in Python. I know, a lot of people really love Python, but it’s just not my cup of tea.

Enter the Erlang πGPIO library by Paolo Oliveira! This is a simple, straightforward library that implements the RPi GPIO stuff for Erlang. Using it, I have created an Erlang library to control a 28BYJ-48 5V stepper motor with a ULN2003 controller board.

Check out the library here.

Installing Ansible 2.2.0 on a Raspberry Pi

Ansible is a powerful IT automation tool with lots of modules and active development. Unfortunately, the only version available for stock Raspberry Pi is old. I wanted to use some of the newer modules and features, so I needed to install at least version 2.2. This tutorial will walk you through installing Ansible 2.2.0 on a Raspberry Pi running Raspbian “jessie”. The version of Raspbian I did this on was tagged “2016-09-23”.

Creating a Debian package for Ansible requires a lot of prerequisites, including TeX Live, which can take up almost 2GB of space. If you don’t want to do this yourself, you can try downloading the Ansible package I built. It might be old by the time you read this, though!

Install Prerequisite Packages

Log into the terminal of your Raspberry Pi and run the following command to install the required packages.

sudo apt install asciidoc devscripts python-dev libffi-dev libssl-dev cdbs sshpass -y

Download and Prepare the Ansible Repo

Ansible is available for download from GitHub. Use the following commands to retrieve the Ansible source code and modules.

git clone git://github.com/ansible/ansible.git --recursive
cd ansible/

Use these commands as a guide to select and checkout a stable Ansible release. The list of tags should give you clues as to which tag is the latest and not a development version.

git tag -l
git checkout v2.2.0.0-1
make deb

Your new .deb package will be located in ./deb-build/unstable/. You can install it with the dpkg command like this.

sudo dpkg -i ./deb-build/unstable/ansible_2.2.0.0-100.git201611010320.cdec853.HEAD~unstable_all.deb

Using the Newest Ansible Features

My goal was to use Ansible on my Raspberry Pi to implement my poor-man’s dynamic DNS solution. However, you might also want to use your RPi as a centralized Ansible hub to control a cluster like the Raspberry Pi Dramble. Also consider checking out the ansible-simple-slurm-cluster repo on GitHub for more ideas.

Let me know how you’re using Ansible on your Raspberry Pi in the comments!

Using Amazon S3 as a Nette Service

Nette is a popular web application framework for PHP. It is mostly pretty well documented and easy to use. Recently, I needed to upload media from a Nette application to Amazon S3. This is how I created an S3 service for my Nette application. You will need to be familiar with Nette and have an existing Nette application to follow along.
Read more

A Poor-Man’s Dynamic DNS with Ansible and Amazon Route53

Traveling Route53

I wanted to be able to configure a DNS hostname dynamically, but couldn’t find an easy-to-use dynamic DNS client that suited my needs. Using Ansible and Amazon Route53, I put together a quick, effective solution.


First, you need an AWS account with a Route53 DNS zone. I followed these directions to create a subdomain.

Next, you need a remote host that accessible via SSH. On that host, install Python and the Boto library. Make sure that Boto is configured with sufficient AWS credentials to access and change your Route53 zone.

Ansible Configuration

This section was updated on 2016-11-29 to reflect improvements I’ve made in the Ansible playbook.

Ansible made this task simple. In fact, the playbook below is mostly based on example recipes from the Ansible Route53 module documentation. The YAML playbook should look like the example below. Replace YOUR-ROUTE53-ZONE with the zone you configured in Route53. Replace YOUR-FULL-DYNAMIC-HOSTNAME with the fully-qualified domain name that you’ll use for dynamic DNS.

Note that this uses the ipify_facts Ansible module. You can use the default value or pass api_url like I’m doing in this example.

- name: Update Dynamic IP
  hosts: localhost
    dyn_zone: YOUR-ROUTE53-ZONE
    - name: Get public IP
      ipify_facts: api_url=https://arnesonium.com/api/yourip.php
      connection: local
    - name: Get existing host information
      register: dynip
        command: get
        zone: "{{ dyn_zone }}"
        record: "{{ dyn_hostname }}"
        type: A
    - name: Delete existing host information
      when: ipify_public_ip != dynip.set.value
        command: delete
        zone: "{{ dyn_zone }}"
        record: "{{ dynip.set.record }}"
        ttl: "{{ dynip.set.ttl }}"
        type: "{{ dynip.set.type }}"
        value: "{{ dynip.set.value }}"
    - name: Create new host record
      when: ipify_public_ip != dynip.set.value
        command: create
        zone: "{{ dyn_zone }}"
        record: "{{ dyn_hostname }}"
        type: A
        ttl: 600
        value: "{{ ipify_public_ip }}"

Running Your Playbook

I named my playbook dyndns.yml, so I run it with this shell command:

ansible-playbook -vv dyndns.yml

The -vv increases the verbosity so you can see what’s going on.

The Next Step

Next, I need to convince this script to run every time my laptop’s network comes back online. I’m sure there’s a good way to do that, but I haven’t spent much time looking into it.

Did this playbook work for you? Let me know! I’d love to get feedback on it.

Alternate Ways to Call wp-cron

WordPress includes a job scheduling system called wp-cron. The default method for scheduled jobs is for wp-cron to be checked on each page load, which has the potential to slow down your website while background jobs are run. Check out these other options that help maintain the user experience on your WordPress site while still running important tasks in the background.
Read more

Pono Rez WordPress Plugin

Together with Commerce Collective,1 we have built a WordPress plugin to allow Activities & Attractions Association of Hawaii (A3H) to quickly and easily integrate activity bookings and sales into their WordPress websites.

We still have more features to add to the plugin, but it’s a solid start that will save A3H members a lot of time. It is written in PHP2 and JavaScript, and uses the Pono Rez SOAP interface to integrate activity data into a WordPress page.

Check out the plugin page here!

  1. I started working with them last year, remember

  2. Like all WordPress plugins, of course. 

CenturyLink AppFog Tutorial

Recently I wrote a tutorial with Word Lions for CenturyLink Cloud that teaches how to build and deploy a Node.js application to CenturyLink AppFog. The tutorial and application were really fun to build and write. It was my first Node.js project, and my first experience with CloudFoundry. The tutorial uses the following CenturyLink Cloud products:

AppFog is CenturyLink Cloud’s CloudFoundry system. It is really powerful, and it appears to be more flexible than Google App Engine.

Read the Tutorial

The tutorial walks you through building a document storage system with a built-in PDF reader and comment storage. It also includes user authentication and some other neat Node.js tricks. You can follow the tutorial from the following links, which will include all of the information needed to get you up and running on AppFog with Node.js. Enjoy!

  1. Deploy an App With User Login
  2. Using CenturyLink Cloud for Object Storage
  3. Add Search Capabilities with Orchestrate
  4. Building a PDF Viewer and Comment System

New Release of OpenPGP for WordPress

Version 1.3.0 of the OpenPGP Form Encryption for WordPress plugin is now available. It’s important to upgrade. It includes the following changes.

  • Updates OpenPGP.js to version 1.0.1
  • Tests the plugin against WordPress 4.2.2
  • Ensures that the browser can support OpenPGP.js

There are a few new features planned for this plugin. Expect a major version release in the next few months.

Check out the plugin page on the WordPress Plugin Repository.