Social Distance Please

Kickstarter idea: something called “Social Distance Please”. The idea is to use iBeacons, blockchain and smartphone technology to encourage social distancing while anonymously tracking COVID-19 infected persons and those who may be exposed.

First design and develop iBeacon medallions which broadcast a UUID that is unique to Social Distance Please devices. The major and minor numbers are random and are secretly produced by a person’s Social Distance Please (SDP) smartphone app, which can associate with and manage a medallion. Major and minor numbers support a maximum of 4,294,836,225 users. Medallions could be designed as necklaces, key fobs, bracelets, etc.

Each medallion also has a receiver that can detect other medallions by Bluetooth low energy proximity sensing. If two medallions come within 2 meters of each other they vibrate or produce some type of indication to alert the people to move further apart. Each medallion also records these proximity violations and periodically synchronizes this data with the SDP smartphone app.

The SDP smartphone app is the interface to an SDP blockchain. Each proximity violation is a blockchain transaction. Transactions are completed when both medallion users synchronize their proximity violations, perhaps at the end of each day. The information is anonymous, because it uses only iBeacon major and minor number pairs with the time of day. Payment to miners could be obtained from COVID-19 Relief funds. Another feature of the SDP smartphone app would be to associate family member medallions so the proximity alerts are muted.

When a person tests positive for COVID-19, the testing agency posts another type of blockchain transaction with the person’s medallion information. This transaction would be used to notify the other persons who experienced a proximity violation with the person testing positive. The testing agency would also have an approximate number of people exposed to the person testing positive. 

The Social Distance Please idea would encourage social distancing while helping to track and notify persons exposed to COVID-19 in a secure and anonymous way.

Wearable Wi-Fi Enabled Lanyard


, ,

This was a fun project. I wanted to build an 8 x 8 matrix LED name tag that I could control with my smart phone. It was to display my name, title, company and business interests all in scrolling text.

Esp-01 lanyard
Wearable Wi-Fi Access Point

The project uses an Esp-01, Adafruit I2C backpack with 8X8 matrix LED and a 3.7 volt lithium ion battery. The code is written in C/C++ using the Arduino development environment and it’s pretty straightforward. The processor acts as a Wi-Fi access point and simple HTTP requests control the output to the 8X8 matrix LED.

Securing Raspberry Pi


, ,

This guide will walk you through a series of steps to configure really basic security for your Raspberry Pi.  First create a new user and remove the default pi account. 

Create a new user account

sudo useradd -m newuser -G sudo
sudo passwd newuser

Then ensure that the new newuser account uses bash. Simply add bin/bash to the newuser account if needed.

sudo vi /etc/passwd

Logout and login as newuser. Make sure everything works for the newuser and then remove pi account.

sudo deluser -remove-home pi

Install Firewall

Install the open source firewall and enable two ports. I like to enable secure shell access (ssh) and file access from my Mac laptop Apple Filing Protocol (AFP) over TCP.

sudo apt-get -y install ufw
sudo ufw allow 22
sudo ufw allow 548
sudo ufw enable
sudo ufw status

I do this for all of my Raspberry Pi servers. I’m sure more could be done but that’s for later post.

Do It Yourself Home Automation System


, , ,

The building blocks of my do it yourself home automation system (DIYHA) consists of nine elements:

  1. host for dashboards, graphs, control buttons, data storage, etc.
  2. Alexa interface through the Fauxmo server which emulates a Belkin switch
  3. Mosquitto MQTT broker/bridge server handles local messaging and the bridge to
  4. Environment sensor servers measuring temperature, humidity, air pressure, gas concentration, air quality and light lux
  5. Motion sensor servers for security applications and to activate or deactivate lights
  6. Administration server to manage configurations and coordinate activities between servers
  7. Alarm servers are an integral part of the security system, e.g., intruder alerts and fire alarms
  8. Lighting control servers that are controlled by Alexa or motion sensor
  9. iOS application to provide a mobile administration tool

