Guess what? My Raspberry Pi SD card got corrupted yesterday :(
I was faced with 2 options: Buy a new card with the Raspbian Wheezy operating system loaded; or re-build my own card.
So I decided to re-build my own.
The first step was to get an image of the most up to date copy of Raspbian onto my Windows netbook using this guide.
I then made a copy of the corrupted disk on my netbook because some of the files might stiil be useful (As it turned out, they was very useful).
Then I needed to download Win32DiskImager so that I could copy the image onto my SD card. The above guide explained all that too.
When I plugged the card back in the RPi and powered up, I got nothing on the PC monitor. So I copied over the config file from my copy of the original corrupted card. I found that it had all the settings I'd pieced together over the last few weeks! This saved me loads of time and got the PC monitor going.
Thankfully, my own blog helped me re-build my web server but I'd lost most of my prototype website. Bummer.
Of course, the way to avoid this kind of thing is to take regular back-ups of the SD card using Win32DiskImager or like this. Then, all you have to do, is copy your most recent back-up image onto the card. Simples.
Saturday, 15 June 2013
Monday, 20 May 2013
Creating A Website On the Pi
I've been spending a bit of time learning some of the skills needed to create a website.
A bit of research told me that I needed to know "basic" HTML and CSS to begin with. Then, when I'd got familiar with those, I could make my site more dynamic using Javascript and PHP.
I'm using the HTML Dog tutorials to get me up to speed on HTML, CSS, and Javascript. They're excellent. They come in bite-size chunks, get straight to the point, giving you all the skills you need, and they even have a sense of humour.
So far, I've done the basic and intermediate levels for both HTML and CSS and found it a pretty quick and painless process. Off the back of this, I can now put together a convincing looking website, complete with images, links, navigation bars, headers and footers.
I used a fake family news site as a prototype to practise the skills I'd learnt. The idea worked well - Forcing me to work through a number of problems that wouldn't have occured to me otherwise.
The starting place for your web pages is the index.html file in the /var/www folder. Apparently that file's more or less the standard place for most websites.
I found a really useful program for my web deveopment work called puTTY. It allows you to connect to your Pi remotely from a Windows PC. For example, I can connect to the Pi from my netbook, login, then edit the web pages. I can even copy & paste stuff from my netbook to the Pi using my right mouse button. More about puTTY here.
If you want to develop your web code on a PC then move it across to the Pi, use WinSCP (See here). By the way, you can't copy files directly to /var/www unless you change the ownership of this folder using: sudo chown -R pi /var/www
A bit of research told me that I needed to know "basic" HTML and CSS to begin with. Then, when I'd got familiar with those, I could make my site more dynamic using Javascript and PHP.
I'm using the HTML Dog tutorials to get me up to speed on HTML, CSS, and Javascript. They're excellent. They come in bite-size chunks, get straight to the point, giving you all the skills you need, and they even have a sense of humour.
So far, I've done the basic and intermediate levels for both HTML and CSS and found it a pretty quick and painless process. Off the back of this, I can now put together a convincing looking website, complete with images, links, navigation bars, headers and footers.
I used a fake family news site as a prototype to practise the skills I'd learnt. The idea worked well - Forcing me to work through a number of problems that wouldn't have occured to me otherwise.
The starting place for your web pages is the index.html file in the /var/www folder. Apparently that file's more or less the standard place for most websites.
I found a really useful program for my web deveopment work called puTTY. It allows you to connect to your Pi remotely from a Windows PC. For example, I can connect to the Pi from my netbook, login, then edit the web pages. I can even copy & paste stuff from my netbook to the Pi using my right mouse button. More about puTTY here.
If you want to develop your web code on a PC then move it across to the Pi, use WinSCP (See here). By the way, you can't copy files directly to /var/www unless you change the ownership of this folder using: sudo chown -R pi /var/www
Wednesday, 24 April 2013
Setting Up A Web Server
![]() |
| Look, it's a web server! |
In the end, I realised this web-page was bit of overkill for what I wanted. So I just gave that a read for background purposes, and went with the explanation in the Raspberry Pi User Guide by Eben Upton & Gareth Halfacre.
LAMP
Firstly, I logged on and installed what's called a 'Lamp Stack'. Lamp stands for Linux, Apache, MySql, and PHP. Linux obviously provides the operating system and is already installed; Apache is the web server; MySQL is the database handler; and PHP is the language that gives life to your web-site.[In fact, xAMP stacks are apparently behind the majority of servers. There are also WAMPs which have Windows instead of Linux, and MAMPs that have the Mac OS]
I installed the LAMP using the following commands:
- sudo apt-get update
- sudo apt-get install apache2 php5 php5-mysql mysql-server
Along the way, MySQL asked me to set a password, then confirm it. I made sure it was secure i.e. Not easy to work out by visitors to my site.
Once the installation had completed, the MySQL and Apache servers were running.
Final Checks
To check that the server was up, I got my netbook out (which is part of my home network connected via a router) and typed the Pi's IP address into a web browser (I got the IP address using the 'ifconfig' command and found it listed in the 'eth0' section).This displayed the default web page. Nearly done.
Finally, I had to confirm PHP was working, so, still following the guidance in above manual, I used the following command to create a test script:
sudo sh -c 'echo "<?php phpinfo(); ?>" > /var/www/phptest.php'
This new file asks PHP to provide an information page when called. And I did that through the netbook again, tacking /phptest.php onto the end of the ip address.
This also worked. Job done!
Final Note
From this point on, every time I switch on the Pi, it becomes a local web server. I don't even have to log in for this to happen.Friday, 19 April 2013
Next Steps With The Pi
Having read through my Raspberry Pi Users Guide, I've decided that my next step will be to set-up a web server to host a small website.
My reasons are basically: I've never done it before; I'll be able to learn and practise stuff HTML, CSS, Javascript, and PHP to build the website. Which could be useful in my current job.
I'll be using advise from that Users Guide I mentioned and this site to build my server.
I'll tell you how that goes soon.
My reasons are basically: I've never done it before; I'll be able to learn and practise stuff HTML, CSS, Javascript, and PHP to build the website. Which could be useful in my current job.
I'll be using advise from that Users Guide I mentioned and this site to build my server.
I'll tell you how that goes soon.
Saturday, 13 April 2013
USB Hubs
So, here's the thing: Not all USB hubs work with the Raspberry Pi.
Hard to believe isn't it? You just take it for granted that you can just plug these into any computer and they just work.
I got my first clue when I looked at the packaging for some of these hubs. Just about all of them say they're compatible with Windows or MacOS. No mention of Linux or anything Pi related.
So I got on-line and did a quick search. Sure enough I found this page. It lists known compatible and incompatible hubs. It's not an exhaustive list (how could it be?) but it's a start and gives you idea what to look out for.
I took the easy option, I just bought from a site that specialises in Pi accessories. I went for a CIT-UH207P-01-HUB, USB 2.0 7 Port (Not the one pictured above).
The reason I went for it was that it has 7 ports (plenty of room for expansion....but probably over the top), and it's got it's own power supply. That's important because the Pi's not up to powering a bucket-load of usb peripherals.
In fact, I've gone a step further and bought a USB A Male to Micro B Male lead so that the hub can power the Pi. That would save me a power socket. Let's hope it works!
Update: Nope, the CIT hub isn't beast enough to power the Pi. If I were to do this again, I'd go for the D-Link Dub-H7 7 Port USB 2.0 Hub. Now that will do the job properly.
Hard to believe isn't it? You just take it for granted that you can just plug these into any computer and they just work.
I got my first clue when I looked at the packaging for some of these hubs. Just about all of them say they're compatible with Windows or MacOS. No mention of Linux or anything Pi related.
So I got on-line and did a quick search. Sure enough I found this page. It lists known compatible and incompatible hubs. It's not an exhaustive list (how could it be?) but it's a start and gives you idea what to look out for.
I took the easy option, I just bought from a site that specialises in Pi accessories. I went for a CIT-UH207P-01-HUB, USB 2.0 7 Port (Not the one pictured above).
The reason I went for it was that it has 7 ports (plenty of room for expansion....but probably over the top), and it's got it's own power supply. That's important because the Pi's not up to powering a bucket-load of usb peripherals.
In fact, I've gone a step further and bought a USB A Male to Micro B Male lead so that the hub can power the Pi. That would save me a power socket. Let's hope it works!
Update: Nope, the CIT hub isn't beast enough to power the Pi. If I were to do this again, I'd go for the D-Link Dub-H7 7 Port USB 2.0 Hub. Now that will do the job properly.
Friday, 5 April 2013
VGA Monitors, Sound, And More Speed (Take 2)
It's taken me a while to get round to trying out the suggestions from my previous post but I've finally had success. Not without a struggle though.....
So I changed the config.txt file on the SD card (using the SD card reader on my netbook) to say:
hdmi_safe=1
This command sets the Pi to low resolution output and should always give you a picture.
When I re-booted, it worked. Now all I had to do was figure out how to get a higher resolution (Giant icons on your desktop is not a good look!).
I just had to match up the monitor's best resolution with the table given here, and change the config.txt file accordingly.
The settings that did the trick on my monitor were:
hdmi_drive=2
hdmi_group=2
hdmi_mode=83
hdmi_force_hotplug=1
disable_overscan=0
However, it took the best part of an evening to discover that each command needs to be on a separate line otherwise it doesn't work!
Anyway, hdmi_drive=2 means that the voltage output is for HDMI (1=DVI voltages).
hdmi_group=2 means I'm using a monitor (1=An HDMI TV).
hdmi_mode=83 is connected with the hdmi_group, 83 means I want 1600 x 900 resolution (See the table I mentioned above).
hdmi_force_hotplug=1 forces the Pi to use the HDMI port even if it can't detect a monitor.
disable_overscan=0 No idea why it works but it does.
However, the makers have now come up with a setting that speeds things up without killing your Pi or invalidating the warranty.
The way to set it is to login then use
sudo raspi-config
Now look for the overclocking option and work your way to this menu:
Select the Turbo preset.
Nightmare! I expected to just plug my headphones into the audio socket and get sound but it's not that simple.
In the end, I had to work through this entire link to get my audio set-up, including a full system update. Another couple of evenings blown. Why on earth should it be so difficult?! I get the impression the Pi is designed around connecting to an HDMI device and anything else is an afterthought.
Oh well, it's done now. I can finally get on with using it. I think I'll read through the Raspberry Pi User Guide to see what I'm going to have a go at next.
VGA Monitors
The problem I had when I switched from an HDMI TV to a monitor as a screen was that I was getting no picture.So I changed the config.txt file on the SD card (using the SD card reader on my netbook) to say:
hdmi_safe=1
This command sets the Pi to low resolution output and should always give you a picture.
When I re-booted, it worked. Now all I had to do was figure out how to get a higher resolution (Giant icons on your desktop is not a good look!).
I just had to match up the monitor's best resolution with the table given here, and change the config.txt file accordingly.
The settings that did the trick on my monitor were:
hdmi_drive=2
hdmi_group=2
hdmi_mode=83
hdmi_force_hotplug=1
disable_overscan=0
However, it took the best part of an evening to discover that each command needs to be on a separate line otherwise it doesn't work!
Anyway, hdmi_drive=2 means that the voltage output is for HDMI (1=DVI voltages).
hdmi_group=2 means I'm using a monitor (1=An HDMI TV).
hdmi_mode=83 is connected with the hdmi_group, 83 means I want 1600 x 900 resolution (See the table I mentioned above).
hdmi_force_hotplug=1 forces the Pi to use the HDMI port even if it can't detect a monitor.
disable_overscan=0 No idea why it works but it does.
More Speed
When I first got the Pi going on an HDMI tv, I noticed that some of the games were painfully slow. Apparently this is a common problem. The solution most people go for is so-called 'over-clocking' which boosts the CPU's clock frequency. However, the makers warn against this as it shortens the life of your Pi. For this reason it invalidates the warranty.However, the makers have now come up with a setting that speeds things up without killing your Pi or invalidating the warranty.
The way to set it is to login then use
sudo raspi-config
Now look for the overclocking option and work your way to this menu:
Select the Turbo preset.
Sound
Nightmare! I expected to just plug my headphones into the audio socket and get sound but it's not that simple.
In the end, I had to work through this entire link to get my audio set-up, including a full system update. Another couple of evenings blown. Why on earth should it be so difficult?! I get the impression the Pi is designed around connecting to an HDMI device and anything else is an afterthought.
Oh well, it's done now. I can finally get on with using it. I think I'll read through the Raspberry Pi User Guide to see what I'm going to have a go at next.
Friday, 8 March 2013
VGA Monitors, Sound, And More Speed (Take 1)
So the idea here was that, having got the Pi running using a TV, I would now make the move to a PC monitor which is in a more convenient position. However......I'm getting nothing from the monitor.
The problem seems to be with this HDMI to VGA cable adapter I needed to convert the HDMI to a standard VGA monitor.
Apparently you need to fiddle with the Pi's config.txt file to get a picture. Here's a helpful comment from 'GeekDad' on Amazon:
"I got this to go with my son's Raspberry Pi. At first it didn't seem to work, but after some googling managed to get it to work by editing the /boot/config.txt file on the SD card. First try with the hdmi_safe=1 option, which should give low-res (VGA) output when booted. If that works it is a matter of turning off safe mode and finding the settings that work for you. I tried:
disable_overscan=0
hdmi_drive=2
config_hdmi_boost=4
this worked after a reboot and gave full resolution on my old Samsung SyncMaster 172v. Haven't checked if all these options are needed.
So the product works with the Pi but you may need to experiment a bit to get it to work with your monitor."
Ah well. I shall report back soon hopefully.
The problem seems to be with this HDMI to VGA cable adapter I needed to convert the HDMI to a standard VGA monitor.
Apparently you need to fiddle with the Pi's config.txt file to get a picture. Here's a helpful comment from 'GeekDad' on Amazon:
"I got this to go with my son's Raspberry Pi. At first it didn't seem to work, but after some googling managed to get it to work by editing the /boot/config.txt file on the SD card. First try with the hdmi_safe=1 option, which should give low-res (VGA) output when booted. If that works it is a matter of turning off safe mode and finding the settings that work for you. I tried:
disable_overscan=0
hdmi_drive=2
config_hdmi_boost=4
this worked after a reboot and gave full resolution on my old Samsung SyncMaster 172v. Haven't checked if all these options are needed.
So the product works with the Pi but you may need to experiment a bit to get it to work with your monitor."
Ah well. I shall report back soon hopefully.
Friday, 15 February 2013
Up And Running
My RPi has arrived!
Actually, it arrived the day after my last post (and I got it going on Sunday) but, due to 'flu, I've not had the chance to tell you about it yet.
Anyway, here goes.
I got it started using a combination of the Raspberry Pi quick start guide and this guide. These were the highlights:
Actually, it arrived the day after my last post (and I got it going on Sunday) but, due to 'flu, I've not had the chance to tell you about it yet.
Anyway, here goes.
I got it started using a combination of the Raspberry Pi quick start guide and this guide. These were the highlights:
- I was using an HDMI TV to make things simpler on this occasion.
- I began with the quick start guide and, as I already had an SD card loaded with the operating system, skipped to Section 5, plugging everything into the Pi in the order given on page 1. Notes: a) When I plugged in the HDMI cable, I also connected it into the TV, switched the TV on, and changed to HDMI input, so I wouldn't miss anything on screen; b) The SD card goes in contacts uppermost and only goes in halfway (Don't panic!).
- When I plugged in the power supply, I started getting loads of text scrolling up the screen.
- After a while this stopped and I got the config screen (Section 5, point b)). At this stage, I took the advice of the other guide I mentioned and set-up the 'expand_rootfs', 'overscan', 'change_pass', 'change_timezone', and 'configure_keyboard' settings by selecting them using the keyboard arrows, pressing Enter, then following the instructions. Notes: a) Once I was in a setting, I found the Tab key was the way to reach the options at the bottom the screen (See 'Overscan' example below); b) When it came to changing the password, nothing happens as you type the password. This is normal.
- Once I'd finished making changes, I Tabbed to the <Finish> option at the bottom of the config screen and pressed Enter to reboot the Pi (which was necessary after changing these settings).
- After a while, I got a login prompt. So I entered 'Pi' (The standard user) and pressed Enter. I then had to enter my password. When I pressed Enter again, I was at the Unix equivalent to a DOS prompt (See the quick start guide section 5, point i)).
- To get to a GUI style screen, I typed 'startx' at the prompt.
- I was in!
- IMPORTANT: To switch off, you don't just yank out the power supply. If you do, you may damage the SD card. Instead, logout of the GUI using the icon in the bottom right corner. Then stop the Operating System using 'sudo halt' then Enter at the prompt. Only then can you unplug everything.
Friday, 8 February 2013
Thinking About Buying A Pi
Beginnings
So, there I was in my local branch of Maplins when I noticed something calling itself a Raspberry Pi Users Guide on a rack.After thumbing through it for a couple minutes, I realised a 'Raspberry Pi' (RPi) was, in fact, a fully fledged computer that could also be used for electronics projects like controlling robotic arms.
I was intrigued. I've always been interested in electronics but it's always struck me as a lot of work for very little result. The RPi promised something more.
Research
Once I got home I did some web searches and quickly discovered there's an awful lot of information out there about the RPi. The things that first grabbed my attention though were it's size (about the size of a deck of cards), and it's price (@ £35).I was definately interested but I still had some questions:
- What could I do with it? The RPi is a decent enough computer with a variation of the Unix operating system running it called Raspbian. Once you've got it up and running it looks and acts much like any other PC. It provides something called Scratch which can be used write games; it has a programming language called Python if you create something more sophisticated; you can set it up as a web server (To host your own website), and learn skills like PHP, HTML, and Javascript on the way; but, above all, it's the ease of access the RPi gives for projects like robotics, weather stations, in-car computers, radios, jukeboxes, webcam servers etc.
- Was it for me? With all those possibilities and more, it was a no-brainer for me. It could even add skills to my C.V.
- Was it reliable? It's difficult to find a bad word about the Raspberry. I couldn't find anything about reliability problems.
- Was that £35 the only cost? This was the final and biggest hurdle to me making the final decision. This is the subject of the next section.
Shopping List
When you buy an RPi it's like buying PC base unit: No keyboard, mouse, monitor, speakers, leads, or a power supply.It's just the basic computer. As with a standard PC, this option keeps your costs down as it's assumed that you already have most of what you need stored in your own home.
There are Raspberry Pi 'bundles' out there that can provide all these missing items. However, it's likely that you'll end up with some items you already have in house. But since these bundles are relatively cheap (between £30 - £100 depending on your needs), you might consider this to be an issue.
Anyway, here's a list of what you may need:
- Raspberry Pi, Model B 512MB
- 5V 1500mA Power Supply
- TV (Preferably with HDMI port) or monitor (You will probably need an adaptor though)
- HDMI or RCA cable (Depending on which one you use on your TV or monitor. HDMI can connect to an HDMI TV or a monitor with VGA using an HDMI to VGA cable adapter or a monitor with DVI using an HDMI to DVI adapter. RCA is used on a TV with an RCA socket)
- Network/Ethernet cable or Wifi dongle
- 8GB SD Card Pre-Loaded with Debian Linux OS
- Case (It's possible to make one out of card or Lego!)
- Keyboard (Preferably with USB connector but you can get adaptors for PS2 connectors)
- Mouse (Preferably USB but you can get a PS2 adaptor)
- USB Hub (For future expansion)
- Speakers
And, because I'm an old-fashioned sort of guy, I also decided to buy a Raspberry Pi User Guide (for £9) to get me started.
The Wait
So now I'm just waiting for it everything to arrive in the post. All being well I should have the lot by this time next week. Then the fun really starts.First Post
![]() |
| The Raspberry Pi |
As a complete beginner with the RPi, I thought people might find it useful to read about my experiences right from the very start (I'm still waiting for it to arrive in the post).
As everything about the RPi seems to be outside my comfort zone (even though I'm an experienced programmer) it should be quite a ride!
Subscribe to:
Comments (Atom)









