Third party cookies may be stored when visiting this site. Please see the cookie information.

Home Babies & Children Gallery Information Free Software Reviews Blog

Stewart's Blog

Monkeys, megabytes, medical and more ...

(Children, computing, first aid and other ramblings ...)

Raspberry Pi robot Android app

February 26th, 2015

I created a web front end for my Raspberry Pi based robot, which works well on a desktop PC, but not quite the way I wanted on a mobile phone.

My idea was to have graphical buttons for the different directions and holding down the button will make it move in that direction and releasing it will stop the robot. Unfortunately it doesn’t work this way through a mobile phone browser. The reason it doesn’t work how I wanted to is because mobile phones treat a button held down on a web-browser in a similar way to a right mouse click on a desktop PC. As a result instead of moving the robot it would give a pop-up menu.

I did have a workaround by changing the behaviour to need a press to start and a press to stop, but it’s not quite what I wanted. I’ve been wanting to have a go at writing a mobile phone app for a while and it just so happens that it’s something I’ve been doing as part of my MSc, so I took this opportunity to create a basic app to control the robot.

Android app for controlling Raspberry Pi robot

This is the first app I’ve created that isn’t related to my academic studies and it’s fairly simple at the moment, but I think it’s great what can be produced fairly simply for Android without having to buy any commercial software to develop with.

It’s still in it’s early stages at the moment, for example there is no way to change the IP address of the robot without recompiling, but I am going to develop it further as time allows.

It’s too early to release on Google Play at the moment but if you’d like to have a go then you can download from github and then open it in Android Studio.

Raspberry Pi – Heart beat – 8×8 LED display with I2C BackPack from AdaFruit

February 5th, 2015

This is based on the AdaFruit 8×8 Bicolor LED display with I2C BackPack. It’s connected to a Raspberry Pi 2, although it’s only very simple and could be connected to any model Raspberry Pi.

After soldering the parts together (checking that the display is the right way round – with the writing near the round marker) then connect to +5v (or if using other I2C may need to use 3V3) Gnd and ports 3 and 5 for the I2C connection.

Enable I2C through the raspi-config interface

Install smbus python package

sudo apt-get install smbus

Get the AdaFruit source code:
git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git

I think put together the following code (which is only a quick hack):

#!/usr/bin/python

import time
import datetime
from Adafruit_8x8 import ColorEightByEight

grid = ColorEightByEight(address=0x70)

# This is a bicolour LED - setting the pixel to 0 is off, 2 is red, 3 is yellow.
red = 2

heart1=[0b00000000, 0b01100110, 0b10011001, 0b10000001, 0b01000010, 0b00100100, 0b00011000, 0b00000000]
heart2=[0b00000000, 0b01100110, 0b11111111, 0b11111111, 0b01111110, 0b00111100, 0b00011000, 0b00000000]

while(True):

  for y in range(0, 8):
    position = 128
    for x in range(0, 8):
      value = position & heart1[y]
      if (value > 0):
        value = red
      grid.setPixel(x, y, value )
      position = position >> 1

  time.sleep(0.5)

  for y in range(0, 8):
    position = 128
    for x in range(0, 8):
      value = position & heart2[y]
      if (value > 0):
        value = red
      grid.setPixel(x, y, value )
      position = position >> 1

  time.sleep(1)

Raspberry Pi - Heart using Adafruit 8x8 LED matrix with LED Backpack

Raspberry Pi 2 – New 1GB quad-core $35 computer

February 4th, 2015

The Raspberry Pi is a $35 computer designed to provide a platform for children to learn computer programming. The Raspberry Pi was launched in 2012 and became and immediate success, with the only problem being how to satisfy demand when initial orders exceeded everyone’s wildest dreams. Initially many were bought by adult makers rather than the children they were aimed at. Since then the Raspberry Pi has taken off in schools, clubs and with children at home. With nearly 4 million sold it’s on it’s way to become the UK biggest selling computer ever.

The Raspberry Pi has many things that make it ideal for teaching programming to children. It’s inexpensive, easy to interface with (through a GPIO connector) and includes a Debian based operating system (Raspbian) with a selection of tools so that children can start programming straight away. The one thing that has let it down is that it is was a little slow. It was still usable and for $35 is better than I ever thought you’d get for that price, but you did need to be quite patient with it.

Raspberry Pi 2 - 1GB quad-core computer

In the three years since the first Raspberry Pi it’s been through a few minor changes, first some small changes to make it work better with USB devices, then they switched production to the UK and doubled the memory to 512Mb. They created an even cheaper version (model A) and then increased the number of USB ports and the number of GPIO pins (model B+). Until now it was still based around the same single core ARM6 processor. They’ve now given the Raspberry Pi it’s biggest boost ever by launching the Raspberry Pi 2 with a new quad-core ARMv7 processor and increasing the memory further to 1GB. The previous changes were all very welcome, but this upgrade is a huge leap and makes the Raspberry Pi capable of much more.

