Raspberry Pi Rides Again

This blog originally started in  June 2012 when Raspberry Pi was new – I wanted to find out what could be done with this wee computer, that cost only about £25.

The site’s header image shows a close up view and the image below gives a better idea of its actual size, with respect to my desk top, screen, and telephone.

The blog was initially quite active as I tried out various ways of using the Pi, beginning of course with hosting a LAMP (Linux Apache MySQL PHP) website running the WordPress Content Management System.

That works quite well and if you are browsing this page then it continues to do so – it is coming, live, from the Raspberry Pi on my desk.

Eventually I posted less frequently because I had tried most of what I wanted to do and actually I prefer my regular desk-side computer, which also runs Linux, for my day to day computer use.  But the Pi was ‘always on’ and it consumes very little power so I just left it to it.

Recently though I noticed a serious failure had occurred, not in the Raspberry Pi hardware but in a USB stick onto which I had migrated the website database – to save space on the Pi’s SD card and for easy sharing with other web sites.  I didn’t have a decent backup because the whole project was just for fun – so most of the old blog has been wiped out  🙁 .

Ironically that catastrophe has re-kindled my interest and I have resurrected the web site by installing a brand new Raspbian operating system, complete with its PIXEL desktop, to replace the previous Arch Linux one – and starting again.

In the next few posts I will re-trace a few of my previous Raspberry Pi steps, and maybe make a few new ones?

Posted in rpi | Comments Off on Raspberry Pi Rides Again

Raspberry Pi + Debian = Raspbian

A computer’s operating system is the critical layer of software between its hardware components (processor, memory, disks etc) and the application programs which make it so useful to its users.

In the 1960s an archetypal operating system was developed at AT&T’s Bell Labs, it’s name is Unix.  Although it was very successful for major organisations and research projects, the advent of personal computers (initially almost exclusively the IBM PC) was very successfully exploited by Microsoft with their new Windows operating system.

Unix had a WIMP (Windows, Icons, Mice and Pointers) Graphic User Interface (GUI)  too, it is named X-Windows.  But Apple and Microsoft became more popular with personal computer users.

The Linux operating system began in 1991 when Linus Torvalds  set out to create a new, free, operating system.  It does not re-use Unix code but it adopts many Unix like features, and importantly it is usually classified as Free and Open-Source Software (FOSS).  As such it can be adopted and developed by others providing the resulting product remains FOSS, so many ‘flavours’ of Linux are currently available.  One of the best is Debian (named from it founders, Deb and Ian !).  Debian has been further adopted and adapted for the Raspberry Pi as Raspbian , although it is not the only version of Linux which will run on it.

My favourite Linux operating system is Arch Linux for various geeky reasons but to resurrect my Rasperry Pi I chose to go with the latest Raspbian offering.

The image above show its bright new PIXEL desktop, as displayed on my regular deskside computer screen via VNC Viewer by RealVNC. VNC is Virtual Network Computing (VNC) , a desktop sharing system that allows me to control the Raspberry PI with my regular mouse and keyboard while it throws its desktop graphics into a window on my regular screen via X-Windows.

VNC is a great boon for Raspberry Pi users because we don’t have to attach a screen via HDMI or a keyboard and mouse via USB.

Here are some details, via screenfetch.


Posted in rpi | Comments Off on Raspberry Pi + Debian = Raspbian

POV-Ray on Raspberry Pi

When I was first experimenting with Raspberry Pi I was also interested in POV-Ray (Persistence Of Vision – Raytracer) graphics and inspired by the Lohmüllers’ great site at http://www.f-lohmueller.de/ . I had some fun on my regular, deskside computer running Arch Linux and I was just intrigued to see if the Raspberry Pi could do it too.  It could, albeit a bit more slowly.  Then, the Pi was running Arch Linux – now it’s running Raspbian, but it can still do povray :

Posted in rpi | Comments Off on POV-Ray on Raspberry Pi

Turtle Graphics on Raspberry Pi

