Sunday, May 3, 2015

Installing the OS and loading software


***Please forgive the quality of the pictures here. They are iPhone photos of the screen, not screenshots.***


First attempts to download the RPI operating system on to the SD card failed also as Windows wasn't even showing the card to the DiscImager.

I went back to the installer and downloaded the tool from the ‘SD Association’.- no fuss whatsoever.Get it from https://www.sdcard.org/downloads/formatter_4/eula_windows/ then choose ‘SD Formatter for Windows Download’

Using the NOOBS installer

NOOBS stands for New Out of Box Software. It allows you to install the distribution of your choice even if you have little to no computing or Linux experience.
It’s just a simple drag and drop onto the SD card window, after which the new card now containing the latest Raspbian system is ejected and plugged into the Raspberry Pi.
More about Debian here: https://www.debian.org/intro/about
IMG_5810.JPG
IMG_5811.JPG
IMG_5812.JPG
IMG_5813.JPG
That all went extremely smoothly and after logging in with the username ‘pi’ and password ‘raspberry', simply typing 'Startx' produced the start screen.
IMG_5814.JPG

LInux commands

Using the command line is not usually my preferred method of controlling a computer and I’m fairly new to Linux, so I found it useful  to have a Linux reference guide to hand.

Setting up wifi

mini-wifi-dongle.JPG
The mini WiFi Dongle
As this is my third RPI, I didn’t find it too difficult to set up the wifi, using a mini usb dongle, but I’ll include a link to a guide here:

It's strangely satisfying to see the Google page after struggling to setup the WiFi
IMG_5816.JPG

Downloading Pygame

I’m using ‘Pygame’ the Python game program, to design and build a dynamic user interface. In other words a full screen window with touch screen control, that will display content including the clock face, weather radar maps, and many other media types. (As I don’t have a touch screen yet, I’ll just set it up to work on any monitor. For now, I am using a 19” monitor through the HDMI output of the PI) Here is the code I used to install it.

$ sudo apt-get install mercurial
$ hg clone https://bitbucket.org/pygame/pygame
$ cd pygame

$ sudo apt-get install libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
$ sudo apt-get install libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev
$ sudo apt-get install python3-dev python3-numpy

$ python3 setup.py build
$ sudo python3 setup.py install

The instructions that I followed are here:

Don't ‘select all’ as it suggests, but do it line by line pressing return between copy and paste into terminal (right click, choose copy) ‘ctrl/shift v' to paste then enter. It will ask if you want to continue ‘y/n’, wait for prompt each time, it may take a while. It' s not finished if there's a white square. When it is done, it will go back to the command prompt.

I will be using Google docs in the Google cloud to write or copy/paste all the Python code. That way I can easily create what I need on my laptop or desktop computer or even in breaks at work, then open it in a web browser on the RPI. From there I can just use it as reference or copy/paste into the Python terminal window.

Downloading Pywapi

Python itself is included in the distribution, but I wanted to download the ‘Pywapi’ Python weather API to deliver the live weather information to my smart alarm. Now that I am online with the RPI I can easily do that from the browser.

IMG_5819.JPG

IMG_5819.JPG

pywapi 0.3.8 download link:

IMG_5818.JPG

Testing the weather API

API (or Application Programming Interface)

The API is a web service that is designed to deliver live data from many different online sources, in a secure way. I will use this method to get the latest live information from the web to my bedside clock screen.
The first task was to test the’ API’s and see if I can configure the weather services to show local data. That’s relatively easy as you just need to append the correct ID code for your location on the end of the url for the chosen weather service. Like this for New York: http://www.weather.com/weather/today/l/USNY0996  
The big problem was that they were set up to deliver results using US zip codes. (Any US postal zip code works as a valid Location ID, so don’t require a search). As a UK post code wasn’t the expected format, I needed to find a way to convert any UK postcode to the correct format. I found this site after a Google search: https://www.edg3.co.uk/snippets/weather-location-codes/  (Choose a country from the bottom of the page to view their respective codes, or use the search box in the top left to search by location name).
These weather location codes can be used for AOL Weather, The Weather Channel (weather.com) or Yahoo! Weather. For example: http://uk.weather.com/weather/today/ukxx0070 for Huddersfield,UK.

My next task will be to create a window on the RPI using Pygame and configure it to display the live weather data from the API.

No comments:

Post a Comment