Future posts will provide build instructions to create you own DIYHAS solution. The servers are all Raspberry Pi devices with applications written in Python 3 and the help from lots of great open source code. I’m planning to push all of my python source to github to coincide with posts.

Building a Do It Yourself Home Automation System


, ,

Welcome to my new home automation project site!

For the past four years I’ve been in a self-taught program to learn python, Raspberry Pi administration, the Internet of Things and basic digital electronics. Its really been an immersed in prototyping, discovery and testing a variety of solutions with a steep learning curve. Its been a blast!

I’m ready to start version 2.0 of my do it yourself home automation system. Over the next  couple of months I will post entries on how to build a custom home automation system with security, environment monitoring, video surveillance, lighting controls, Alexa integration and more. Please stay tuned.


Raspberry Pi Python Tool Chain




I didn’t like Python when I was first introduced to it a couple of years ago. Since that time I’ve learned that it is a great quick-n-dirty language that can be used to build an app or what we used to call a “hack”. The extent of its built-in features and the enormous amount of open source code makes it a natural do-it-yourself language.

Install Tool Chain or Installation Scripts

The first step is to install several tools to facilitate installation of Python modules.

sudo apt-get install -y python-pip git
sudo apt-get install -y build-essential python-dev python-smbus
sudo apt-get install i2c-tools

I like to use Flask so install the following for a basic environment.

sudo pip install flask 
sudo pip install requests 
sudo pip install flask-httpauth

My do-it-yourself home automation system uses MQTT for messaging. My Python apps subscribe and publish using the Paho implementation.

sudo pip install paho-mqtt

I like to use Adafruit’s I2C backpack for LED and OLED devices. Their libraries usually require the Python imaging module.

sudo apt-get -y install python-imaging python-pil

Add Adafruit libraries for the most common devices. I like to use the GPIO, LED backpack and OLED displays for almost every project.  Upgrade pip to use setup wheel

sudo python -m pip install --upgrade pip setuptools wheel

Start with the GPIO stuff. I like to use a directory called /home/pi/systemd.

mkdir systemd
cd systemed
git clone
cd Adafruit_Python_GPIO
sudo python install

Add OLED python class:

git clone
cd Adafruit_Python_SSD1306
sudo python install

Add the LED backpack class:

git clone 
cd Adafruit_Python_LED_Backpack
sudo python install

Sync and reboot. The next step depends on your project device.

Setting up a systemctl service on a Pi

Each Internet of Things (IOT) device in my Do It Yourself Home Automation System (Diyhas) has three elements.

  1. Headless Raspberry Pi server with Wi-FI and Bluetooth (Pi Zero W for example)
  2. Build and production Python directory structure with my device or subsystem Python modules and a variety of Open Source modules.
  3. Boot configuration using systemctl

The systemctl process is used to manage the IOT application.

Configuring a Basic systemctl Service Configuration File

I’m going to use my basic application as an example. My basic file structure requires to three directories: ../fonts, ../logs and ../systemd. The DiyhasClock service requires a configuration file called DiyhasClock.service. This file has three sections:

  • [Unit] — contains options not dependent on the type of the service. It contains directives like description, service behavior and dependencies with other services.
  • [Service] — categorizes services by their process and daemonizing behavior
  • [Install] — optional and defines the behavior if the service is enabled or disabled

The first step is to create a service configuration file in development directory.

cd /home/pi/systemd
vi DiyhasClock.service

The first section of the configuration file contains a [Unit] with a simple Description and the After directive which states that it requires multi-user run level.


The [Service] section has two directives. The Type specifies that the service runs after the boot sequence is complete, i.e., idle. The ExecStart is the full command and path to execute. In my case I use Python, the directory of the Python code and a log file.

ExecStart=/usr/bin/python /home/pi/systemd/ > /home/pi/logs/DiyhasClock.log 2>&1

The remaining section is used to add DiyhasClock.service to the multi-user run level when the Raspberry Pi server is booted.


The next step is to move the completed DiyhasClock.service to the systemctl directory.

Adding the DiyhasClock Service to the Boot Sequence

