HOME      Other material for programmers
Pi? Arduino? Other?

I have notes for translators, if you would add a translation.


Raspberry Pi: Getting started

filename: pittoc.htm


Suggestion: Your browser has a "Find in this page" tool... probably worth using, if you are looking for something specific.

I try to make my pages browser friendly. Make your browser window as wide as you want it. The text will flow nicely. It is easier to read in a narrow window... and the rest of your screen will be free for other things! Hold down the control key ("ctrl") and press the plus sign, the minus sign, or zero to change the size of the text in Firefox and other good browsers. This and other hints explained on my Power Browsing page!

There are more notes at the bottom of the page about other offerings, my editorial philosophy, a link to a way to send me email, and a search engine to help you find things on my site.


It does have to be said that in matters Raspberry Pi, I've barely got past my first "Hello World". (This page started August 11th 2018.) But I do know a thing or two about computers, about Arduinos. (They are very different from Pi's... but some of the things you need to know to use an Arduino transfers across to working with Pi's. I come from a Windows background. (Actually, a PDP-8 background... Windows became my "new" environment when it came along, "only yesterday".)

What this page offers

This page attempts to provide step-by-step guidance for the complete Pi novice, so that he or she can go out, get the right "bits" (but nothing unnecessary), and "fire up" a Raspberry Pi, from scratch.

That much is more or less finished, and appears below.

I hope to add various "what do we do with it?" articles in the near future, so that you can DO SOMETHING with your wondrous little machine.


A Fundamental Issue

The Raspberry Pi is an extraordinarily powerful little beast. (And I try very hard not to use "powerful" when talking tech.)

As a result, it is many things to many people.

I am going to walk you through how I made my start with Pi. Other guides on the net may suggest a totally different path.

While I am new to Pi as I write this, I am not new to computers, or to teaching people (in the real world) how to use computers.

I'm also reluctant to spend money.

So... "Introductions" complete, let's get to work...






What you need to "play Raspberry Pi"- MINUMUM

This is a condensed statement of my advice. I also offer a 'sidebar page' with the same advice, but in more detail.

To start with the Raspberry Pi by the path I would suggest, you need...

Pi: Be aware: Pi's come in models 1, 2 and 3. In some cases, there are "A" and "B" variants of a given model.

microSD card: 16 Gig minimum, Class 10 minimum.

Monitor to be driven from an HDMI signal.

Adequate Power Supply: I bought a "starter kit" from a good source. It came with a 2.7 amp power supply.


Highly desirable other bits and pieces

An easy way to connect stuff to the GPIO headers, e.g. the "Pi Wedge" from Sparkfun. $10.

A breadboard.

Some bits and pieces of the electronics nerd: solid wire, buttons, LEDs, resistors.

I'd recommend an enclosure for your Pi

I would suggest you buy a Pi Starter Kit. Again, I will recommend Sparkfun not because a family member works there, but because I have found them a great source of Stuff for years. Their kit (14644) is an intelligently chosen selection.

One other "nice to have" item, not in the kit: a second microSD card, 16G and Class 10, any one will do. Or go for a 32G card.

Also: an "ordinary" computer. Linux, Windows, or Mac.

As I said, I also offer a 'sidebar page' with the 'buy this' advice, in more detail.


Money spent! Toys assembled! Let's do it! First...

In theory: Plug everything in, turn it on. It just works. Initially, you answer some questions, just like if you bring a new Windows computer home from a store, and then you are... IN ! ! !

In practice: Probably not too far from that!

Sadly, there are always chores. You don't NEED to do it, but I would make a copy of the "microSD card with operating system" which you bought, put the original someplace safe and work with the COPY. (That's why I suggested buying the second microSD card!)

You can trash the data on your microSD card. If you are working with the original, you'll feel foolish then, won't you??

NOTE: "Copying" the microSD card isn't the simple copy you might assume would suffice. But it isn't rocket science, either. (Someday I will try to expand on the details of that.)

I used and liked Win323DiskImager, from https://sourceforge.net/projects/win32diskimager/
... I've made notes, will try to write up.

In a nutshell: Start Win32DiskImager running. Insert card with the "stuff" you want to preserve. Copy the card to a file on your hard disk. Change cards. Write the "stuff" onto the new card. Done.

Why is this "hard"? We need to take "an image" of the card's contents. This is subtly different from "copying the card's files".


More "doing it"...

So! We have a COPY of the operating system ("OS") on our microSD card. Actually, strictly speaking we have a copy of the stuff needed to SET UP the OS. (We're using "Raspbian"... one of many OS's which can be used with a Pi.)

DON'T plug in the power to your Pi yet.

