Tuesday, November 29, 2016

Entertainment system evolution

After long time I decided to do something to improve little bit my entertainment system.

In the past I played with some streamers and lately I ended up to use the glorious Wii to watch Netflix or Chromecast with the same purpose.
For a while I tried to use some Android sticks without much success.
They did work but all suffered by a bad video quality and connection problems.

In fact the connection to the network is the real problem.
The TV is located far away from the WiFi router and even using a repeater it didn't improve much the connection reliability.

So after a long time experimenting with cheap and wireless streamers, I decided to set up something better.
Here my basic requirements :

  • Wired connection
  • Faster streamer
  • Decent user interface
  • HD quality
  • Possibility to be connected to the main network
  • Possibility to stream from my server
  • Possibility to stream from local memory (flash pen)
  • Support for all video formats
  • More streaming choices than Netflix
  • Possibility to receive local HD program via antenna
Looking for something capable to cover these requirements, I ended up with two choices :
Wetek Play 2 is a nice and faster streamer with also the possibility to install a digital HDTV receiver (ATSC).
It is Android based and uses Kodi as main streaming management.

Amazon Fire TV is an Android based streamer with Alexa (the Amazon voice interface) integrated in it and very nice intuitive way, plus it supports Plex for streaming.

I tried to install Kodi on the server but I had some problems, then it was not clear when the Wetek Play 2 would be available.
I then installed as media server Plex on the server, after reading some interesting reports, and it went perfectly, plus Amazon Fire TV was readily available.

Because of that I decided to go with Amazon also if is missing the possibility to connect an ATSC receiver in order to see local HDTV channels.
As bonus it has Amazon Alexa that helps to integrate vocal commands to search for programs or activate applications. 

So after a while, here some pros and cons of using Fire TV.


  • Easy to configure and handle
  • Fast streamer. No I mean ... FAST.
  • Nice to search/select some programs using Alexa
  • Fast streaming from my server using Plex
  • Quite reliable
  • Very small, very easy to hide
  • Vudu is blocked because competitor of Amazon
  • No possibility to connect an ATSC receiver
  • Not integrated with Amazon Echo even if both are using Alexa
  • Too many apps require subscription (I guess is the same for all streamer though)
  • Quite close system. Is Android but is not open to install whatever you want

Sunday, November 27, 2016

Playing with Alexa and Echo

After my first tests with the Raspberry Pi and Alexa it was time to try an Echo.
Since now is available a more cheap version, the Echo Dot, I bought one of these and started to play.
Here some notes about.

Is it good ?

Yeah :) It is good.
Of course is not perfect, there is a huge space for improvements, but it is already something, especially when I was able to link it with my HA system.
But let see some details.

What it can do

Well, like the things I tried with the Raspberry Pi  you have the usual activities, asking the time, setting timers, creating lists, emulating Eliza :)
Other than that, the big advantage of Echo Dot is the possibility to ask and listen music, podcast, etc.
Of course to have decent results is better to pair it with an external bluetooth speaker.

Then, with some plugins and extra work, is possible to interface Alexa with different things, like my HA system (based on X10) and other appliances.
Now is really nice to turn on/off/dim the lights of my house simply asking Alexa to do it.

Yeah, nothing really new, already 20 years ago it was possible something like that, but the cost to set up a system capable to respond to vocal commands was huge and the system was surely less responsive and less easy to use.
Alexa really is impressive and all considered is easy to set up.

Well, OK, easy relatively speaking.
For example, in order to connect Alexa to my HA system I had to do some vodoo :)

Interface Alexa with X10

As I said, my HA system is still based on the old, glorious X10 protocol.
Why ? Well, I had around tons fo X10 modules and the newer systems, like Zigbee or Zwave, are still quite expensive.
I would love to migrate on Zigbee for example, but I still have a lot of still good X10 working modules.
I hate to trash away something that still work.

I have a server running Heyu that controls the lights and it handle some macros and timer.
So the natural question was, is it possible to interface Alexa with my server ?
A quick search with google said yes !

I found a very nice and detailed article from Corey Murnaghan : Amazon Echo X10 Home Control.
From there actually there was a link to an update : UPDATED Amazon Echo X10 Home Control

The two articles (I strongly suggest to use the updated version) discuss about how to interface Alexa with a Raspberry Pi running Heyu.
I already had a server running Heyu, with the glorious Ubuntu 16.04, so I used that article as main guideline, changing things here and there and in the end, voila', everything worked just nice.

The main differences from the Corey's article were about of course the Heyu installation and setting, since I already had that done years and years ago :)
In the end I just installed the Ha-bridge and configured little bit differently, also because my server hosts some websites, so it was impossible to follow some suggestions like erase the /var/www/html directory.

I had to change also some ports, since I was already using the port 80.
At least my version of Echo/Alexa requires to use the port 80 to recognize the Ha-bridge>
In order to have Alexa recognizing the server, I had to change the UPNP IP Address, forcing to use the one of the server.
Of course I had also to modify some firewall configuration for security reasons, to make the HA system local to my network and not be accessible from outside.

But in the end, I have now a very nice and useful way to control my lights :)

Wednesday, November 16, 2016

5V Solar Power supply for Raspberry Pi - feasibility phase

Ok, here the deal.
The goal is to have a 5V solar power supply for Raspberry Pi in order to power up a project (fHelper).

Main characteristics

  • Solar charger
  • Battery
  • at least 5v 1A
  • monitoring power and shutting off nicely Raspberry before the battery is depleted
  • Push button for on/off operation (see RPOf project)