Given that The Raspberry Pi was originally created to promote and teach basic computer science in schools and colleges around the UK I was reminded of my playing about with Logo, for my son in the 1980s.  Logo was intended as an educational programming language, and became most widely known for the introduction of Turtle Graphics  which introduces basic programming logic in a fun way by getting kids to instruct a ‘turtle’ to move forward and rotate in incremental steps, leaving a trail in its wake which can be coloured or rendered in different widths as it goes.  A simple idea but it can lead to some super results.  Since the 1980s things have moved on of course and Logo is not so well known now.  However there is a modern variant, Python Turtle, which I tried out on Raspberry Pi.

Actually, I may be a bit cynical but I have reservations about Raspberry Pi as a vehicle for teaching kids to become programmers.  It may be small and fairly cheap but you can get a better computer for not much more than the price of a good screen, which you might want for the Pi anyway.

It’s best application I think is as the ‘smart’ component of a school project, photographing birds at nesting boxes say, or controlling time-lapse photography.  A great project might be to design and build a Turtle Graphics ‘turtle’,  a simple vehicle controlled by stepper motors that could go forward and rotate on the spot – and controlled by a wire or reading its instructions from a program saved onto the Pi’s SD card.

Posted in rpi | Comments Off on Turtle Graphics on Raspberry Pi

StarViewer on Raspberry Pi

This project started out as a Java exercise in 2010 when I was doing a Glasgow University evening class on Introduction to Astronomy.
hygxyz.csv is a free machine-readable catalogue of stars. I downloaded it and inserted the data into my PostGIS database,  a spatially enabled version of the Postgres database server (both free as well). That installs records for 119,617 stars, with most of the important parameters including RA and Dec coordinates (like latitude and longitude on the celestial sphere). Now I can analyse the data with any database query I choose e.g. SELECT * FROM Star WHERE DEC > 34 to find the stars which are circumpolar at Glasgow.

A spatially enabled database is no fun unless you can make maps from its content , so I installed OpenJUMP (an open source Geographic Information System, which can connect to PostGIS). Then I could use PostGIS to make stereographic projections of selected parts of the celestial sphere, and  OpenJUMP to inspect the result. After some considerable effort I achieved what Ptolemy worked out about 2000 years ago.

That led to me developing my own Java program (named StarViewer) using Java’s Swing widget toolkit for the Graphic User Interface(GUI), which is portable to any computer which can support the Java Runtime Environment (JRE).  That includes Raspberry Pi of course, so I just copied the program’s .jar file to the Pi to try it out, after installing PostgreSQL and loading my stardb database from a  dump (backup file).  I was surprised how easy it was and it worked quite well.

…. time passed and I began experimenting with Python, the new kid on the object oriented programming block.  I developed a Python version of StarViewer using Python’s Tkinter widget toolkit for the GUI.  That was portable to Raspberry Pi too of course, and I have recently resurrected it on my new Raspbian system:

Posted in rpi | Comments Off on StarViewer on Raspberry Pi

WSGI to the stars

WSGI is a specification for simple and universal interface between web servers and web applications for Python programming language.  That allows us to use python .py program files code in a similar way to .php files – to access a server-side databse and generate .html pages for the web server to provide to users running a WWW browser on their personal computer.

And it’s exactly what I needed to publish my StarViewer – just for fun of course.  I struggled to do this on the Raspberry Pi years ago, but eventually I succeeded.  I struggled again to resurrect it because Apache’ WSGI offering has changed quite a lot and evolved into mod_wsgi-express, which is good in the end but quite a step learning curve.

For the present state, coming to you from the very same Raspberry Pi on my desk as is presently serving the WordPress blog that you are reading now.  It’s not very fast, but not bad for a little Pi running 2 databases (MySQL for WordPress and PostrgreSQL for stardb), and a web Server (Apache), and Python simultaneously.



which should deliver something which looks like this – but is interactive and live (albeit quite slow):