Insert the microSD card into its slot.
Plug mouse and keyboard in.
Turn your monitor on; connect the cable between it and Pi.
Plug power supply into the wall socket, to give it power....

And THEN plug the power from the power supply into the Pi, and cross fingers!

Before long (30 seconds) "stuff" should appear on the monitor. If it doesn't, don't panic! Does your monitor have multiple inputs? If so, does it need to be told which one to look at?

By now, you should be seeing something on the monitor.

Hurrah!

(If it is not too late, there's the same advice (minus the "work with a copy of your microSD-card-with-OS-installer" bit!) at https://learn.sparkfun.com/tutorials/setting-up-raspbian-and-doom#prepare-the-pi (You can forget the "select display mode" bit, if you are working with a Raspberry Pi 3 B.)

There's a good guide to your setup choices at... https://learn.sparkfun.com/tutorials/setting-up-raspbian-and-doom#setup-raspbian
"Go for" boot to Desktop.

When you've made the various choices, invoke "finish". That will do a reboot, and THEN you will be "into" your Pi, under Raspbian for the first time.

That is how it will look each time you start it up, from now on.

The "install OS" process is really very clever: When we started, the microSD card had one lot of stuff on it. That stuff let us replace what WAS on the card with what we need to have on the card to use the Pi normally. The card is the Pi's "hard disk", in case that is not already evident to you.

I think now you can see more fully why I prefer to work with a duplicate, an "image", not a "copy" the way we sometimes mean that, of what was originally on the microSD card? I hope so, anyway.


Wow! A working Pi!

Great! Pi up and working! But you're exhausted by now, I would assume. I certainly am, for the moment.

Turning off your Pi: Like any modern computer, you should Shut It Down Properly.

In the upper right hand corner of the desktop, there's a Raspberry icon. Click it. At the bottom: "Shutdown". Click it. You get choices: Shutdown shuts the Pi down. Reboot shuts it nearly all the way down, but at the last moment starts it up again. (Reboot is the right way to "turn it off; turn it on again", which you may need to do one day to clear something. You "shouldn't" need to do it... but you may need to. Doing a reboot is wise, if you have been Doing Things to the system, and are a little nervous as to whether you may have broken things. Or to "finish" the "doing" of some complex, arcane things. It gives you a fresh start. And finally: Logout. You will only need this if you set up additional "users" on the system. At the moment, you are user "pi", with password "raspberry" (unless you've already changed that. It isn't hard.) There is another "user", "root", but you wouldn't ever change to that user. (There are ways we will come to to do things "as if you are" root, from within "pi".

Whew. As I said... exhausted. Give some of the games a try!

Raspberry (icon/ button)/ Games/ Python Games... it leads to a further menu. "Tetromio" is pretty intuitive, and you only need the arrow keys to operate it.

Or, if you are plugged into your LAN and internet source, try the web browser... If there's a "globe" on the menu bar, which reports "Web Browser" if you hover the mouse pointer over it, that's what you need. (Alternatively, click the Raspberry, select "Internet" (same "globe" icon, but this time it takes you to a sub-menu. Click on "Chromium Web Browser" ("Chrome" to its friends.)

You have a nice little Linux computer. $40. Enjoy!


Enough play. Back to work.

When you are "using a Pi", you will be working in one of two environments. (I think there are only two... there might be more.)

Sometimes, you will be in the GUI desktop. ("Pixel", in Raspbian from Sept 2016.) That is to say, in an environment much like Windows. I've done a long-ish tour of the GUI desktop for you, with a few "gems"... but leave it to later, if you wish.

And sometimes you will be using the Command Line Interface, otherwise known as the CLI. Often in these essays, I will give you links, like this for CLI, to "glossary" entries about words I use for when you wish to check "what's he mean by that?". But for some terms there will also be longer essays available, as in the case of the GUI. (That link is to the same page as the one in the paragraph above.)

For most people, most of the time, I suspect that the GUI desktop will be how they interact with their Pi. (Although there is a class of user will probably do most things via the CLI). You'll gradually learn which is for you, when. As I said, almost everyone needs to use both of them, if only once in a while.

Remember: There are usually ways to do things either way. But the two "alternatives" are not always exact alternatives. As a beginner, if in doubt, if you know a way to do "it" by the GUI... do it that way.

As I said, even the someone who usually uses the GUI will have to use the CLI from time to time.

Happily, it is not hard. You just click on the "Terminal" icon on The Panel. ("Terminal" icon: Black rectangle with white ">_" inside it.) (You can also get to the CLI from the The Menu icon (raspberry) on The Panel, if you can't get there more directly.) If you got the right thing, a window will have opened. It will have a black background, and "File/ Edit/ Tabs/ Help" on offer in its menu.

Type "ls", and press the enter key (a lower case "ell", and a lower case "s", without the quotation marks.) In the CLI, everything is case sensitive.

Some words should appear on the window. Probably in blue. Probably including some or all of the following: pi, Desktop, Documents.

Congratulations! You've just issued your first CLI command! (You told the system to LiSt the files and directories at whatever place you are currently at in the filesystem.)

You will often be told to do....

sudo apt-get update
sudo apt-get upgrade

In fact, if you have just got your Pi up and running, you should issue those commands quite soon... but beware: The first time you do it, they may take quite a while (20 minutes?) to complete.

You do these commands in the CLI.

Those commands come in two parts. You are doing apt-get update and apt-get upgrade, "under", or "within" the sudo command. (You use sudo... if it is available to you, which it will be on a newly set up Pi, set up in the way I suggested... to give yourself a bit of extra authority. apt-get is Big Mojo, and can be denied to "lesser beings" to keep the system safe from mistakes by novice users.)

apt-get update and apt-get upgrade, between them, get your system up to date. (I have an innate aversion to "updates" and "upgrades", in general. But they are a fact of life in modern computing. Like eating your peas, it is something that Just Has To Be Done.)

You can either Just Do It, or read my more detailed notes on apt-get update, etc.


Security 101

Security is, of course, a never ending story.

But, please, at least, now change the password on the standard user account, "pi"... from the default "raspberry".

There are all sorts of ways to do this. The easiest and best, my opinion: Do it via the desktop, i.e. the GUI (Graphical User Interface).

Click the raspberry icon, upper left, i.e. 'The Menu'. From the choices which have, I hope, appeared, click Preferences/ Raspberry Pi Configuration. That brings us a dialog with four tabs... System/ Interfaces/ Performance and Localization.

On the "System" tab there is a button to "Change Password". That will change the password of the currently logged in user. Don't be (too) alarmed by the fact that you can change to a new password without having to enter the old password. Seemed strange to me, but seems to be The Way Things Are. (!)

(Don't be (too) alarmed if at this stage you can give yourself a new password without first entering your old password. You don't have to do it now, but someday, you might enjoy my discussion of Pi passwords.)

Early in my Pi life I thought I'd like to move away from the default user, "pi", create an alternative user. This is probably a bad idea, and probably unnecessary. I'd suggest resisting that urge, for now, at any rate.

Once you have your password changed, while you are here....

On the same tab as Change Password, there's an edit box for "hostname". Set this to something other than the default... for your convenience, and for security.

Hostname: The "hostname" will be used in various contexts to say "this pi". Including when you are talking to it across a network. It wants to be something short, first character a letter, after that letters or digits, maybe an underscore or two. It will be case sensitive. Every piece of my equipment has a short "serial number", unique across all of my equipment. A worthwhile system, but not one everyone will embrace, I understand. If I bought my pi on 5 August 2018, I might use pi5aug18 for its hostname. Don't agonize too deeply over this "change hostname" business. If you keep the name short and simple, not a lot can go wrong, and you can change it again later, if you wish.

When you've changed the hostname, you should re-boot the device. No Big Deal. It finished rebooting before I finished typing this. This isn't Windows... hurrah!!!

If you used, say, the Chromium browser (Chrome) before changing the hostname, then sometime soon, you may get a message about its profile being locked. But you're allowed to "unlock" the profile, and "relaunch". This is what you want to do.

Who am I? If you are even a bit unsure about what user you are logged in as, or the hostname of the machine, go into the CLI. Unless you've "messed with it" (!), the prompt will have two parts, separated by an "at" sign. If, in the CLI, the prompt is xxx@yyy, then the current user is "xxx", and the hostname of the Pi is "yyy".

System time (date/ time of day): At this stage, not "security", but useful: In the same dialog, there is a "Localization" tab. If your i will "live" connected to the internet, you might want to set locale and time zone. The basic Pi does not have a built in date/time-of-day clock. It resets itself from the internet each time you turn it on, though.


Samba- very useful... not essential

Wouldn't it be nice if you could read files into your Pi from other computers on your LAN? Or, from other computers on your LAN see some of the files on your Pi?

It is easy to use, once you have it set up. And the set-up isn't terribly arcane. A bit trying, maybe.

When you are ready to have a go, read my guide to filesharing for Raspberry Pi's across the LAN, using Samba. I believe Samba is also "the answer" to printer sharing, but I haven't tackled that yet.


Webserver

I've made a start on how to make your Pi a webserver. You won't be able to rival http://google.com just yet... but this is where that would start.

I spent years learning the hard way (self taught) how to do what I could now do in about an hour. The secret is to go about building a webserver in the right order. If you follow my tutorial, I hope I can spare you the years of suffering I endured. There are many steps to "having a webserver". None is particularly difficult. The trick is to do them in the right order, so that you have "A" working before you try to do "B", which depends on "A", but adds more elements. You then go to "C", ditto, to "D"... etc. If you try to start at "B", you may do all the "B" stuff right, but still fail, because some "A" stuff isn't right. My path to success lets you test "A" before you start "B".

Start with how to make your Pi a webserver. After that you're ready for how to make your Pi (or other) webserver available ToThe World... and beyond.

When you've got a server up and running, as described in the two guides cited above, it is only a small further step to add PHP capabilities to your webserver. (Once you've done that, you are closer to a webpage which, for instance, will report the temperature where the server is.)


High level languages, generally

If you want to Do Things with your Pi, some can be done with the apps that come with it.

You can add apps written by others. (I will try to expand on that!)

But the day will come when you want create "bespoke" apps, apps created by you, for specific purposes.

I lean towards a minority candidate for that job: Lazarus. (See "Lazarus: High Level Language" section a little further down the page.)

Other candidates: It seems a lot of people Do Things on Pi's with Python scripts. There are plenty of Getting Started pages on the web. I got my Pi do Do Something, by means of a Python script quite easily, early on. I didn't have to install anything extra. (I'll try to write a "getting started with Python" which is integrated with this and the rest of my Pi Help pages.)

It seems a lot of people also Do Things on Pi's with C... or is it C++. There are plenty of Getting Started pages on the web. I got my Pi do Do Something, by means of C (C++), using gcc in the CLI quite easily, early on. I didn't have to install anything extra. (I'll try to write a "getting started with Python" which is integrated with this and the rest of my Pi Help pages.)


Reading, writing GPIO pins.

So far, I've had limited success in playing with the GPIO pins. I've turned an LED on and off... by a method that seems Not Good to me. I've monitored the state of a pin configured as an input. I've read extensively about connecting 1-Wire, SPI devices, etc.

So far, I'm really longing for the Arduino world where such things seem much simpler.

I have found that I THINK that as of August 2918, a "gpio"... umm... "library" comes as standard on Pi's using Raspbian. The one that allows the stuff in the tutorial from auctoris.co.uk to work. That showed me how to turn an LED on GPIO 17 on and off, with manual commands via CLI.. but left a lot of questions in my mind. But also a hope that the stuff you can read on old pages about having to install GPIO support software may be out of date.

The big disappointment for me in respect of access to the GPIO is that solutions seem to be very programming language specific. I can find say, a way to read a 1-Wire device in a C program, a way to change the state of a pin set up for output with a Python script, and a way to read an SPI peripheral in Lazarus... but as I want to do all three in one application, I am, so far, out of luck.

The good people at Sparkfun have done some well written examples of accessing SPI and I2C via a Pi's GPIO, in C++ and Python. Setting your machine up for them is also covered.


Lazarus: High level language, IDE, for desktop environment... including reading, writing GPIO pins.

I've liked Lazarus for a long time, having used it for many years on Windows machines. I was delighted to find, 8/18, that some of the dire warnings you read online are out of date. I was able to install a very respectable version (1.6.2) on my Raspberry Pi 3 B with just two sudo apt-get installs.

I've written up two things: Using Lazarus programs to read or to write from/to the Pi GPIO pins.. Full sourcecode for both projects is provided in .zip archives, for download.

Though my success with Lazarus and the GPIO pins is to date very limited, there is a lot you can do with Lazarus on a Pi without needing the GPIO pins. (Skype was written in Delphi, the "parent" of Lazarus.)






Glossary pages

Browser (i.e. Internet Browser)
CLI (Command Line Interface... aka "Terminal")
GUI Graphical User Interface
IP Address (see also LIPA, where WIPA is also defined)
Linux what does "Linux" (the operating system) have to do with Pi?
LIPA (LAN IP Address. This entry also covers "WIPA") (see also IP Address)
OS (Operating System)
Sudo DO as Super User (Preliminary notes)
Terminal (shares a page with "CLI")
'The Menu' The raspberry icon on the GUI's Panel, your access to many functions for the GUI
'The Panel' The bar of icons on the GUI, your main route to power.
WIPA (shares a page with LIPA) (see also IP Address)



About the person who wrote this...

These pages come to you from a retired teacher of computing. A not-retired electronics/ computing hobbyist.

I started these Pi pages August 10, 2018... six days after my first use of a Raspberry Pi!

For many years before that, I had been building many online advice pages, including my Arduino Tutorials. (Things there will also inform some parts of your Pi work, especially if you start using the GPIO pins.)

What cheek! What good can these pages be?

Well, my experience of Pi's is very limited, but I am in a very good position to write pages which will not gloss over issues that "everyone knows" the answers to.

And my many years of computing leave me well placed to guide other new users of a Raspberry Piin their first adventures.






Editorial Philosophy

I dislike 'fancy' websites with more concern for a flashy appearance than for good content. For a pretty picture, I can go to an art gallery. Of course, an attractive site WITH content deserves praise... as long as that pretty face doesn't cost download time. In any case....

I am trying to present this material in a format which makes it easy for you to USE it. There are two aspects to that: The way it is split up, and the way it is posted.

The way it is split up...

TEMPORARY NOTICE: For the moment, there is so little Pi material available from me that it isn't yet appropriate to split it up. That will happen in due course. If you see this notice after that has happened, please remind me to get rid of it? Please mention that it is in page sg/pi/pittoc.htm? Contact details below.

I have tried to split it up into 'bite-sized' pieces, and to indicate which pieces are basic and of general importance, and which address more specific issues which also happen to be complex, or require understanding of more fundamental issues. In other words, I try to show you how to walk before worrying about running.

The way it is posted...

For most readers, using the material online is your best bet. That way, you get the benefit of any updates to a page. However, that isn't always convenient. If you don't already have an HTML capable wordprocessor, load the free OpenOffice. It Really Does Work. Alternatively, you can save the pages from a browser, and re-load them to the browser from your hard-disc later, off-line.

If you choose to capture the tutorials for off line use, including editing for your own purposes, I would suggest that you create a folder for the tutorials so that you can retain my filenames with no risk of clashes:

Please remember the material is copyright. (TK Boyd, 2018) The procedures above are suggested only for convenient personal use of the material, however, also....

Feel free to use this information in computer courses, etc, but a credit of the source, quoting the URL, should be present. If you simply copy the pages to other web pages you will do your readers a disservice: Your copies won't stay current. Far better to link to these pages, and then your readers see up-to-date versions. For those who care- thank you- I have posted a page with more information on what copyright waivers I extend, and suggestions for those who wish to put this material on CDs, etc. (There is at least one prison using the material for inmate education. Situations do exist where an internet connection isn't possible!)




And, lastly, now for something (almost) completely different: Want a bit of fun? If you have the excellent, free, Open Office installed on your Windows or Linux machine, you can write applications similar to many of the applications in this tutorial! I've produced a little demo, consisting of a single "document" for Open Office's wordprocessor, "Writer". If you have Open Office on your machine, and download my demonstration, you will see a "page" of "wordprocessor" material with a button, an edit box, two spin boxes, and some labels, for output. You will see text manipulation, message boxes, and arithmetic. Almost like something created with Lazarus or Delphi! Fun! (The details of how the controls were made "live" are also given.) The demo was written for Open Office version 2.



   Search this site or the web      powered by FreeFind

Site search Web search
Site Map    What's New    Search

The search engine is not intelligent. It merely seeks the words you specify. It will not do anything sensible with "What does the 'could not compile' error mean?" It will just return references to pages with "what", "does", "could", "not".... etc.


In addition to the tutorials for which this page serves as Table of Contents, I have other sites with material you might find useful.....

Arduino Tutorials... another great small computer. Superficially similar to a Pi, very different, when you get into details, and the jobs it is suitable for.
Lazarus Tutorials... a great way to create Windows and Raspbian (Debian) applications.
Tutorials about the free database supplied with Open Office.
Some pages for programmers.


If you visit 1&1's site from here, it helps me. They host my websites, and I wouldn't put this link up for them if I wasn't happy with their service. They offer things for the beginner and the corporation.

Learn more about 1&1 Web Hosting



Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run a Windows PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!

Click here to visit editor's Sheepdog Software (tm) freeware, shareware pages.


And if you liked that, or want different things, here are some more pages from the editor of these tutorials....

Click here to visit the homepage of my biggest site.

Click here to visit the homepage of Sheepdogsoftware.co.uk. Apologies if the "?FrmTut" I added to that link cause your browser problems. Please let me know, if so?

Click here to visit editor's pages about using computers in Sensing and Control, e.g. weather logging.



To email this page's editor, Tom Boyd.... Editor's email address. Suggestions welcome!



Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes. There were two "unknown attributes" in Google+ button code. Sigh.

Why does this page cause a script to run? Because of the Google panels, the code for the search button, etc. Why do I mention scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....