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.

Sunday, April 19, 2015

Project to build a 'Super Smart Alarm Clock' around the latest Raspberry Pi 2 B+ board.


New-10-1-TFT-LED-1024-600-Touch-Screen-Display-for-Raspberry-Pi-2-B
10.1" TFT LED 1024*600
 Touch Screen Display

RASPBERRY PI 2 - Model B.
 1GB RAM, Quad Core CPU
Vivanco wireless active bookshelf speakers

Who am I?

I am a 59 year old designer/technical illustrator from Cheshire, currently working as as a web designer for a web startup company in Torquay.

When it comes to projects like this, I'm more of a designer than a programmer, but with a little help from my friend Google (and of course, an army of other online makers, programmers and bloggers), I can usually get things to work.

This is a real project of the 'internet of things' and a good example of 'convergence'. It could be argued that it isn't really an alarm clock but a tablet computer, media centre or whatever else, but it will live by my bedside to awaken me with any sound, vision or information that I choose. I couldn't find room on my bedside table for my desktop computer, keyboard and mouse (although at one time I did set my Mac to wake me up with a CD when it was in the same room as I slept). My smartphone's screen is also a bit too small to read the mornings news, emails and facebook posts. I can play music from my iPhone or iPod, but fiddling with cables and chargers isn't fun or tidy, for that matter.


History

I was one of the first to get my hands on a Raspberry Pi, this will be my third. My last project was to build a smart tv which ran full screen Youtube videos and played all my networked media as well as my favourite internet radio station Radio Paradise, (an eclectic commercial free Internet radio station in California http://www.radioparadise.com/). I had also messed around with a few Arduino boards, and more specifically, many years ago I built an LED digital clock out Maplin parts and a home-made perspex case, so that I could admire my dreadful soldering as well as see the time in the middle of the night.


Origins

This project has been inspired by Tony Dicola's SMART Alarm clock on Makezine.
http://makezine.com/projects/s-m-a-r-t-alarm-clock/ 

I like that, but the screen would be too small for my blurry-eyed first-thing-in-the morning-before-I-can-find-my-glasses, vision. He based his project on the Arduino Yun which carries a second processor running an embedded version of Linux. He cleverly uses Google Calender to set the alarm remotely.

Matt Dyson's 'Alarmpi' http://mattdyson.org/projects/alarmpi/ is also along similar lines being a Raspberry Pi based smart alarm, but just features an LCD clock with a small text display, although it has an impressive set of functions, not least the openweathermap feed, internet radio and Google calendar integration. It also has home automation functions.

Adafruit's open clock project, an LED clock in a 3D printed case is a great design too, but just uses an LED display.
https://blog.adafruit.com/2013/03/21/open-clock-project-fully-functional-working-prototype-3dthursday/

I also love Instructables (http://www.instructables.com) and plan to post this completed project on there when it's done. There's dozens of funky home built alarm clocks on there.

I found this useful. How to tweet from an Arduino using the wifi sheild by echoalex http://www.instructables.com/id/How-to-tweet-from-an-Arduino-using-the-wifi-sheild/?ALLSTEPS


I originally planned just to have a smart alarm with the local weather, so this Instructable project was my first inspiration. Raspberry Pi Internet Weather Station http://www.instructables.com/id/Raspberry-Pi-Internet-Weather-Station/?ALLSTEPS


Project


I have been involved with the internet since its inception and love computers and electronics and technology in general, but I am a very practical sort of person, so I wanted to do something that would be really useful and enhance my life. The bedside alarm is, of course one of the most useful items that we need in our daily lives and I have had a succession of these ranging from compact travel alarms to clock radios, clock tape recorders and even a teasmaid, which on no account would pass any health and safety checks in the modern day, being awoken with hot steam issuing a few centimetres away from ones ear. I now have a useful projection clock so that I can see the time clearly displayed on the ceiling if I wake up in the night. It is also radio controlled by an accurate time signal which is right most of the time, but for some inexplicable reason goes out by exactly 4 or 6 hours occasionally (I personally think it must have an ironic sense of humour).


Why 'Super Smart Alarm Clock'?

I'm glad you asked that, since I don't have the right to name something with such an impressive and dangerously presumptuous title without backing it up sufficiently. Well, it would be easier to say what it can't do, partially due to the expansion possibilities of the amazing raspberry pi and range of internet web services, but I'll have a go.


What is planned

Remotely set alarm clock,  iPhone dock, music centre with remote speakers, Kodi network media player, streaming music and YouTube/Vimeo feeds, Google calendar with notifications, internet radio, streaming digital photo frame, Gmail server, Twitter feeder, Facebook viewer, news reader, RSS reader, weather reporter...

plus, using the RPI's GPIO header

240v extension socket remote switch/timer to turn on any household appliance, such as lights, fans, heaters etc and future possibilities include home security with CCTV/remote surveillance through a web browser.


Functionality

I like Google cloud services and I have been using Google Calendar as well as Google Docs, sites and also Gmail for some time now. One of the things I have particularly found useful is the Gmail/Calendar notifications which flag up on my iPhone, reminding me of important events and meetings. Of course, Google cloud services can be accessed from any computer, smartphone or tablet, wherever you happen to be.

This project will make use of API's from Google as well as from Twitter, Tumblr (for the photo frame), Wunderground, the weather underground site (http://www.wunderground.com/) and National Lottery Results from http://lotteryresults.bentasker.co.uk/.


So what is an API?

An API ('Application Programming Interface' http://en.wikipedia.org/wiki/Application_programming_interface) is a set of tools to help when transferring secure, live data from the internet. 


Design and Build

I will use Sketchup (http://www.sketchup.com/to design the case and make the files available should you want to use them. I plan to use Plywood as it is easy to fashion and looks good, as well as matching the wooden surrounds of the remote speakers, although a 3D printed case is possible directly from the sketchup files. I don't want to do that just yet, until I have a fully working prototype that may have many mods before it is an optimum design. For example, I was wondering if a cooling fan might be necessary, and a 'carrying' slot, so that it could be easily moved with one hand. The slot would be a good air vent for cooling too. I will incorporate small speakers although the plan is to use remote active bookshelf speakers, as they have much more power and therefore volume, but I may not want to fill the entire room with sound at the crack of dawn.

The heart of the project is the new Raspberry Pi 2 Model B+. It is 6 times faster than the previous model, with 1Gig of RAM and a Quad Core CPU. I found the earlier model a bit sluggish when choosing media files in XBMC (now Kodi) also it has an extended GPIO header for better expansion capabilities, more usb outlets with 1.2Amp power so no need to resort to a powered hub, plus ports for camera (for home security) and touch screen monitor, as I don't want to fiddle with a keyboard on a day to day basis, unless programming or adjusting settings. It also has a 4-pole jack for stereo audio out and composite video via HDMI at a very respectable 1080P resolution.


The Project so far

Well, I have done a lot of research, scribbling on graph paper and set up accounts and API's with Google, Twitter, Tumblr, wunderground and Temboo (for help with coding the API's https://temboo.com/) as per the instructions on Tony Dicola's Makezine post (http://makezine.com/projects/s-m-a-r-t-alarm-clock/).

The next step is to download the latest Raspbian Wheezy OS

I have an SD slot on my laptop, but I found that as it is not USB 2.0 it won't read my 16Gig card. I had to get this external card reader which supports USB 2.0.


USB 2.0 External card reader.

The first plan is to test all the new API's. I'll let you know...