Posted in rpi | Comments Off on WSGI to the stars

Raspberry Pi does barometry

I am a software guy really, I usually stick to programming and database design, and so far I had just tried my Raspberry Pi as a simple wee platform for running Raspbian Linux.  And it has proved pretty good, albeit not quite so good as a much bigger regular desktop PC.

So I was quite keen to try out some stuff with the General Purpose Input/outputs, — better known as GPIO pins — using it to interface external hardware directly rather than via one of the USB ports (see Interfacing hardware with the Raspberry Pi for example).

I decided to have a go at a data logger for atmospheric pressure and temperature so I bought: The BMP180 precision sensor from Bosch is the best low-cost sensing solution for measuring barometric pressure and temperature. – not too expensive, about £10.

And a simple Humble Pi – Raspberry Pi Breakout Board to help me connect it to the Pi’s GPIO pins.

Then I wrote a little python program, barometer.py :

# coding: UTF-8
from Adafruit_BMP085 import BMP085
import time
import datetime
format = '%Y-%m-%d %H:%M'
# Initialise the BMP085 and use STANDARD mode (default value)
bmp = BMP085(0x77)
header =  "timestamp\ttemperature(°C)\tpressure(hPa)\n"
outfile = open('rpimet.log', 'a')
    while True:
        temp = bmp.readTemperature()
        pressure = bmp.readPressure()
        tnow = datetime.datetime.now().strftime(format)
        record = "%s\t%.2f\t%.2f\n" % (tnow,temp, (pressure / 100.0))
    print '\nhave a nice day\n'

which writes rpimet.log :

timestamp    temperature(°C)    pressure(hPa)
2014-02-08 20:25    32.70    951.73
2014-02-08 20:41    33.20    951.77
2014-02-08 20:56    32.50    951.81
2014-02-08 21:11    32.50    952.01
2014-02-08 21:26    32.40    952.08
2014-02-08 21:41    32.30    952.19
2014-02-08 21:56    32.20    952.40
2014-02-08 22:11    32.10    952.64

which we load into a database for Jasper Reports to produce this report :

Can’t do that with my regular desktop computer !  The Pi’s so small I could even send it up on a balloon and use barometry.py as an altimeter!

Posted in Uncategorised | Comments Off on Raspberry Pi does barometry

Raspberry Pi does photography

I had been trying to do some simple star-trail photography from the back garden (this was before I got my first telescope…).  That requires a very long exposure and my Panasonic Lumix DMC-FZ20 camera was not up to it.  The only way was to use the longest available exposure setting (8s) and repeatedly click the button up and down by hand.  Or to get an intervalometer and control the camera via a remote release cable.  I got a cheap one, but it didn’t work  🙁  .

I decided to have a go with RPi, and I found this at www.doc-diy.net :

Most DSLR and SLR cameras can be triggered remotely using a release cable. Unfortunately the connectors used for the external release have rather exotic shapes. Below you will find the pinouts for the common camera types.

Panasonic/Lumix goes an unusual way and uses just one wire to control the focus and the shutter. As shown in the picture above, only the shaft and the first ring are used. Resistors are used to choose the function.

Given that information I was able to get a few components and wire up a wee circuit board as required, then connect it to the Pi via a PiFace Digital interface.  The PiFace interface includes two RPi controlled relays which act as the switches in the circuit diagram above.  I wrote a small python program to open the shutter for 8 seconds every  20s and strapped my wee circuit board handywork to RPi’s side, see below.  The whole package is still quite small and easily fits in the outside pocket of my regular camera bag.

I used a great, free application called StarTrails to stack the images and this is the result from my first attempt.  The orange sky is due to Glasgow’s light pollution of course.  The brightest trail is Mars I think, and the dashed diagonal is a passing plane (which appeared in just a few images)!

Shortly after this I got more seriously into astronomy (see my Stargazer’s Blog) and the RPi was retired.

Posted in rpi | Comments Off on Raspberry Pi does photography