Upgraded Raspberry Pi 2

At first look it’s hard to see any changes between the Raspberry Pi B+ and the Raspberry Pi 2. The first change is that you can actually see the processor. Previously it was hidden under the memory which was soldered directly on top of the processor. The memory chip is now on the underside of the board and provides 1GB of RAM. The rest of the Raspberry Pi is unchanged, which is the good part. If they had swapped lots of other things on the board or added any of the other features people are asking for then it would have either added more to the cost or risked breaking compatibility with the older Raspberry Pi.

There are people complaining that they didn’t add various features. Most seam to be complaining about the lack of gigabit ethernet or that they want SATA capability, but these are unlikely to be of any benefit in and educational setting which is after all the aim of the Raspberry Pi.

Raspbian

There are few changes to the Raspbian image which is the standard Linux distribution for the Raspberry Pi. I believe there is a new kernel to support the chipset, but otherwise very few changes. This may mean that there is potential for more improvements in speed on the Raspberry Pi 2 if some of the libraries are compiled for the ARM7 processor, but that would need to be done in a way that maintains compatibility with the older versions.

Speed increase

The Raspberry Pi 2 is noticeably faster. The claims are for a typical six times increase in performance which is easy to believe. Applications such as Scratch which were slow but usable are now fast and responsive. The processor indicator is also a good indicator which on the previous version of the Raspberry Pi would often be showing 100% is now showing nearer 25 to 40% even with significant applications running.

Additional software

There is nothing new installed by default, but there is now much more software available that would either not run or be too slow to be usable before. The Raspberry Pi comes with it’s own web browser based on Ephiphany which is specially tuned to get the most out of the processor on the original Raspberry Pi, but I wanted to try a more modern browser. So one of the first things I installed was Ice Weasel which is Firefox renamed by Debian (IceWeasel / IceCat compared with Firefox). Iceweasel was too slow to be usable on the earlier version of the Raspberry Pi, but zips along nicely on the Raspberry Pi 2.

IceWeasel is installed using:
sudo apt-get install iceweasel

It was a similar thing with LibreOffice which is an open source office suite comparable with MS Office. There are other lightweight office applications, but being able to run LibreOffice would be a big improvement. I installed the full LibreOffice suite
sudo apt-get install libreoffice
and then tried the Impress presentation application. It’s a little bit slower compared to running on a full PC, but it’s now fully usable.

Raspberry Pi 2 running LibreOffice Impress - presentation

This means that rather than just being a platform for learning programming the Raspberry Pi 2 can now be used as a personal computer for homework etc.

What doesn’t work?

The main thing missing in terms of software capability on the Raspberry Pi 2 and another PC is Adobe Flash. This is because Adobe has dropped support for Flash and as it’s a proprietary application it’s not possible to get the source code to compile for the Raspberry Pi. With Adobe dropping support for Flash it’s a dying technology, but unfortunately it’s still used by some educational websites such as Educational City and Bug Club which my children have to use for homework.

The new version of Scratch (version 2) also uses Flash, so that won’t run on the Raspberry Pi. Fortunately version 1.4 still works fine and has continued to see some improvements supported by the Raspberry Pi foundation.

I expect in a few years time flash will be used less and less, but for now it does mean that children may need to have access to a “normal” PC as well to be able to complete all their homework.

Ubuntu Snappy Core

It was not possible to run Ubuntu on the Raspberry Pi before as it is not available for the ARM V6 processor. Now that the Raspberry Pi 2 has an ARM 7 processor then it is now possible to run a version of Ubuntu. The normal desktop version of Ubuntu uses Unity which is slow enough on a low spec PC, so is unlikely to be usable on a Raspberry Pi, although it may be possible to get a version that uses a lightweight desktop to work. It should therefore be possible to install Lubuntu which uses the LXDE desktop environment similar to Raspbian.

One version of Ubuntu that is available is Ubuntu Snappy Core. Ubuntu Snappy Core is a development of Ubuntu designed for improved reliability required for Cloud services and in the new Ubuntu phone. There is an Internet Of Things (IOT) version of Ubuntu Snappy Core currently available on the Raspberry Pi website. There appears to be a few issues with the image at the moment as I am unable to install additional software due to a certificate key problem, but it sounds promising for the future.

Windows 10 for devices / IOT on the Raspberry Pi