In order to achieve this goal some experimentation is necessary in order to figure out if the location where the project will be placed has enough sunlight and how to dimension the circuit.
Some assumption are made :

  • at least an average of half day of direct sunlight is present
  • the load will have an average of 350 mA (the goal will be to reduce the Raspberry Pi consumption as much as possible, however "as is" the current Raspberry Pi for the project, is stable around 350 mA)
  • The power supply is done using "off the shelf" components as much as possible.
    The only part to build is the RPOf.
This article describe the initial test.

The shopping list

Let's start with the shopping list for the project.
Let see first a block schematic of the test environment

Block schematic

A view of the test system. The battery is probably damaged and need to be substituted.
Temporarly an external data logger (USB-500) is capturing the charge/discharge cycle of the battery and a USB voltmeter is displayng the DC/DC output
On the top the Raspberry Pi with the GrovePi board and some sensors.


Here a list of components used to build the solar power supply.
The goal is to use as much as possible "ready made" circuits, so I looked at Adafruit.

DC/DC converter

This is the core of the solar power circuit and is based on the Powerboost 1000 from Adafruit.
  • convert to 5V 1A a 3,7V battery

Solar charger

The second "off the shelf" component is the solar charger.
It connects the solar panel from one side and the DC/DC to the other side providing the power to charge the battery.
Is based on the USB/DC/Solar lithium module from Adafruit.

Solar panel

From Adafruit, a 6V 2W solar panel


Initially I will use some spare batteries I have around, to determine what best battery should work for the project.
A 3.7V 6600 mAh probably will be used (from Adafruit)

Data collection

This phase is necessary in order to figure out how to dimension the solar power.
In order to collect some data a Raspberry Pi, powered separately, will collect some data.
The sensors used are based on the GrovePi system.
Here a shopping list of the needed hardware for the data logger functionality (GrovePi is also used for the final project).


In order to have some kind of mechanical support, a wooden base is holding a plexiglass where the Raspberry Pi, the solar panel and the rest of the circuits are mounted.
The mechanical base is the same used for the fHelper project (described in separated articles).



In order to use the GrovePi system of sensors a special Raspbian version is used, from Dexter industries (the company who produce the GrovePi system).
Follow the instructions from the GrovePi website in order to install the system on a Raspberry Pi.

The code to handle the data logger functionality is in python.
The idea is to collect data about the light presence (full sun, out of sun), the voltage from the solar panel and the voltage on the battery.
The goal of the data collection is to figure out some answers to these questions :

  1. how long the battery can supply the project in absence of the sun ?
  2. is the solar panel enough to charge the battery ?
  3. is the battery big enough to sustain a constant power supply ?
  4. devise an algorithm to eventually shut down the Raspberry Pi and automatically power it back when enough power is available
Stay tuned for updates

Playing with Vagrant

Vagrant is a way to handle virtual machines for development or other uses.

Here some practical notes about this tool and how to use it.


First of all your development  machine must have some program installed.
This document assumes to use a Linux box, based on Ubuntu 16.04 LTS 64 bit but is possible of course also to have Vagrant on a Windows or MacOS  machine.
The basic principles apply as well to the other environments.

It is necessary to have at least two program installed :

  • a 'provider'
    i.e. a program capable to handle the virtual machine.
    The typical choice is VirtualBox, is one of the most available VM handler and almost all the Vagrant images are supported by Virtualbox.

    A 'sudo apt-get install virtualbox' should be enough
  • Vagrant
    Of course is necessary to have Vagrant installed on the machine.

    sudo apt-get install vagrant


After installing the required programs, is possible to start to use Vagrant.

The first thing to do is to identify what operating system you want to install on the virtual machine.
The environments, operating system to be installed, are called "boxes", so you need to identify what box to install.
The question is, "where are the boxes" ?

There are some free public boxes available at the Hashicorp (the company who handle Vagrant) and is possible to set up/use other repo, public or private.
By default Vagrant is set up to use the free public space hosted by Hashicorp.

You need to create an account to do so, is free.

Let say we want to install a CentOs box, let identify the closest CentOs box in the free repo.
To do so, once logged in, select some search criteria, like what virtual environment to use (in my case Virtualbox) and the name of the distro (CentOs).

Then pick up a box that you think is the better choice.
Clicking on a box name will show detailed information or links about the box and also will show what vagrant command to use to install the box.

For example to install the first box in the list, open a terminal and execute :

vagrant init -f centos/7
vagrant up --provider virtualbox

This will create a configuration file in the terminal place (usually ~) called Vagrantfile and then the CentOS image will be downloaded and installed in VirtualBox.


At this point Virtualbox has ready a machine with CentOS (like in the example).
It is possible to start the installed machine from Virtualbox, as any installed machine, or via vagrant directly with the command vagrant up.
In this case nothing is indicating that the machine is running if not the status on virtualbox and it will be possible to access to the installed machine using the command vagrant ssh.

Usually by default any installed machine has set up a user called vagrant (password vagrant) or it can be accessed using root and the password vagrant.


There are some advantages to use Vagrant to create virtual machines.

  1. No need to keep a OS image on the local machine
  2. Easy to recreate the machine if something goes wrong
  3. Possibility to create your own machine image
The last point is the most important.
You can start to create a virtual machine using your preferred base image, then update it and install the programs you need to use, then store that image in a Vagrant server or a local one.
After that, you can recreate your virtual machine every time you need it, without the need to configure/update/install programs.
You end up to install in minutes an entire machine pre-configured for your needs.