The next steps are relatively simple. Move the DiyhasClock.service to the systemctl directory and enabling the service.

sudo cp DiyhasClock.service /lib/systemd/system/DiyhasClock.service
sudo chmod 644 /lib/systemd/system/DiyhasClock.service
sudo systemctl daemon-reload
sudo systemctl enable DiyhasClock.service

Reboot and test the installation. For convenience I always create an aliases file to manage my IOT applications.

vi .bash_aliases

The file contains the following systemctl specific aliases.

alias stop='sudo systemctl stop DiyhasClock.service'
alias status='sudo systemctl -l status DiyhasClock.service'
alias start='sudo systemctl start DiyhasClock.service'
alias restart='sudo systemctl restart DiyhasClock.service'
alias catlog='cat /home/pi/logs/DiyhasClock.log'
alias taillog='tail -f /home/pi/logs/DiyhasClock.log'

That’s how I manage an IOT production device.

Creating a New Headless Pi Server


Every time I receive a new Raspberry Pi, I go through the same error prone discovery process of creating my personal development environment. I know its going to be Python based with Flask, Paho MQTT, Adafruit modules, my own Python models and a standard pi user file structure. I also setup a “systemd” init configuration and modify the .bash_aliases file with “status”, “restart”, “stop”, etc. to manage the process started by the boot sequence.

Since I don’t have the space to add a USB keyboard and mouse to my already crowded desk, I’ve settled on headless servers. IMHO a headless Raspberry Pi server is also an ideal Internet of Things host. This “how to guide” is for Mac OS users like myself.

Getting Started

Go to the Raspberry Pi download page, select the latest “lite” image. You will need to unpack or unzip the file.  Raspian Lite Image

Use Etcher to copy the img file to your SD card. It is usually /dev/disk2. Use Etcher to burn the img to the SD card

Ok, now the fun begins. A headless server needs SSH enabled. Simply create an empty file call “ssh” on the boot level.

cd /Volumes/boot
touch ssh

If you can’t see /Volumes/boot try reinserting the SD card.  You should see the boot volume on Finder.

I’ve standardized on Wi-Fi for most of my devices, which is a must for the Raspberry Pi Zero W. The next step is to configure your local Wi-Fi access point.

vi wpa_supplicant.conf

Insert the following into the blank file on the boot level. NO SPACES! Don’t forget to use the correct SSID and PASSWORD.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

Eject the SD card using finder. Insert it into your Raspberry Pi, power it up and cross your fingers!

First Login to Pi Zero

Special instructions for the Raspberry Pi Zero are needed to attach a Wi-Fi dongle to the USB port. First connect your Pi Zero to your network with a RJ45 connector. Boot the Pi Zero and update/upgrade the OS to support USB/Wi-Fi.

sudo rpi-update
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade

If you get a command not found error on the rpi-update then simply install it with apt-get. Some earlier distributions did not include this command.

sudo apt-get install rpi-update

The latest kernel has changed the /etc/network/interfaces file to use /etc/network/interfaced.d files. What I found that works is to add the following lines to the end of the /etc/network/interfaces file.

cd /etc/network
sudo vi interfaces

Add the following to the end of the file.

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

This may mess up dhcp but I’ve just started working with the Pi Zero USB/Wi-Fi.

First login to Pi Zero W

Login the new server and run raspi-config to set password, hostname and enable I2C.

ssh pi@raspberrypi.local
sudo raspi-config
  • Change the password and hostname
  • Expand memory
  • Enable the camera, SPI and I2C bus
  • Set timezone and localization
  • Exit and reboot

Update the operating system with latest.

sudo rpi-update
sudo apt-get update
sudo apt-get -y upgrade 
sudo apt-get -y dist-upgrade
sudo sync
sudo reboot

Configure the Apple Bonjour service and Apple networking

sudo apt-get install avahi-daemon
sudo systemctl enable avahi-daemon.service
sudo apt-get -y install netatalk

Edit the .bashrc file to enable ll and other aliases. See systemctl

vi .bashrc
sudo sync
sudo reboot

Reboot and test your installation.