Another big announcement is that Microsoft Windows 10 will be available for the Raspberry Pi 2. Now I’m not a big Windows fan (in fact I rarely use it outside of work) but if people want to run Windows then that’s their choice. It’s worth noting that this is not going to be the full desktop version of Windows 10, but is instead a light version specifically for running on devices as part of IOT. As far as the main operating system is concerned it is likely to remain as Raspbian.

Windows 10 will be provided free of charge, but only for non-commercial use. I expect that that anyone developing a commercial application that needs Windows 10 would need to purchase a license from Microsoft.

The Windows devices software currently provides wiring which is a programming language similar to that used on the Arduino. This is developed in Windows Visual Studio on a PC and then pushed to the device.

With no desktop environment on the Raspberry P I expect programming for Windows 10 is not going to be as easy for children as using Raspbian, but may be popular with existing developers that are used to developing with Microsoft Visual Studio.

Where does this leave the old version?

One of the good things about the Raspberry Pi 2 is that it’s maintained physical and software compatibility with the older versions. So it’s provided the performance improvements for those with the new Raspberry Pi, but it’s not alienated anyone running the older ones.

The original Raspberry Pi is still suitable for teaching programming and for physical computing, the new version just does this faster and adds a couple of new options. The old Raspberry Pi still works fine as a media centre and as a server and all the other things that people have been using it for. So if you’ve got an older model there is no need to get rid of it just yet, but obviously the new model is nice to have.

The model A+ is the current, smaller, cheaper version that uses less power and therefore may be a better fit for some circumstances. I expect the A+ will be upgraded to the new processor eventually, although I’m not sure if that will mean an upgrade to the memory to 1GB as the current A+ has only 256MB. It sounds like this it is unlikely to be until late 2015 before the A+ gets the upgrade though, so if you want a low power Raspberry Pi (to run on batteries) or are on a tight budget then you may still want to consider the A+ instead.

Criticism

Overall the reaction from the public seams to have been overwhelmingly positive, but there has been some criticism and some of the comments have unfortunately been quite rude or hurtful. I could go off on a tangent and describe how this sadly appears to be the way of the modern digital age where more and more people seam to think that it’s fine to throw insults when sending comments via the internet, but rather than take the bait from the trolls here’s just a few of the comments and why I think they are unjustified.

Why not add the xyz feature?
It seams that you can never please everyone and there are several people complaining that the feature they want adding has been overlooked once more. Whilst I would love to have a 200GHz hecta-core processor with 4PB of memory and a 100GB fibre network interface it would not be possible to do so at the same low price. The important thing is that the price is kept low and that they continue to meet the educational aims of the foundation. The Raspberry Pi has already proved a huge success with the maker community and whilst there are always going to be people that won’t more it’s a great achievement to get so much for such a low price.

Not available for $35 – and why it priced in dollars anyway?

The Raspberry Pi is priced in US dollars as that is how the components are sourced and it means that the price can remain steady regardless of currency fluctuations. The majority of Raspberry Pis are made in the UK (Wales in fact) and are available through suppliers in many different countries using local currency. The price excludes local tax and additional shipping charge (where applied). I bought mine for about £30 including free delivery which is excellent value for money considering what you get.

Can’t get a Pi quick enough

The Raspberry Pi has been and continues to be a victim of it’s own popularity. They are currently making 20,000 Raspberry Pis per day so although most suppliers sold out very quickly when the new version was announced there shouldn’t be too long to wait. Those of us that tried to order on the first day that the first Raspberry Pi went on sale had to wait for several months so hopefully a few days wait shouldn’t be too bad.

Anti-Microsoft comments

There have been quite a bit of criticism of the announcement that Windows 10 will be available from the Raspberry Pi. I am a fan of Linux, I like the fact it’s free and open source, I like the fact it’s developed by the community and like the choice it gives me. I do not see the need to start criticising others for choosing something different. The main operating system for the Raspberry Pi is still going to be based on Linux and if others want to install Windows (and want to pay the license fee if they develop a commercial device) then that is their choice.

But I just bought a B+ last week

The one group of critics that I do feel a little bit of sympathy for are those that have just bought an older version to find that there’s now a new version come out that’s better for the same price. Unfortunately that’s just a fact of life and I’ve been in the same position myself. Technology moves on and it’s frustrating to find that something you bought one week drops in price, or (as in this case) that a better version is now available at the same price.

There wasn’t any announcement about the new version until it was available, but that is the same as most of the industry as once a new one is announced the sales of the existing product will stop. I don’t think there is a large enough product margin to significantly discount the price of the old one so a decision would have been made about when was the best time announce availability of the new one.

