Tuesday, November 28, 2017

IOT- Mongoose OS

In preparing for another IoT project I came across Mongoose OS.  Mongoose OS describes itself as “an operating system for connected products” and is a product of Cesanta. It is open source and dual-licensed under the GPLv2 licenses and a Commercial License which removes the GPLv2 and functionality restrictions.

It supports the ESP32, ESP8266, CC3220, and CC3200.  I have been mostly using it with a nodemcu board but also have gotten several simple examples running on an Olimex mod-wifi-esp822-dev board

I have been working with it off and on for a few weeks and so far am impressed. 

I have put a couple of my examples on github in the hope that they will help others.

More to follow…

Saturday, February 4, 2017

Another Adventure with IOT - CallerID Project

Over the past year or so I have been looking for an IoT project.  Last summer I came up with one which was to capture caller id information and display it on our multiple computers around the house so we can see who is calling with out getting up and checking the phone.


For the project I used the opensource Mosquitto MQTT Broker running on a Raspberry PI configured with self signed certificates.  I used TLS connections with usernames and password to secure communications between the nodes.

I captured the caller id using an old US Robotics Sportster modem connected to an original Raspberry PI Model B using a serial to USB adapter.  I started the project with the goal of working with Node.js but but had problems getting the node.js serial module running on the old Raspberry PI.  I switched over to a simple C program to capture the caller id information from the modem and publish it to the MQTT Broker.

So far I have built a Windows client which displays the caller id information using a notification from a tray icon.

The project took me a couple of months to get up and working.  This was in part due to having limited time to work on it and partly as I spent a good bit of time getting familiar with node.js.  I found Mosquitto very easy to use.  The documentation for Mosquitto and the Mosquitto API very good.

The setup has been running for several weeks now.  Both my wife and my computers have the CallerID Subscriber installed on them and we get notifications with caller id when calls come in.

One tool that I used extensively during the development process was mqtt-spy which I would recommend to anyone working with MQTT.

Friday, December 23, 2016

New Setup Guide Posted - lirc on Raspberry PI 3

A setup guide for setting up lirc on the Raspberry Pi 3 has been posted.

Setup guides are reference documents that I create for installing hardware, software and entire systems. They consist of the steps I followed for the build. They are mostly meant for my future reference but they might be able to help someone so I post them online. They are posted in the digitalhack GitHub repository under SetupGuides

Sunday, May 22, 2016

Adventures in IOT - Particle Photon

Last summer I came across the Particle Photon and decided to pick up two of them and give them a try. Fast forward a number of months and I decided on a simple project combining a DHT22 temperature and humidity sensor with the Particle Photon in a simple IOT project.


The Photon is a nice development platform in the style of the Arduino.  The Photon consists of a STM32 ARM Cortex M3 microcontroller paired with a Broadcom WICED wifi chip.  This allows easy access from the board to the Internet.

Development with the Photon can be done a couple of different ways.  There is a web based IDE paired with an online compiler known as Particle Build.  There is an IDE that can be installed on your computer which also uses the online compiler known as Particle Dev.  The online compiler can be accessed using a node.js based command line environment which allows you to use a iDE of your choice.  Finally you can roll your own development environment with the ide of your choice, ARM gcc and the DFU boot loader.  The flash process can be done over wifi or usb.

The development environment is styled after the popular Arduino development environment with good documentation and core and user contributed libraries  I have a good bit of experience with that Arduino and It’s IDE and found that there was a very minimal learning curve.

The most complex part of developing on the Photon is activating your Photon so that it can be flashed via wifi over the Internet.  There are a number of methods for doing this.  I used the Android App and the process went very smoothly.

To get started there is excellent documentation on the Particle website and a very good guide at Sparkfun.


image image image


My plan was to read the DHT22 with the photon and upload temperature and humidity data over the Internet to an IOT analytics service.

Hardware Setup

Minimal hardware is required for this project.  I used a mini breadboard, s photon, a DHT22, 10 K resistor and some hook up wire.

The DHT22 has four pins on it.  With the DHT22 facing you so you are looking at the vents the pins are numbered 1 – 4 left to right.

  1. VCC 3V to 5.5V: connects to 3.3V on Photon with a 10K resistor to pin 2.
  2. Data: connects to D3 on the Photon.
  3. N/A: is not used
  4. Ground: connect to GND on the Photon.


Using Particle Build, Particle Dev or the command line development environment a program is written the same way as an Arduino sketch with a setup routine that is executed once and a loop routine that is executed continuously after setup completes.

My simple example was made considerably easier thanks to the user contributed library for the DNT22 sensor.  The PietteTech_DHT library can be found in the list of user contributed libraries in Particle Build or as a GitHub repository

To build this example I used the command line.  When using the command line environment you put your library files, in this caswe PietteTech_DHT.cpp, PietteTech_DHT.h, and your Photon program in the same directory.  When you compile or flash you specify the directory as the source.

The example below reads the sensor and then publishes the temperature, humidity and status to the Particle website.

#include <cstdio>
#include "PietteTech_DHT.h"

#define DHTTYPE  DHT22       // Sensor type for PietteTech_DHT
#define DHTPIN   3           // Digital pin for PietteTech_DHT

// Must be declared before PietteTech_DHT 
void dht_wrapper();

// Library instantiation
PietteTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);

float temp;
float humidity;
float status;

