Monday, 28 November 2016

Ultimate GNU Radio Install

I find myself installing GNU Radio quite often lately, so I felt the need to document all (most) of the steps.

I use Xubuntu because I like the simple, minimalistic feel of it and the speed! Xubuntu 16.04 doesn't seem to work well just yet and so I use 14.04 with all the updates. I also use the PyBOMBS version because it is up to date and it's easy to install new packages.

The guide here is a good starting point after installing updates, etc. I'll repeat the steps here for copy-paste reasons...

sudo apt-get update
sudo apt-get upgrade

Now for the PyBOMBS and GNU Radio...

sudo apt-get install python-pip
sudo pip install -U pip
sudo pip install pybombs

We need to set the PyBOMBS prefix. I have no interest in messing about with prefixes, so things PyBOMBS installs should appear to the system as normal programs.

sudo pybombs prefix init /usr/local -a usrlocal
sudo pybombs config default_prefix /usr/local

sudo pybombs recipes add gr-recipes git+
sudo pybombs recipes add gr-etcetera git+

We can now do the installation, but first you may notice an HTTPS error when we run PyBOMBS installs. This can be fixed as follows:

sudo pip install 'requests[security]'


sudo pybombs install uhd gnuradio

Now is a good time to sit back or go grab a coffee. It will take a few minutes to fetch and compile everything. On my old 2GHz i7 it takes over an hour and on my i7-6770 @ 4GHz it takes at least 15 minutes.

At this stage I like to do a little customization. I set the background to a nice GNU Radio logo and put a CPU and network monitor widget next to the clock. I also like to change the system highlight colour to a matching orange.

sudo ldconfig

You must run ldconfig every time PyBOMBS finishes something or odd things just won't seem to work!

Once the install is done, GNU Radio should be working. There are a few more settings to deal with to avoid warnings, etc.

sudo groupadd usrp
sudo adduser <my-login> usrp

sudo nano /etc/security/limits.conf

Add the following line to the bottom of the file:

@usrp            -       rtprio          99

I use USRP so I need the firmware packages:

sudo "/usr/local/lib/uhd/utils/"

Finally, test by typing gnuradio-companion in a terminal. Close it again. Let's install some more packages!

Note: For some reason it's not working anymore... :(

Sunday, 27 November 2016

The ESP-Live

I was doing some shopping (read: surfing Amazon) for Black Friday and I was checking out all of the home automation gear. Things have come a long way! Home automation has been a passion of mine for many years - although to date I still haven't automated my lights! I will eventually prevail... I think that with the ESP-Live (my latest attempt) I will prevail.

Many years ago, when I was still in school, I remember interfacing some LEDs to my old Pentium I box via the parallel port. I had set up a Visual Basic 5 program to write bytes to the port. I messed around with logic chips to expand the number of input and outputs I had and I even had some transistors to switch relays. Sounds pretty primitive - right? The cool thing about this prototype system was I had a pretty good voice recognition system written using the Microsoft Speech API and it could respond to quite a few commands:

"Computer, turn LED one on.", "Computer, turn LED one off.", "Computer, start Linkin Park, Parpercut.", "Computer, set volume ten.", "Computer, pause music.", "Computer, pause music!!!". And it didn't work because it couldn't hear me over the music...

Nowadays the Google and Amazon speech recognition are getting really good. I think I will work on a project to interface the speech recognition into my home automation, one day.

Back to the point. Why do I still not have a working home automation system, you ask? I have spent many years trying to develop my own custom system. I personally think that buying a system off the shelf is too easy... and no fun! There are also features that I want, that probably don't exist except in extremely high end systems (and I haven't necessarily decided on these features just yet!). I have gone through many iterations of design with different technologies, but one fact remains: the switches must be wireless so that they are easy to install and they must fit into the wall to replace my current switches.

Perhaps some day I will write a post detailing all the light switched I have half designed... and why I stopped.

What is the ESP-Live?

Arduino has pretty much taken over the hobbyist world in my opinion. It's really easy to get something up and running in no time compared to the DIY approach with the raw microcontrollers, in circuit programmers, etc. Kind of like C++ versus C#, I guess.

I usually prefer to not use something like Arduino, because it's too easy. In recent years, however, I have changed my mind. I think that since Ardunio is literally just a comprehensive C/C++ wrapper on top of existing Atmel gcc, it's not really cheating... I still want to design my own hardware - but at least now I can do that and not waste too much time on bringing it to life.

I like the ESP modules because they have a lot of documentation and are powerful and really cheap! I like what NodeMCU has done in making the ESP8266 more like an Arduino, but I still want to do C programming and not script in Lua.

The ESP-Live is an ESP-12F module, on a fairly general purpose board with all of the IO's broken out, with a USB-Mini port for programming and debugging, power supply, etc.

What's different then? 

The ESP-Live has an on board AC/DC converter so that you can connect it directly to the mains! The shields can then be things like TRAIC or MOSFET dimmers, power measurement boards, etc. I have also designed it to be as compact as possible. The final design measures a mere 30x65cm! Small enough to fit inside a 2x4 inch light switch box inside the wall.

I'll post the design files on GitHub soon.

PCB and Schematic:

A 3D rendering of the top of the PCB. The areas for the ESP module is visible on the right. To the left is the area for the power supply module and AC input.

Quark One Bootloader

In 2015 I decided to try out the ESP8266 line of WiFi modules. I did a lot of reading and I determined that I didn't like they normal way people used them. I decided that the ESP modules needed an additional microcontroller to be truly useful in terms on analog to digital conversion and other IO features.

The Quark One was born. I will write about the hardware details in another post. Suffice to say, I wanted to try out the Atmel Xmega microcontroller due to it's relatively low cost and great feature set. I also wanted everything to work with the Arduino IDE!

Typically, when people connect an ESP module to a microcontroller, they flash it separately and then integrate everything. I didn't like this way of doing things and so I hacked together and then polished a new bootloader for the Xmega which presents two separate USB devices to the computer it is connected to: the first device is the CDC Xmega bootloader, as one would expect. The second device is a CDC that passes through the chip to the ESP module! You probably guessed it by now, but I used the USB device built into the micro and then one of the hardware serial ports to interface to an ESP-01 module.

The Quark One bootloader deals with the reset signals to enable the ESP to be programmed from the Arduino IDE as if it was simply connected to a USB to Serial converter! To write code and flash the ESP, you do so in the usual way. To write code for the Xmega, I had to extend the xmega-arduino library to include the Quark One pin mapping. Otherwise, this is also standard!

To activate the bootloader I took some inspiration from the Arduino Lilypad type devices. A quick "double click" of the reset button on the edge of the Quark One puts it into bootloader mode.

Check out the source code on GitHub:

The bootloader should work on any Xmega chip that has quite a bit of bootloader flash... I used the Xmega128A4U.

Let me know what you think!

Home Assistant + Node-RED with BTRFS on Arch

After using Home Assistant for a few months and having set it up to use external MySQL databases, etc. I have decided to re-install in a rob...