One thing to remember is that the Raspberry Pi you bought last week is still just as good today as it was last week and was still excellent value for money then. It’s still a great device for learning programming on, or for use around the home. In fact I still have several of the original 256MB Model B Raspberry Pis which we use to turn our TVs into smart TVs using Kodi (formally XBMC) and at only $35 that’s a bargain.

Summary

The Raspberry Pi has just got better. I am sure that there is no other computer that has the flexibility and processing power of the new Raspberry Pi 2 and charges just $35.

If you have an older Raspberry Pi then you can continue to use that as you did before, although the speed improvement on the new model is impressive.

This is all good news as far as I’m concerned and I’ll be looking forward to the even faster Raspberry Pi 3 in a few years time [here’s hoping], but this provides an amazing computer at an unbelievably low price.

I’ve got some ideas of my own, but mostly I’m look forward to seeing what school children manage to create with the new faster processor on the Raspberry Pi 2.

Adding a home disk to virtualbox virtual machine – Ubuntu VM

January 26th, 2015

Introduction

Recently I ran out of space when using a Virtualbox virtual machine. Normally I use a dynamic disk that allows resizing (typically setting it to be much larger than I expect to use), but in this case I am using a virtual disk provided for me. It’s based on VMDK and Virtualbox does not have support for resizing a VMDK disk.

A lot of the space was used in the home directory (in my case this was different versions of Android software development kit) I added a second virtual drive and migrated the home partition over to the new drive, similar to how I’ve done it with real physical disks on servers before.

I have updated this after some more research into how VirtualBox handles drive allocations.

Warning !

First backup / clone your vm if not already done so.
WARNING – if run incorrectly you could lose all your data. the drive letters mentioned below may not match your virtual machine in which you will need to change the drive reference in the commands or you will lose data. Do NOT copy and paste the commands I have used unless you are 100% sure that you have the same setup as mine.

If you are using Linux as the host computer for the virtual machine then make sure you enter the commands on the appropriate system. Running the cfdisk / mkfs commands outside of the virtual machine could damage your host computer.

Adding the virtual disk drive

Create a second disk drive through the virtual machine manager

Choose a dynamically allocated disk and choose a large size – it will only use the size required, but can then expand so hopefully you won’t need to go through this again. I created one approximately 30GB in size.

I believe the name of the disk drive determines the order initial order in which it is listed and hence the drive letter allocated. It does not matter as we will be using a unique non-changing reference for each drive, but this will determine the exact commands that need to be run. Choosing a later filename (alphabetical) may avoid having to install grub onto the new disk (the last step).

You can also change the drive slot allocation by click on the drive in question and looking at the attributes shown to the right. A lower SATA port number will result in a lower drive allocation (eg. SATA 0 is normally /dev/sda – SATA 1 is normally /dev/sdb).

Virtual machine adding disk VirtualBox virtual machine manager

Start the virtual machine – boot using the existing drive

Depending upon how the disk has been attached it may complain about not being a bootable drive. You can either go back to the settings and change the drive to a higher slot location (eg. SATA 1 instead of SATA 0) or reboot and press F12 to boot from the second hard disk. We can fix this later.

Partition and format the new drive

Assuming that /etc/fstab uses the UUID (blkid command) of the disk drive then it should not matter if the disk allocation has changed for the drive.

From a terminal run df to determine the drive used for your root hard disk

Virtual machine adding disk - df show existing file systems

In this case it’s at /dev/sdb1 and so we need to make sure we don’t do anything to drive sdb as that’s our main operating system and current home directory. This may be different on your computer – MAKE SURE YOU CHECK!

run
ls /dev/sd*
and look what other drives exist. The physical drives are the ones without a digit on the end, which on my system are sda and sdb (sdb is the one that’s in use and so sda must be our new disk drive).

Partition the drive using the following command making sure that you use the correct drive.
cfdisk /dev/sda

Partition second hard disk for virtualbox vm image

Check that there are no partitions already defined and that the size in the top right matches the size of the drive you created. If not STOP!

Use NEW to create a new partition – accept the defaults of primary and use the entire disk size.

Choose WRITE and then QUIT.

You will now have a new partition with the device name previously but with a 1 on the end. In my case /dev/sda1

You can now format it as a Linux (ext4) partition using

sudo mkfs.ext4 /dev/sda1

MAKE SURE YOU ARE RUNNING THIS AGAINST THE CORRECT PARTITION. This will destroy all data on the partition and will NOT ask for confirmation before formatting the drive. Run a df again first to make sure and don’t use a drive if it’s listed.

Copy the data from the home directory

After formatting the drive it can be mounted to a temporary mount point

sudo mkdir /mnt/home
sudo mount /dev/sda1 /mnt/home

Check that it’s mounted correctly
ls /mnt/home
you should just see the one file called lost+found