void setup() {

// Must be setup like this for PietteTech_DHT to work
void dht_wrapper() {

void loop() {
  int result = DHT.acquireAndWait();
  if (result == DHTLIB_OK) {
    temp = DHT.getFahrenheit();
    humidity = DHT.getHumidity();
  } else {
    temp = 0;
    humidity = 0;
  char buf[80];
  int n = snprintf(buf, 80, 
    "{ \"temp\": \"%5.2f\", \"humidity\": "
    "\"%5.2f\", \"status\": \"%d\" }",
    temp, humidity, result);

  Particle.publish("THEvent", buf, 60, PRIVATE);

In a command window at the command line compile using the command below where THPublish is a subdirectdory that contains the ino file and library files.


To flash your code to the photon is done using the command below again THPublish is a subdirectory that contains the ino file and library files.  Also, photon2 is the name of the photon you are flashing.


The photon led will flash blue/red and then green and back to blue.

If everything is successful you can go to the Particle log and see you events and event data.  Starting at the main Particle web page select  image from the upper right corner.  Then on the left side of the screen select the log icon imageand see your events and event data in the log.  The way that logging works it will start logging when you show the log which means you will need to wait for your event to occur before it will be shown.



The folks at Particle has put together a very nice device and a comprehensive development environment.  The price of the device and the ease of use has greatly lowered the cost of entry in the IOT space.  Beyond traditional IOT the Particle Photon can be used to allow easy interaction with a microcontroller based project over wifi.

The Particle Photon can be purchased for $19 from Particle, Sparkfun or Adafruit making it an attractive option for your next project.

Saturday, December 26, 2015

It Worked For Me (Sort Of) - Raspberry PI and D-Link DWA-171A1

I recently purchased a D-Link DWA-171A1 Wireless AC Dual Band USB Adapter to use with a Raspberry PI 2 B after seeing a posting that stated that it worked out of the box.  Well…

It didn’t work out of the box but I was able to get it to work by compiling the driver.  I used this code from GitHub on the Raspbian Jessie image dated 11/21/2015

  1. Loaded the Raspbian Jessie image from here: https://www.raspberrypi.org/downloads/raspbian/ Linux raspberrypi (4.1.13-v7+)  to my SD Card.
  2. Added the following packages using apt-get: apt-get install dkms build-essential bc
  3. Downloaded and unzip the driver from abperiasamy/rtl8812AU_8821AU_linux GitHub repository:  https://github.com/abperiasamy/rtl8812AU_8821AU_linux/archive/master.zip
  4. Download the appropriate kernel headers for your version of Raspbian.  I found the ones I needed here: https://www.niksula.hut.fi/~mhiienka/Rpi/linux-headers-rpi/.
  5. Install the headers using sudo dpkg –i <package name>.deb.
  6. cd to the directory you unziped the driver into.
  7. Using nano or some other editor update the Makefile:
  9. The using the following commands build and install the driver.
  10. # sudo make clean
    # sudo make
    # sudo make install
    # sudo modprobe -a 8812au
You should now see the DWA-171 as a wireless interface and should be able to configure it.
I tried the same procedure using a Raspberry Pi B running Arch Linux with a 3.12.26-1-ARCH kernel and wasn’t able to get the driver to compile.
Thanks to all those who made resources available to help me along this journey.

Thursday, December 24, 2015

Project Raspberry Pi Music Player

Two weeks ago my wife informed me that the CD player attached to our stereo wasn’t working.  After a tinkering with it for a while, I decided that I wasn’t going to be able to fix it.

Over the years, we have moved from playing CDs to listening to music using computers, tablets and MP3 players.  The one time where we use the CD player is during the Holidays.

So now the holidays were almost upon us and no CD player.

I decided that this would be an opportunity to put one of the many single board computers (SBCs) to use.  I had a Raspberry PI B that I have been using in various projects over the past several years.  I had recently added a Raspberry Pi 2 B and a Raspberry Pi Zero so I figured I could turn the older system into a music player.

I figured correctly that given the huge community around the Pi that there would be at least a couple of options.  As it turned out I was not disappointed.

There are a number of options for music players for the Pi.  I checked out four of them installing three before finalizing on one.

The fist three volumio, rune, and Moode have the same look and feel as they came out of the RaspFi project and utilize the Music Player Daemon (MPD).  Pi MusicBox comes from a different lineage and has a different look and feel.

I installed all three RaspFi based versions.  There is one major difference between rune audio Player and volumio / Moode and that is that it is based on Arch Linux where as volumio and Moode based on Raspberian.  All three offer SD card images that can be downloaded, written to an SD card and insterted in the Pi and have you up and running in less than an hour.

These programs all support the Pi’s onboard audio as well as specialty Pi audio i2s audio boards as well as usb audio.  For my installation I am using the onboard audio.  With this setup I just needed a 3.5mm to RCA cable which I connected into my stereo receiver.

I started with volumio and had some success but the player ui would stall and leave me with spinning arrows.  I moved to rune audio Player and it was a much better experience.  I had some problems at first and that led me to check out Moode, but I didn’t like the ui as much and decided to go back and look at solving my problems with rune.

The first problem I had with rune was that songs would cut out.  Doing some network testing I determined that my wifi connection would drop occasionally and that caused the drop outs. The solution to this was to move the songs locally.  At fist moving the songs locally didn’t solve my problem.  Song continued to cut out.  I determined that the usb drive I was using was periodically resetting.  I moved to another usb drive and the problem went away.

I have been running rune for about a week now and am pretty happy with it.  I will detail my build over the next couple of days and post it here.

Wednesday, July 22, 2015

TI SimpleLink SensorTag 2015 - Development Environment Guide

Gerard at 43oh has posted an excellent guide for setting up the development environment for the CC2650STK.  I highly recommend that you check it out before you attempt to install Code Composer Studio.