Assuming you are not using an encrypted home partition then run the following:

sudo rsync -aXS /home/. /mnt/home/.

You may get a warning about not being able to copy .gvfs – you can ignore this warning.
You may also get a warning that some files/attrs were not transferred.

If you want to check that the copy has worked correctly then run
sudo diff -r /home /mnt/home

Note you will see the following differences which are all OK
lost+found (only in new copy)
.gvfs (only in old copy – not required)
Plus any files on the home directory that may have changed since the rsync (eg. .lesshst on my computer)
A list of about a dozen differences is normal, if you see some of your documents in the list of differences then the rsync may not have completed properly.

Update fstab and remount the drive

Now add the new drive to /etc/fstab. You need to add the drive using the UUID which is found using

blkid /dev/sda1

The entry should then be added to /etc/fstab in the format
UUID= /home ext4 none 0 0

as shown below

Adding second virtual hard disk for virtualbox vm image /etc/fstab

Now rename the current folder and create a mount point for the drive

cd /
sudo mv /home /home.old
sudo mkdir /home

Now run
sudo mount -a

You should find that the drive is mounted in the new location.

Whilst a reboot is not required then I think it’s a good idea to do one at this point to make sure everything is working, before removing the old home directory.

Grub setup

The virtual machine will attempt to boot from the first disk. If the new disk is earlier in the drive list than the main disk then it will try and boot that instead.

You should be able to change this by changing the drive slot allocation in the VirtualBox setings, but you can on a temporary basis hitting F12 each time you boot the VM.

If you have created a disk that is appearing earlier in the system (and have to use F12 to boot the system) then you can install Grub onto the new disk image so that it can boot from either drive (it will still look for the operating system on the original disk).

To install grub to the new drive

sudo grub-install /dev/sda
sudo update-grub

Rebooting the virtual machine should now boot straight into the virtual machine.

Summary

This is one way of increasing the storage on a virtual machine by adding a second virtual disk drive. There are other ways of achieving this (eg. cloning the disk into a different disk drive), this one has the advantage of creating a different virtual home drive which could be useful if you want to access the drive in another virtual machine image.

An alternative is to clone the existing drive into a larger drive. You can then create another partition on the drive – or if you want to be able to increase the existing partition, it is possible using gparted as long as the drive is not mounted. This may mean having to attach your disk drive to another virtual machine.

Energenie infrared socket and Raspberry Pi infrared

January 22nd, 2015


I have already posted about the Energenie wireless remote control sockets. I’ve now had chance to look through one of their other products – which is an infrared remote control socket. This is a power saving socket allowing a TV and associated equipment to be fully powered off from the mains socket using the normal TV remote. I have seen the sockets before and wondered whether they were actually that easy to use. In particular I wasn’t sure how it would be possible to use the same remote control to control both the TV and the power socket. The way it does work is that there is a 10 second delay between the socket being powered on and being able to power it off again (giving time to turn on the TV without inadvertently turning the power back off) and a delay of 10 seconds after the power off is pressed before it cuts power (allowing the TV to shutdown properly). This works great with my bedroom TV setup.

In my bedroom I have a TV and a Raspberry Pi running OSMC with Kodi (formally Raspbmc with XBMC). As standard it is not possible to fully power these off using the remote control, so before I used the Energenie infrared socket these were left powered on after use with the TV often being left in standby when not required. I have now connected these to the Energenie Infrared socket using an extension lead. To power on the TV I use two presses of the on button on the TV remote which powers on the socket and then the TV. At this point power is applied to the Raspberry Pi so that powers on as well. To then shutdown I first choose shutdown from the Kodi menu so that the Raspberry Pi shuts down cleanly then press the power button which turns off the TV and then 10 seconds later the power is turned off at the socket.

Remote control using the Energenie Infrared remote control board

As well as making a socket, Energenie have also released a Raspberry Pi add-on that provides a way to receive and send infrared signals. The circuit is fairly simple and details are provided so you could make one yourself, but the Energenie board provides this in a pre-built board (no soldering required) which can be plugged in to the top of the Raspberry Pi.

Setup isn’t quite as straight forward as the wireless ones as you need to lookup your infrared remote codes, or enter learn mode to teach LIRC about the remote control. It’s fairly easy for most remote controls, although it doesn’t work with some media centre remote controls (including these). I believe this is because a kernel module is required which is not included in the standard Raspbian install, I expect this is required to enable the “mouse” support from the remote control. The IR transmitter also needs to be in line-of-site with the sensor for the power socket (fortunately there is a long lead provided to the sensor).

It does however open up a whole world of other opportunities and I will be writing about at least one other use in future.

Buying the infrared socket and infrared Raspberry Pi controller board

The infrared socket has been available for a while and is available from a number of suppliers. At the time of writing the infrared controller board is a new item and is only available from a limited number of suppliers. Below are some of the sources I found.

The Energenie infrared remote socket is available from Amazon.co.uk or Energenie4U. You may also find it at some electrical or diy stores.

The Energenie IR controller board is available from cpc.farnell.com. Before buying do check whether it’s a pi-mote (wireless) or a infrared board for the Raspberry Pi to ensure you purchase the appropriate board.

Summary

I am impressed with the Infrared Remote Controlled socket. It provides an easy way power off a TV and accompanying Raspberry Pi, without leaving it on standby and without needing to get out of bed to do so. The Raspberry Pi infrared board also allows this to be controlled using a computer or could be used for control of other infrared devices.

If you are just wanting to control a power supply using the Raspberry Pi then the wireless sockets are easier to use and don’t required line-of-sight, but if you want to be able to use it with a standard TV remote control then this works well.

This review is based on an evaluation unit provided by Energenie.

Git – Version Control that’s addictive

January 20th, 2015

Git is a version control system. A way of keeping regular backups of files which is particularly useful for creating computer source code.

I’ve used other version control systems before (CVS and Subversion) and other tools that provide an element of version control (eg. Dropbox), but so far I’ve only really used them when I needed to for specific software projects. Elsewhere I’ve been manually creating backups as required, which includes the code and data files used in my websites. I first starting using git almost 2 years ago and continued to use it in the same way as I did before. I’ve since learned more about Git and my use of version control has now completely changed.

GitHub profile - Stewart Watkiss / PenguinTutor

I had picked up the basics of git through some projects I’ve been working on and I started using it for my own projects, but just by having an account on github and pushing my open source project code there. I had read up on how to use git, but was just using it in a similar way to how I used the other version control systems before. I am now studying for an MSc in Computer Science with Georgia Tech and my current class on Software Development Process (CS 6300) includes git as one of the “tools of the trade”.

As well as the course video I have watched a Udacity course. Note that Udacity also provide the platform for my degree course which is where I found this course.

Udacity course – How to Use Git and GitHub

Simple personal git repository

GitHub is the main provider of git repositories and is free for open source projects. It does support private repositories, but there is a charge for this. The cost is reasonable and it provides the reassurance of a professional run server but I just wanted something that I could run on my own server. It is possible to install a full blown git server using GitLab, but for a basic repository it’s possible to create a basic server just using ssh – which I already had installed.

I created a git user with login restricted to git shell (/usr/bin/git-shell) and copied my public key for my other computers to /home/git/.ssh/authorized_keys

I then created directories for each of the repositories and initialized them as git repositories using

git init --bare

and I could then push and pull to the repository.

Note that as I’d disabled login as git I switched to the git user using
sudo -su git

I’ve used this for maintaining the files used for my websites.

Customization

These are some of the customizations I have done.

git config –global user.name “User Name”
git config –global user.email name@example.com
git config –global core.editor “vim”
git config –global push.default upstream
git config –global merge.conflictstyle diff3
git config –global color.ui true

Download completion
wget https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
wget https://github.com/git/git/raw/master/contrib/completion/git-prompt.sh

In .bashrc
I added the entries

source ~/git-completion.bash
green=”\[\033[0;32m\]”
blue=”\[\033[0;34m\]”
purple=”\[\033[0;35m\]”
reset=”\[\033[0m\]”
source ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
export PS1=”$purple\u$green\$(__git_ps1)$blue \W $ $reset”

More information

There is lots more information available on Git. Here are a few I’ve found useful.

Changing from RaspBMC to OSMC – static IP address and remote connection

January 5th, 2015

I’ve been running XBMC using RaspBMC on a Raspberry Pi for some time. I’ve digitised my music and videos and this allows me to watch them on various TVs around the home accessing from a central server PC. Recently the XBMC project has now renamed itself as Kodi to reflect that it has changed from it’s original idea as a X-Box Media Centre. RaspBMC is going through a similar transition rebranding itself as OSMC (Open Source Media Centre) which will also see other platforms supported in future.

OSMC Kodi - running on a Raspberry Pi

As I write the initial version of OSMC is in alpha, but there have been many performance improvements that I wanted to try it out before waiting for the final version. Whilst I have RaspBMC in my lounge as well it is only the one in my bedroom that I have upgraded so far. I have only just installed it, so have not yet been able to put it through a rigorous test, but so far I am very impressed with the performance improvements. The interface is more responsive and fast-forward and rewind inside a video work much better. When I upgraded I did take the opportunity to switch to a faster SD card, but I believe the majority of the improvements are down to changes in the way that Linux is setup and configured and the performance improvements in the latest version of Kodi. I am still running on the same Raspberry Pi as before with only 256Mb of memory (an old model B), although the recommended configuration is a Raspberry Pi B / B+ with 512Mb of memory. There are however a few things missing from the old version including a way to configure a different network configuration which I’ve provided some details of below.

Easy installation

Raspbmc is already well known for it’s simple configuration and install procedure, but that has been made even easier for OSMC with an automatic installer which provides an application that can download and install the image onto an SD Card. The installer is available for Windows, OSX and Linux. The installer does provide an opportunity to configure the network interfaces manually at this point, although I’ve instead provided instructions to do this manually below.

Once the image is copied to the SD card it’s a case of putting that into the Raspberry Pi and then waiting patiently for a few minutes whilst it completes the install. After a reboot it looks similar to the old XBMC on Raspbmc, but it says Kodi in the top left.

No Operating System Configuration tool

One of the good features of Raspbmc was the RaspBMC configuration tool which provided a way to configure OS specific features through the TV interface. This is no longer available in OSMC or at least not in the alpha version that I tried. During the install I had let the installer use the wired ethernet connection using default dhcp configuration, but later decided to change it to a fixed IP address so that I could use my mobile phone as remote control. This meant logging in to the Raspberry Pi using ssh and then manually configuring the network connection.

Logging in

The System information page provides the IP address given by the dhcp server so I could login using ssh. The default login details for OSMC are provided below.
username: osmc
password: osmc

First thing I noticed as a “hardcore vi user” is that the choice of text editor is limited. This is one of the very few Linux systems where vi is not installed. You can of course install it yourself, but I just decided to use nano which is installed.

Configuring a static IP address for OSMC

The standard place on Linux for the network configuration is /etc/network/interfaces , but OSMC uses connman which is a lightweight network controller designed for embedded devices. Connman uses different files to the traditional Linux network configuration files. To define a static IP address one should create a config file in the /var/lib/connman directory with a filename ending with .config.

In my case I created a file: /var/lib/connman/ethernet.config

[service_ethernet]
Type = ethernet
IPv4 = 192.168.0.12/255.255.255.0/192.168.0.1
Nameservers = 8.8.8.8

This uses my local network settings (IP address/subnet mask/default gateway) and I’ve set the dns entry to one of Googles public DNS servers.
If you need something a bit more advanced (perhaps wifi with encryption) then more examples are available in the config-format.txt file on git.

I then rebooted the Raspberry Pi and it came up with the new IP address (the changes can be applied dynamically, but I prefer to reboot whenever making network changes to make sure that they come up correctly at start-up).

Summary

Whilst OSMC is still in alpha it appears to work well with my setup (wired ethernet and IR remote control). The lack of system configuration program is a bit frustrating (hopefully something similar will be added in a future release), but manual IP configuration is still available for those willing to edit configuration files through ssh.

Installing a MyPiFi LCD onto a Raspberry Pi in a Pimoroni Pibow case

December 10th, 2014

Having already done some work with LCD displays on the Arduino I had been looking for a project to use one with the Raspberry Pi. Wiring this up was a bit messy until the MyPiFi LCD display board came along. The problem I then had was that I couldn’t fit the MyPiFi LCD onto the Raspberry Pi when it was in a case and as a result the LCD was in a vulnerable position.

I decided to do some hacking on an existing case and this is what I came up with:

MyPiFi LCD display mounted on a Raspberry Pi installed in a Pimoroni Pibow case

This is based on the original PiBow for the Raspberry Pi model B, although there is actually a Raspberry Pi model A inside the case.

The LCD display is not the one I purchased with the MyPiFi LCD module. I originally purchased a 4×20 display which I decided was too big for this particular project. I therefore swapped it for a SparcFun 2×16 display – which is similar to the 2×16 display provided as part of the Kickstarter.

You can ignore the cables coming out of the top for now (all will be revealed about the mysterious sensor in due course). This is a Pimoroni Pibow Case with some alterations made to the top layer.

If you want to follow this yourself then you should be aware that this involves permanently damaging the top layer of the Pibow case. If you’d like to use the case for something else afterwards you can buy a replacement Pibow top layer from ModMyPi. Similar modifications can be made to the Pibow B+ case, but I believe that it should fit the B+ Pibow Coupe with less alterations (not tested).

The first thing is that there is no slot for the GPIO connector (there is for a cable, but not for a board to be mounted directly on top). The distance between the GPIO connector also meant that I needed to remove some of the top layer so that the PCB could mount where the top layer normally is. I therefore decided to saw off the corner of the top layer of the Pibow case to the same size as the MyPiFi LCD display. I did this by placing the MyPiFi LCD board onto the top layer and drawing around it then cutting with a small hacksaw. Then filed it down to make it a snug fit and smooth the edges.

With the PCB mounted the LCD display is still loose so needed to be secured with PCB mounts. I fitted the top layer and PCB on and marked holes to drill two holes to connect PCB mounts to hold the LCD display on the right hand side. I have also included a PCB stand on the bottom left, but it is not connected to the PiBow. I used M2.5 nylon screws and nuts to hold them in place.

MyPiFi LCD display mounted on a Raspberry Pi installed in a Pimoroni Pibow case - pcb mounts

More details of the sensor and software will be added in future.

Father Christmas at Creaky Cauldron, Magic Alley, Stratford-Upon-Avon

December 7th, 2014

One bricked phone and lots of reboots – I finally have Android Lollipop on my Nexus 4

November 28th, 2014

I have been a fan of Android since I had my first mobile phone. Since Gingerbread I’ve managed to have every new version (although still running an older version on some of my devices) and it just keeps getting better. So I was very excited when I heard that the latest version Lollipop was available for my Nexus 4.

Android Lollipop

I was notified that the update was available. I checked on the requirements for the update (min 500Mb space) and made sure my phone was ready to take the upgrade. I applied the update and then disaster struck. The install appeared to go well until the “Installing system update…” screen. The bar moved across showing the progress as the update was installed, but instead of booting into the new operating system it rebooted back onto the “Installing system update…” screen.

I checked on the forums and I was not the first to have this problem. The suggested solution was to go into recovery mode, clear the cache and then try booting again. Worst case I should have been able to do a factory reset and then try the install again; or at least I though that was the worst case…

The problem is that whilst I could get to the bootloader I was not able to get into recovery mode. This appears to be a rare thing to happen, but there are certainly others that also reported the same problem.

I phoned Google (the phone was purchased directly from them through the Play store) and to their credit they sent me a replacement phone. It was their update that caused the problem with my phone in the first place, but the phone was originally purchased about 2 years ago, and I’d already had a replacement due to a faulty touch screen about 18 months ago. So whilst I think it’s only fair that they did replace the phone I know of other suppliers that are not so helpful.

The new phone arrived the next day. It’s a refurbished phone, but apart from the lack of packaging it looks every bit as good as a new one. The problem is that the Nexus 4 is now quite an old phone and it came pre-installed with Android 4.2.2. I logged in to the new phone and it came up with an upgrade available to 4.3 Jelly bean. This installed fine, but then the next install to Android 4.4 (KitKat) wouldn’t install. It downloaded and verified the install, but then when I clicked “Reboot to install” it counted down to “installing now”, but then didn’t actually reboot. I tried rebooting, checking for new updates but it just refused to install the update. I even tried a sideload from a PC (using both the next incremental update and a jump to the latest version), but all of these failed due to a verification failed error.

So last resort I thought – start again and did a factory reset. I thought that the factory reset would take it back to the initial Android image (ie. 4.2.2), but in fact it reset it to factory settings to the last successful image which was 4.3. At least this meant that I had kept my last installed image (even if I did lose all my data again). This was good as this was not going to be the last time I performed a factory reset.
I then successfully upgraded to Android 4.3.3, but the update to Android 4.4.4 failed. Aftering trying to get the install to work I then did another reset to factory state (which kept it at Android 4.3.3) and was then able to upgrade to Android 4.4.4. Finally I was able to update to Android 5 (Lollipop), but first following the advise of the Google help desk (and the forums) this time I did a cache reset first. The cache reset is accessed through the bootloader and wipes the cache partition, without deleting any data. I then tried the update for Lollipop, Android version 5. After a bit of nervous waiting whilst it went through the update the phone booted into Lollipop and finally my upgrade is complete.

I don’t think my experience is particularly common. My wife has a similar Nexus 4 (although she has the 8GB model whilst mine is the 16GB model) and her upgrade worked first time without any problems. There are some other people reporting similar problems, but I think we are in the unfortunate minority. The good thing is that Google were helpful in sending me a replacement phone and getting me back up and running again.

Android 5 looks great. Was it worth the hassle of the upgrade?
I don’t think that the new version of Android has any killer must have features, but as someone that loves technology it’s great to have the latest version of Android.


Also see QI Wireless charger for Nexus phone

Twitter Status - follow stewartwatkiss


UK days out, children and holiday information is also available on the Days Out Diary web site
Linux, LPI and the Quiz / Test Program posts are also available on the Penguin Tutor website
First Aid Information, first aid games and first aid practice test / quiz entries are also available on the First Aid Quiz Web site