Raspberry Pi Computing Analog Measurement Malcolm Maclean all chapter instant download
Raspberry Pi Computing Analog Measurement Malcolm Maclean all chapter instant download
com
https://ebookmeta.com/product/raspberry-pi-computing-analog-
measurement-malcolm-maclean/
OR CLICK HERE
DOWLOAD NOW
https://ebookmeta.com/product/instant-raspberry-pi-the-beginner-s-
guide-to-raspberry-pi-setup-1st-edition-ashwin-pajankar/
ebookmeta.com
https://ebookmeta.com/product/retro-gaming-with-raspberry-pi-2nd-
edition/
ebookmeta.com
https://ebookmeta.com/product/diego-s-heart-vampires-of-the-beloved-
gem-1-1st-edition-taylor-rylan/
ebookmeta.com
https://ebookmeta.com/product/calling-mr-nelson-pugh-1st-edition-
christopher-opyr/
ebookmeta.com
https://ebookmeta.com/product/stem-mathematics-test-for-primary-
junior-1st-edition-bat-nhi/
ebookmeta.com
https://ebookmeta.com/product/democratizing-rpa-with-power-automate-
desktop-1-converted-edition-peter-krause/
ebookmeta.com
Spanish Language and Sociolinguistic Analysis 1st Edition
Sandro Sessarego
https://ebookmeta.com/product/spanish-language-and-sociolinguistic-
analysis-1st-edition-sandro-sessarego/
ebookmeta.com
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Welcome! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
What are we trying to do? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Who is this book for? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
What will we need? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Why on earth did I write this rambling tome? . . . . . . . . . . . . . . . . . . . . . . . . 3
Where can you get more information? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Raspberry Pi Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Raspberry Pi B+, B2, B3 and B3+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
USB Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Video Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Ethernet Network Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
USB Power Input Jack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
MicroSD Flash Memory Card Slot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Stereo and Composite Video Output . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
40 Pin Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Raspberry Pi Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
SD Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Keyboard / Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Welcome to Raspbian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Downloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Writing the Operating System image to the SD Card . . . . . . . . . . . . . . . . . 20
Enabling Secure Shell Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Powering On . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
The Command Line interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Raspberry Pi Software Configuration Tool . . . . . . . . . . . . . . . . . . . . . 24
Software Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
CONTENTS
Power Up the Pi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Static IP Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
The Netmask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
CIDR Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Distinguish Dynamic from Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Default Gateway . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Lets edit the dhcpcd.conf file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Remote access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Remote access via SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Setting up the Server (Raspberry Pi) . . . . . . . . . . . . . . . . . . . . . . . . . 33
Setting up the Client (Windows) . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
WinSCP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Setting up a WiFi Network Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Built in WiFi Enabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Make the changes operative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Make the built in WiFi IP address static . . . . . . . . . . . . . . . . . . . . . . 44
Make the changes operative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
WiFi Via USB Dongle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Editing files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Make the changes operative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Make USB WiFi IP address static . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Make the changes operative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Reconnecting to the wireless network automatically . . . . . . . . . . . . . . . . . . . . 50
Let’s write a script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Lets run our script on a regular schedule . . . . . . . . . . . . . . . . . . . . . . . . . 51
Let’s test it . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Record the readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Recording data on a regular basis with cron . . . . . . . . . . . . . . . . . . . . . . . 74
Managing database size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Explore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Simple data point API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Extracting a Range of Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Wrap Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Linux Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
What is Linux? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Linux Directory Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
/bin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
/boot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
/dev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
/etc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
/etc/cron.d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
/etc/rc?.d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
/home . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
/lib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
/lost+found . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
/media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
/mnt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
/opt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
/proc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
/root . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
/sbin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
/srv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
/tmp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
/usr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
/usr/bin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
/usr/lib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
/usr/local . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
/usr/sbin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
/var . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
/var/lib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
/var/log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
/var/spool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
/var/tmp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Everything is a file in Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Traditional Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
System Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
CONTENTS
File Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
The nano Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Linux Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Executing Commands in Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
The Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Putting it all together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
apt-get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
The apt-get command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
apt-get update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
apt-get upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
apt-get install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
apt-get remove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
cat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
The cat command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Arguments and Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Test yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
cd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
The cd command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Test yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
chmod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
The chmod command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
crontab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
The crontab command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Test yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
ifconfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
The ifconfig command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Test yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
The ls command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
CONTENTS
ping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
The ping command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Test yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
sudo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
The sudo command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
The ‘sudoers’ file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
sudo vs su . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Test yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
¹https://www.goodfreephotos.com
²https://www.ebay.com/usr/fluxworkshop
Introduction 2
• A Keyes KY-018 LDR³. They are available from lots of places for around $2 US.
• An ADS1015 ADC from Adafruit⁴. The ADS1015 has a 12bit resolution giving it the ability
to convert an analog signal into one of 4096 discrete levels.
• Some 2.54mm header pins for the ADC module (these are widely available) and some
soldering equipment (you could solder directly, but that’s not as flexible).
• Some dupont connectors (that’s what I used, but you could connect to the Pi and the
modules in different ways).
• An Internet connection for getting and updating the software.
As we work through the book we will be covering off the different parts required and you should
get a good overview of what your options are in different circumstances.
³https://www.google.co.nz/search?q=Keyes+KY-018+LDR
⁴http://www.adafruit.com/products/1083
⁵https://leanpub.com/RPiMRE
⁶https://leanpub.com/b/rpc
⁷https://www.raspberrypi.org/
⁸https://plus.google.com/u/0/communities/113390432655174294208
⁹https://www.reddit.com/r/raspberry_pi/
¹⁰https://raspberrypi.stackexchange.com/questions?sort=newest
The History of the Raspberry Pi
The story of the Raspberry Pi starts in 2006 at the University of Cambridge’s Computer
Laboratory. Eben Upton, Rob Mullins, Jack Lang and Alan Mycroft became concerned at the
decline in the volume and skills of students applying to study Computer Science. Typical student
applicants did not have a history of hobby programming and tinkering with hardware. Instead
they were starting with some web design experience, but little else.
They established that the way that children were interacting with computers had changed. There
was more of a focus on working with Word and Excel and building web pages. Games consoles
were replacing the traditional hobbyist computer platforms. The era when the Amiga, Apple II,
ZX Spectrum and the ‘build your own’ approach was gone. In 2006, Eben and the team began
to design and prototype a platform that was cheap, simple and booted into a programming
environment. Most of all, the aim was to inspire the next generation of computer enthusiasts
to recover the joy of experimenting with computers.
Between 2006 and 2008, they developed prototypes based on the Atmel ATmega644 microcon-
troller. By 2008, processors designed for mobile devices were becoming affordable and powerful.
This allowed the boards to support an graphical environment. They believed this would make
the board more attractive for children looking for a programming-oriented device.
Eben, Rob, Jack and Alan, then teamed up with Pete Lomas, and David Braben to form the
Raspberry Pi Foundation. The Foundation’s goal was to offer two versions of the board, priced
at US$25 and US$35.
50 alpha boards were manufactured in August 2011. These were identical in function to what
would become the model B. Assembly of twenty-five model B Beta boards occurred in December
2011. These used the same component layout as the eventual production boards.
Interest in the project increased. They were demonstrated booting Linux, playing a 1080p movie
trailer and running benchmarking programs. During the first week of 2012, the first 10 boards
were put up for auction on eBay. One was bought anonymously and donated to the museum
at The Centre for Computing History in Suffolk, England. While the ten boards together raised
The History of the Raspberry Pi 5
over 16,000 Pounds (about $25,000 USD) the last to be auctioned (serial number No. 01) raised
3,500 Pounds by itself.
The Raspberry Pi Model B entered mass production with licensed manufacturing deals through
element 14/Premier Farnell¹¹ and RS Electronics¹². They started accepting orders for the model
B on the 29th of February 2012. It was quickly apparent that they had identified a need in the
marketplace. Servers struggled to cope with the load placed by watchers repeatedly refreshing
their browsers. The official Raspberry Pi Twitter account reported that Premier Farnell sold out
within few minutes of the initial launch. RS Components took over 100,000 pre orders on the
first day of sales.
Within two years they had sold over two million units.
The the lower cost model A went on sale for $25 on 4 February 2013. By that stage the Raspberry
Pi was already a hit. Manufacturing of the model B hit 4000 units per day and the amount of
on-board ram increased to 512MB.
The official Raspberry Pi blog reported that the three millionth Pi shipped in early May 2014.
In July of that year they announced the Raspberry Pi Model B+, “the final evolution of the
original Raspberry Pi. For the same price as the original Raspberry Pi model B, but incorporating
numerous small improvements”. In November of the same year the even lower cost (US$20) A+
was announced. Like the A, it would have no Ethernet port, and just one USB port. But, like the
B+, it would have lower power requirements, a micro-SD-card slot and 40-pin HAT compatible
GPIO.
On 2 February 2015 the official Raspberry Pi blog announced that the Raspberry Pi 2 was
available. It had the same form factor and connector layout as the Model B+. It had a 900
MHz quad-core ARMv7 Cortex-A7 CPU, twice the memory (for a total of 1 GB) and complete
compatibility with the original generation of Raspberry Pis.
¹¹http://element14.com/
¹²http://www.rs-components.com/index.html
The History of the Raspberry Pi 6
Following a meeting with Eric Schmidt (of Google fame) in 2013, Eben embarked on the design
of a new form factor for the Pi. On the 26th of November 2015 the Pi Zero was released. The Pi
Zero is a significantly smaller version of a Pi with similar functionality but with a retail cost of
$5. On release it sold out (20,000 units) World wide in 24 hours and a free copy was affixed to
the cover of the MagPi magazine.
The Raspberry Pi 3 was released in February 2016. The most notable change being the inclusion
of on-board WiFi and Bluetooth.
In February 2017 the Raspberry Pi Zero W was announced. This device had the same small form
factor of the Pi Zero, but included the WiFi and Bluetooth functionality of the Raspberry Pi 3.
On Pi day (the 14th of March (Get it? 3-14?)) in 2018 the Raspberry Pi 3+ was announced. It
included dual band WiFi, upgraded Bluetooth, Gigabit Ethernet and support for a future PoE
card. The Ethernet speed was actually 300Mpbs since it still needs to operate on a USB2 bus. By
this stage there had been over 9 million Raspberry Pi 3’s sold and 19 million Pi’s in total.
It would be easy to consider the measurement of the success of the Raspberry Pi in the number
of computer boards sold. Yet, this would most likely not be the opinion of those visionaries who
began the journey to develop the boards. Their stated aim was to re-invigorate the desire of
young people to experiment with computers and to have fun doing it. We can thus measure
their success by the many projects, blogs and updated school curriculum’s that their efforts have
produced.
Raspberry Pi Versions
In the words of the totally awesome Raspberry Pi¹³ foundation;
The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer
monitor or TV, and uses a standard keyboard and mouse. It’s capable of doing every-
thing you’d expect a desktop computer to do, from browsing the internet and playing
high-definition video, to making spreadsheets, word-processing, playing games and
learning how to program in languages like Scratch and Python.
There are (at time of writing) eight different models on the market. The A, B, A+, B+, ‘model B 2’,
‘model B 3’, ‘model B 3+’ (which I’m just going to call the B2, B3 and B3+ respectively), the Zero
and Zero W. A lot of projects will typically use either the the B2, B3 or the B3+ for no reason
other than they offer a good range of USB ports (4), 1024 MB of RAM, an HMDI video connection
and an Ethernet connection. For all intents and purposes either the B2, B3 or B3+ can be used
interchangeably for the projects depending on connectivity requirements as the B3 and B3+ has
WiFi and Bluetooth built in. For size limited situations or where lower power is an advantage,
the Zero or Zero W is useful, although there is a need to cope with reduced connectivity options
¹³http://www.raspberrypi.org/help/what-is-a-raspberry-pi/
Raspberry Pi Versions 8
(a single micro USB connection) although the Zero W has WiFi and Bluetooth built in. Always
aim to use the latest version of the Raspbian operating system (or at least one released on or after
the 14th of March 2018). For best results browse the ‘Downloads¹⁴’ page of raspberrypi.org.
¹⁴https://www.raspberrypi.org/downloads/
Raspberry Pi Versions 9
Raspberry Pi B models
The model B+, B2, B3 and B3+ all share the same form factor and have been a consistent standard
for the layout of connectors since the release of the B+ in July 2014. They measure 85 x 56 x
17mm, weighs 45g and are powered by Broadcom chipsets of varying speeds, numbers of cores
and architectures.
USB Ports
They include 4 x USB Ports (with a maximum output of 1.2A)
Video Out
Integrated Videocore 4 graphics GPU capable of playing full 1080p HD video via a HDMI video
output connector. HDMI standards rev 1.3 & 1.4 are supported with 14 HDMI resolutions from
640×350 to 1920×1200 plus various PAL and NTSC standards.
40 Pin Header
The Raspberry Pi B+, B2, B3 and B3+ include a 40-pin, 2.54mm header expansion slot (Which
allows for peripheral connection and expansion boards).
¹⁵http://www.cablechick.com.au/blog/understanding-trrs-and-audio-jacks/
Raspberry Pi Peripherals
To make a start using the Raspberry Pi we will need to have some additional hardware to allow
us to configure it.
SD Card
Traditionally the Raspberry Pi needs to store the Operating System and working files on a
MicroSD card (actually a MicroSD card all models except the older A or B models which use
a full size SD card). There is the ability to boot from a mass storage device or the network, but it
is slightly ‘non-trivial’, so we won’t cover it.
MicroSD Card
The MicroSD card receptacle is on the rear of the board and on the Model B2 it is a ‘push-push’
type which means that you push the card in to insert it and then to remove it, give it a small
push and it will spring out.
This is the equivalent of a hard drive for a regular computer, but we’re going for a minimal effect.
We will want to use a minimum of an 8GB card (smaller is possible, but 8 is recommended). Also
try to select a higher speed card if possible (class 10 or similar) as this will speed things up a bit.
Raspberry Pi Peripherals 14
Keyboard / Mouse
While we will be making the effort to access our system via a remote computer, we will need
a keyboard and a mouse for the initial set-up. Because the B+, B2, B3 and B3+ models of the Pi
have 4 x USB ports, there is plenty of space for us to connect wired USB devices.
An external wireless combination would most likely be recognised without any problem and
would only take up a single USB port, but if we build towards a remote capacity for using the Pi
(using it headless, without a keyboard / mouse / display), the nicety of a wireless connection is
not strictly required.
Video
The Raspberry Pi comes with an HDMI port ready to go which means that any monitor or TV
with an HDMI connection should be able to connect easily.
Because this is kind of a hobby thing you might want to consider utilising an older computer
monitor with a DVI or 15 pin ‘D’ connector. If you want to go this way you will need an adapter
to convert the connection.
Network
The B+, B2, B3 and B3+ models of the Raspberry Pi have a standard RJ45 network connector on
the board ready to go. In a domestic installation this is most likely easiest to connect into a home
ADSL modem or router.
This ‘hard-wired’ connection is great for getting started, but we will work through using a
wireless solution later in the book.
Raspberry Pi Peripherals 17
Power supply
The Pi can be powered up in a few ways. The simplest is to use the micro USB port to connect
from a standard USB charging cable. You probably have a few around the house already for
phones or tablets.
However, it’s worth thinking about the application that we use our Pi for. Depending on how
much we ask of the unit, we might want to pay attention to the amount of current that our power
supply can deliver. The A+, B+ and Zero models will function adequately with a 700mA supply,
but the B2, B3 and B3+ models will draw more current and if we want to use multiple wireless
devices or supplying sensors that demand increased power, we will need to consider a supply
that is capable of an output up to 2.5A.
Raspberry Pi Peripherals 18
Cases
We should get ourselves a simple case to keep the Pi reasonably secure. There are a wide range
of options to select from. These range from cheap but effective to more costly than the Pi itself
(not hard) and looking fancy.
You could use a simple plastic case¹⁶ that can be brought for a few dollars;
For a very practical design and a warm glow from knowing that you’re supporting a worthy
cause, you could go no further than the official Raspberry Pi case¹⁷ that includes removable
side-plates and loads of different types of access. All for the paltry sum of about $9.
¹⁶http://www.dx.com/p/abs-case-box-for-raspberry-pi-b-black-346332
¹⁷https://www.raspberrypi.org/blog/raspberry-pi-official-case/
Operating Systems
An operating system is software that manages computer hardware and software resources for
computer applications. For example Microsoft Windows could be the operating system that will
allow the browser application Firefox to run on our desktop computer.
Variations on the Linux operating system are the most popular on our Raspberry Pi. Often they
are designed to work in different ways depending on the function of the computer.
Linux¹⁸ is a computer operating system that is can be distributed as free and open-source
software¹⁹. The defining component of Linux is the Linux kernel, an operating system kernel
first released on 5 October 1991 by Linus Torvalds.
Linux was originally developed as a free operating system for Intel x86-based personal comput-
ers. It has since been made available to a huge range of computer hardware platforms and is one
of the most popular operating systems on servers, mainframe computers and supercomputers.
Linux also runs on embedded systems, which are devices whose operating system is typically
built into the firmware and is highly tailored to the system; this includes mobile phones, tablet
computers, network routers, facility automation controls, televisions and video game consoles.
Android, the most widely used operating system for tablets and smart-phones, is built on top of
the Linux kernel. In our case we will be using a version of Linux that is assembled to run on the
ARM CPU architecture used in the Raspberry Pi.
The development of Linux is one of the most prominent examples of free and open-source
software collaboration. Typically, Linux is packaged in a form known as a Linux ‘distribution’, for
both desktop and server use. Popular mainstream Linux distributions include Debian, Ubuntu
and the commercial Red Hat Enterprise Linux. Linux distributions include the Linux kernel,
supporting utilities and libraries and usually a large amount of application software to carry out
the distribution’s intended use.
A distribution intended to run as a server may omit all graphical desktop environments from the
standard install, and instead include other software to set up and operate a solution stack such as
LAMP (Linux, Apache, MySQL and PHP). Because Linux is freely re-distributable, anyone may
create a distribution for any intended use.
Welcome to Raspbian
The Raspbian Linux distribution is based on Debian Linux. At the time of writing there have
been three different editions published. ‘Wheezy’, ‘Jessie’ and ‘Stretch’. Debian is a widely used
Linux distribution that allows Raspbian users to leverage a huge quantity of community based
experience in using and configuring software. The Wheezy edition is the earlier of the three and
was the stock edition from the inception of the Raspberry Pi till the end of 2015. From that point
Jessie was the default distribution until mid 2017 when Stretch took over.
¹⁸http://en.wikipedia.org/wiki/Linux
¹⁹http://en.wikipedia.org/wiki/Free_and_open-source_software
Operating Systems 20
Downloading
The best place to source the latest version of the Raspbian Operating System is to go to
the raspberrypi.org page; http://www.raspberrypi.org/downloads/. We will download the ‘Lite’
version (which doesn’t use a desktop GUI). If you’ve never used a command line environment,
then good news! You’re about to enter the World of ‘real’ computer users :-).
Raspbian Download
You can download via bit torrent or directly as a zip file, but whatever the method you should
eventually be left with an ‘img’ file for Raspbian.
To ensure that the projects we work on can be used with either the B+, B2 or B3 models we
need to make sure that the version of Raspbian we download is from 2015-01-13 or later. Earlier
downloads will not support the more modern CPU of the B2 or B3. To support the newer CPU
of the B3+ (and all the previous CPUs) we will need a version of Raspbian from 2018-03-13 or
later.
Image File
We should always try to download our image files from the authoritative source!
We will work through an example using Windows 7 but the process should be very similar for
other operating systems as we will be using the excellent open source software Etcher²⁰ which
is available for Windows, Linux and macOS.
Download and install Etcher and start it up.
Etcher Start
You will need an SD card reader capable of accepting your MicroSD card (you may require an
²⁰https://etcher.io/
Operating Systems 22
adapter or have a reader built into your desktop or laptop). Place the card in the reader and you
should see Etcher automatically select it for writing (Etcher is very good at presenting options
for installing that are only SD cards).
Etcher in progress
Etcher will write the image to the SD card. The time taken can vary a little, but it should only
take about 3-4 minutes with a class 10 SD card.
Once written, Etcher will validate the write process (this can be disabled if desired).
Operating Systems 23
Flash Complete!
When the process is finished Etcher will automatically unmount the SD card.
Powering On
Insert the card into the slot on the Raspberry Pi and turn on the power.
You will see a range of information scrolling up the screen before eventually being presented
with a login prompt.
Operating Systems 24
raspberrypi login:
We will use the Raspberry Pi Software Configuration Tool to change the locale and keyboard
configuration to suit us. This can be done by running the following command;
sudo raspi-config
The sudo portion of the command makes sure that you will have the permission required
to run the apt-get process.
Discovering Diverse Content Through
Random Scribd Documents
not libel or slander of which the law takes notice. Many privileged
occasions have been recognized. The occasion, with which we now
have to deal, is that a defamatory statement has been made either in
words or by writing in the course of an inquiry regarding the
administration of the law. It is beyond dispute that statements made
under these circumstances are privileged as to some persons, and it
has been admitted by the plaintiff’s counsel that one set of these
persons are advocates: it could not be denied that advocates are
privileged in respect of at least some defamatory statements made by
them in the course of an inquiry as to the administration of the law.
It was admitted that so long as an advocate acts bona fide and says
what is relevant, owing to the privileged occasion, defamatory
statements made by him do not amount to libel or slander, although
they would have been actionable if they had not been made whilst he
was discharging his duty as an advocate. But it was contended that
an advocate cannot claim the benefit of the privilege unless he acts
bona fide, that is, for the purpose of doing his duty as an advocate,
and unless what he says is relevant. That is the question which we
now have to determine. Certain persons can claim the benefit of the
privilege which arises as to everything said or written in the course of
an inquiry as to the administration of the law, and without making
an exhaustive enumeration I may say that those persons are judges,
advocates, parties, and witnesses. There have been decisions with
regard to three of these classes, namely, judges, parties, and
witnesses, and it has been held that whatever they may have said in
the course of an inquiry as to the administration of the law, has been
said upon a privileged occasion, and that they are not liable to any
action for libel or slander. But it has been suggested that only some
of these classes of persons can successfully claim the privilege of the
occasion, and those are judges, parties, and witnesses, who make
statements without malice and relevantly; and that those judges,
parties, and witnesses, who either speak or write without relevancy
and with malice, cannot successfully claim the privilege of the
occasion. I am inclined to think that with regard to these classes of
persons the law has not always been stated in the same manner by
the judges, and some judges have a strong objection to carry the
privilege beyond the point to which they are obliged by authority to
carry it; they are disinclined to admit the existence of the privilege.
Other judges are inclined to carry the privilege to its full extent, and
we must see what is the doctrine which has been finally adopted.
With regard to witnesses, the chief cases are, Revis v. Smith, 18 C. B.
126, 25 L. J. C. P. 195, and Henderson v. Broomhead, 4 H. & N. 569,
and with regard to witnesses, the general conclusion is that all
witnesses speaking with reference to the matter which is before the
court—whether what they say is relevant or irrelevant, whether what
they say is malicious or not—are exempt from liability to any action
in respect of what they state, whether the statement has been made
in words, that is, on viva voce examination, or whether it has been
made upon affidavit. It was at one time suggested that although
witnesses could not be held liable to actions upon the case for
defamation, that is, for actions for libel and slander, nevertheless
they might be held liable in another and different form of action on
the case, namely, an action analogous to an action for malicious
prosecution, in which it would be alleged that the statement
complained of was false to the knowledge of the witness, and was
made maliciously and without reasonable or probable cause. This
view has been supported by high authority; but it seems to me wholly
untenable. If an action for libel or slander cannot be maintained,
how can such an action as I have mentioned be maintained, it being
in truth an action for defamation in an altered form? Every objection
and every reason, which can be urged against an action for libel or
slander, will equally apply against the suggested form of action.
Therefore, to my mind, the best way to deal with the suggested form
of action is to dispose of it in the words of Crompton, J., in
Henderson v. Broomhead, where he said: “The attempts to obtain
redress for defamation having failed, an effort was made in Revis v.
Smith, 18 C. B. 126, 25 L. J. C. P. 195, to sustain an action analogous
to an action for malicious prosecution. That seems to have been done
in despair.” Nothing could be more strong, nothing could show more
clearly his entire disbelief in the possibility of supporting that new
form of action. The answer to the suggested form of action was that
during the hundreds of years which had elapsed such an action never
had been sustained. No reported case from the time of the
commencement of the common law until the present day can be
found in which the suggested form of action has been maintained,
and yet it is impossible to suppose that opportunities for bringing
actions of that kind and of carrying them to a conclusion have not
occurred again and again. However, the question is not as to the
form of the action, but whether an action of any kind will lie for
defamation uttered in the course of a judicial proceeding. Crompton,
J., in Henderson v. Broomhead, also said: “No action will lie for
words spoken or written in the course of any judicial proceeding. In
spite of all that can be said against it, we find the rule acted upon
from the earliest times. The mischief would be immense if the person
aggrieved, instead of preferring an indictment for perjury, could turn
his complaint into a civil action. By universal assent it appears that in
this country no such action lies. Cresswell, J., pointed out in Revis v.
Smith, 18 C. B. 126, that the inconvenience is much less than it would
be if the rule were otherwise. The origin of the rule was the great
mischief that would result, if witnesses in courts of justice were not
at liberty to speak freely, subject only to the animadversion of the
court.” It is there laid down that the reason for the rule with regard
to witnesses is public policy. In Scott v. Stansfield it was held that all
judges, inferior as well as superior, are privileged for words spoken
in the course of a judicial proceeding, although they are uttered
falsely and maliciously and without reasonable or probable cause.
The ground of the decision was that the privilege existed for the
public benefit: of course it is not for the public benefit that persons
should be slandered without having a remedy; but upon striking a
balance between convenience and inconvenience, between benefit
and mischief to the public, it is thought better that a judge should not
be subject to fear for the consequences of anything which he may say
in the course of his judicial duty. Therefore the cases of both
witnesses and judges fall within the rule as to privileged occasions,
notwithstanding it may be proved that any defamatory words spoken
by them were uttered from an indirect motive and to gratify their
own malice. In Dawkins v. Lord Rokeby, Law Rep. 8 Q. B. 255, it was
assumed for the purposes of the decision, that the defendant had
been guilty of both falsehood and malice; nevertheless it was held
that no action would lie against him for statements made by him as a
witness. The ground of the decision was no doubt that a witness in
giving his evidence should not be afraid of being sued for anything
that he might say. A similar view of the law was taken in Seaman v.
Netherclift; and the same rule has been applied to the parties. If
upon the grounds of public policy and free administration of the law
the privilege be extended to judges and witnesses, although they
speak maliciously and without reasonable or probable cause, is it not
for the benefit of the administration of the law that counsel also
should have an entirely free mind? Of the three classes—judge,
witness, and counsel—it seems to me that a counsel has a special
need to have his mind clear from all anxiety. A counsel’s position is
one of the utmost difficulty. He is not to speak of that which he
knows: he is not called upon to consider, whether the facts with
which he is dealing are true or false. What he has to do, is to argue as
best he can, without degrading himself, in order to maintain the
proposition which will carry with it either the protection or the
remedy which he desires for his client. If amidst the difficulties of his
position he were to be called upon during the heat of his argument to
consider whether what he says is true or false, whether what he says
is relevant or irrelevant, he would have his mind so embarrassed that
he could not do the duty which he is called upon to perform. For,
more than a judge, infinitely more than a witness, he wants
protection on the ground of benefit to the public. The rule of law is
that what is said in the course of the administration of the law, is
privileged; and the reason of that rule covers a counsel even more
than a judge or a witness. To my mind it is illogical to argue that the
protection of privilege ought not to exist for a counsel, who
deliberately and maliciously slanders another person. The reason of
the rule is, that a counsel, who is not malicious and who is acting
bona fide, may not be in danger of having actions brought against
him. If the rule of law were otherwise, the most innocent of counsel
might be unrighteously harrassed with suits, and therefore it is better
to make the rule of law so large that an innocent counsel shall never
be troubled, although by making it so large counsel are included who
have been guilty of malice and misconduct. In Rex v. Skinner, Lofft,
55, Lord Mansfield, a judge most skilful in enunciating the principles
of the law, treated a counsel as standing in the same position as a
judge or a witness. In Dawkins v. Lord Rokeby, Law Rep. 8 Q. B. 255,
at pp. 263, 264, 268, a most careful judgment was delivered on
behalf of all the judges in the Exchequer Chamber, and the opinion
of Lord Mansfield was cited and adopted. If the authority of these
two cases is to be followed, counsel are equally protected with judges
and witnesses. I will refer to Kennedy v. Hilliard, 10 Ir. C. L. Rep. N. S.
195, and in that case Pigott, C. B., delivered a most learned
judgment, in the course of which he said: “I take this to be a rule of
law, not founded (as is the protection in other cases of privileged
statements) on the absence of malice in the party sued, but founded
on public policy, which requires that a judge, in dealing with the
matter before him, a party in preferring or resisting a legal
proceeding, and a witness in giving evidence, oral or written, in a
court of justice, shall do so with his mind uninfluenced by the fear of
an action for defamation or a prosecution for libel.” 10 Ir. C. L. Rep.,
at p. 209. Into the rule thus stated the word “counsel” must be
introduced, and the rule may be taken to be the rule of the common
law. That rule is founded upon public policy. With regard to counsel,
the questions of malice, bona fides, and relevancy, cannot be raised;
the only question is, whether what is complained of has been said in
the course of the administration of the law. If that be so, the case
against a counsel must be stopped at once. No action of any kind, no
criminal prosecution, can be maintained against a defendant, when it
is established that the words complained of were uttered by him as
counsel in the course of a judicial inquiry, that is, an inquiry before
any court of justice into any matter concerning the administration of
the law.
I am of opinion that the rule of law is such as I have pointed out,
that it ought to be applied in the present case, and therefore that this
action cannot be maintained.
From our judgments it is obvious that we dissent from the opinion
of Lord Denman, C. J., expressed by him at Nisi Prius in Kendillon v.
Maltby, Car. & M. 402; 2 M. & R. 438.
Appeal dismissed.[457]
SEAMAN v. NETHERCLIFT
In the Court of Appeal, December 15, 1876.
Reported in 2 Common Pleas Division, 53.
Appeal from the decision of the Common Pleas Division, ordering judgment to
be entered for the defendant. 1 C. P. D. 540.
Claim: That defendant said of a will, to the signature of which the plaintiff was a
witness, “I believe the signature to the will to be a rank forgery, and I shall believe
so to the day of my death,” meaning that the plaintiff had been guilty of forging the
signature of the testator, or of aiding and abetting in the forgery.
Defence: That defendant spoke the words in the course of giving his evidence as
a witness on a charge of forgery before a magistrate.
Reply: That the words were not bona fide spoken by defendant as a witness, or
in answer to any question put to him as a witness, and he was a mere volunteer in
speaking them for his own purposes otherwise than as a witness and maliciously
and out of the course of his examination.[458]
Cockburn, C. J. The case is, to my mind, so abundantly clear, and I believe to
the minds of my learned brothers, that I think we ought not to hesitate to at once
pronounce our decision.
The plaintiff brings his action against the defendant for slander, alleged to have
been uttered on the occasion of a prosecution for forgery before a magistrate of the
city of London. The defence set up is: “True, I did utter the words imputed to me,
but I spoke them when I was a witness in a case in which I was called as a witness.”
The plaintiff’s answer to that is, “Yes, you were called as a witness, but you spoke
these words when you were no longer giving evidence, and not only knowing them
to be false, but also not in the inquiry, and dehors altogether the subject-matter of
the inquiry, for your own purpose of maliciously defaming me.” At the trial before
Lord Coleridge it appeared that in the Probate suit of Davies v. May the defendant
had been examined, as an adept, to express his opinion as to the genuineness of a
signature to a will, and he gave it as his opinion that the signature was a forgery.
The president of the court, in addressing the jury, made some very strong
observations on the rashness of the defendant in expressing so confident an
opinion in the face of the direct evidence. Soon afterwards, on a prosecution for
forgery before the magistrate, the defendant was called as an adept by the person
charged, when he expressed an opinion favorable to the genuineness of the
document. He was then asked by the counsel for the prosecution whether he had
been a witness in the suit of Davies v. May. He answered, “Yes.” And he was then
asked, “Did you read a report of the observations which the presiding judge made
on your evidence?” He again said, “Yes.” And then the counsel stopped. I presume
the circumstances of the trial were well known, and the counsel thought he had
done enough. The defendant, the witness, expressed a desire to make a statement.
The magistrate told him he could not hear it. Nevertheless the defendant persisted
and made the statement, the subject-matter of this action of slander.
On the proof of these facts Lord Coleridge reserved leave to the defendant to
move to enter judgment, if the court should be of opinion that there was no
evidence on behalf of the plaintiff which ought to be left to the jury. It occurred to
him, however, that it would be as well to take the opinion of the jury, and they
found that the replication was true, viz., that the words were spoken, not as a
witness in the course of the inquiry, but maliciously for his own purpose, that is,
with intent to injure the plaintiff. Upon these findings judgment was entered for
the plaintiff, leave being again reserved to enter judgment for the defendant, and
the Court of Common Pleas gave judgment for the defendant.
Now, if the findings of the jury had been founded upon evidence by which they
could have been supported, I might have had some hesitation about the decision.
But they were not; and we are asked to come to a conclusion contrary to what has
been established law for nearly three centuries.
If there is anything as to which the authority is overwhelming it is that a witness
is privileged to the extent of what he says in course of his examination. Neither is
that privilege affected by the relevancy or irrelevancy of what he says; for then he
would be obliged to judge of what is relevant or irrelevant, and questions might be,
and are, constantly asked which are not strictly relevant to the issue. But that,
beyond all question, this unqualified privilege extends to a witness is established
by a long series of cases, the last of which is Dawkins v. Lord Rokeby, Law Rep. 7
H. L. 744, after which to contend to the contrary is hopeless. It was there expressly
decided that the evidence of a witness with reference to the inquiry is privileged,
notwithstanding it may be malicious; and to ask us to decide to the contrary is to
ask what is beyond our power. But I agree that if in this case, beyond being spoken
maliciously, the words had not been spoken in the character of a witness or not
while he was giving evidence in the case, the result might have been different. For I
am very far from desiring to be considered as laying down as law that what a
witness states altogether out of the character and sphere of a witness, or what he
may say dehors the matter in hand, is necessarily protected. I quite agree that what
he says before he enters or after he has left the witness-box is not privileged, which
was the question in the case before Lord Ellenborough. Trotman v. Dunn, 4 Camp.
211. Or if a man when in the witness-box were to take advantage of his position to
utter something having no reference to the cause or matter of inquiry in order to
assail the character of another, as if he were asked, “Were you at York on a certain
day?” and he were to answer, “Yes, and A. B. picked my pocket there;” it certainly
might well be said in such a case that the statement was altogether dehors the
character of witness, and not within the privilege.
If, therefore, the findings of the jury, that the defendant had ceased to be a
witness when he spoke the words, were justified by the evidence, I should hesitate
before I decided in his favor. But I think the defendant was entitled to judgment on
the first reservation. There was no evidence to go to the jury upon the plaintiff’s
case. What the defendant said was said in his character of witness; for there can be
no doubt that the words were spoken in consequence of the question put to him by
counsel for the prosecution, the object and effect of the cross-examination having
been to damage his credibility as a witness before the magistrate, and of this the
witness was conscious. The counsel, having put the question, stops; and if there
had been counsel present for the prisoner who had re-examined the witness, he
would have put the proper questions to rehabilitate him to the degree of credit to
which he was entitled. That such questions would have been relevant I cannot
bring myself for a moment to doubt, relating as they do to the credibility of the
witness, which is part of the matter of which the magistrate has to take cognizance.
That being so, the witness himself, who is sworn to speak the whole truth, is
properly entitled, not only with a view to his own vindication, but in the interest of
justice, to make such an observation in explanation of his former answer as is just
and fair under the circumstances. That is what the defendant did. The sitting
magistrate having allowed the disparaging question to be put and answered, ought
not to have interfered to prevent the defendant from giving an explanation. I think
the statement, coming immediately after the damaging question had been put to
him, must be taken to be part of his testimony touching the matter in question, as
it affects his credibility as a witness in the matter as to which he was called. It was
given as part of his evidence before he had become divested of his character of
witness; and but for the question of the opposite counsel he never would have
made the statement at all.
As to the finding of malice, it is true that what the defendant said might possibly
have the effect of damaging the plaintiff’s character; but can any one suppose that
the defendant had this in his mind when he spoke, or that he intended to injure the
plaintiff? He thought only of his own credit as a witness, which had been attacked.
He spoke, on the impulse of the moment, no doubt very foolishly; and it was
probably his foolish persistence in maintaining the same attitude and setting up
his own opinion against the positive testimony of the other witnesses that
prejudiced the jury against him, and led them to return the findings they did,
founded, in reality, upon no evidence at all. In my opinion, the Lord Chief Justice
should have nonsuited the plaintiff, which is the conclusion at which the Court of
Common Pleas ultimately arrived; for there really was no evidence that the
defendant was speaking otherwise than as a witness and relevantly to the matters
in issue, because relevantly to his own character and credibility as a witness in the
matter. That being so, even if express malice could have been properly inferred
from the circumstances, the case of Dawkins v. Lord Rokeby, Law Rep. 7 H. L. 744,
conclusively decides that malice has ceased to be an element in the consideration
of such cases, unless it can be shown that the statement was made not in the course
of giving evidence, and therefore not in the character of a witness. A long series of
authorities, from the time of Elizabeth to the present time, has established that the
privilege of a witness while giving evidence is absolute and unqualified. Allardice v.
Robertson, 1 Dow, N. S. 495, 515, was relied upon by Mr. Chambers. That was the
case of an action against a magistrate for words spoken on the bench, and Lord
Wynford expressly distinguishes the two cases, and says that the privilege of a
judge of the superior courts does not apply to the judge of an inferior court; and
that in the case of the latter the privilege is not absolute and unqualified, and that a
“subordinate judge” would be liable to an action if malice were proved. It does not,
therefore, touch the present case; and as to a witness speaking with reference to
the subject-matter of the issue, it is clear that the privilege is unqualified.
The judgment of the Common Pleas Division must, therefore, be affirmed.
Bramwell, J. A. I am of the same opinion. The judgment of the Common Pleas
affirmed two propositions. First, that what the defendant said was said as a
witness, and was relevant to the inquiry before the magistrate; secondly, that, that
being so, the Lord Chief Justice should have stopped the trial of the action by
nonsuiting the plaintiff.
As to the first proposition, I am by no means sure that the word “relevant” is the
best word that could be used; the phrases used by the Lord Chief Baron and the
Lord Chancellor in Dawkins v. Lord Rokeby, Law Rep. 7 H. L., at p. 744, would
seem preferable, “having reference,” or “made with reference to the inquiry.” Now,
were the judges of the Common Pleas Division right in holding that this statement
of the defendant had reference to the inquiry? I think that they were. There can be
no doubt that the question put by the cross-examining counsel ought not to have
been allowed: “Have you read what Sir James Hannen is reported to have said as
to your evidence in Davies v. May?” What Sir James Hannen had said in a former
case was not evidence. It was, therefore, an improper question, and the answer to
it, if untrue, would not have subjected the witness to an indictment for perjury. But
the question having been put, and the answer having been in the affirmative—and
the question being, as Lord Coleridge observed, “ingeniously suggestive,” viz., that
the way the defendant had been dealt with on the former occasion did not redound
to his credit as a witness—the defendant insisted on making in addition the
statement complained of. He did so, in my opinion, very foolishly. It would have
been better to have been satisfied with retaining his own opinion without setting it
up in direct opposition to the positive testimony of eye-witnesses. But he foolishly,
as I think, and coarsely exclaimed, “I believe that will to be a rank forgery, and
shall believe so to the day of my death.” Suppose after he had said “yes,” he had
added in a decent and becoming manner, “and I am sorry Sir James Hannen said
what he did, for I took great pains to form my own opinion, and I shall always
retain it, as I still think it right.” Would not that have had reference to the inquiry
before the magistrate? And would it not have been reasonable and right that the
witness should have added that statement in justification of himself? Surely, yes.
Mr. Clarke said he was prepared to maintain that as long as a witness spoke as a
witness in the witness-box, he was protected, whether the matter had reference to
the inquiry or not. I am reluctant to affirm so extreme a proposition. Suppose
while the witness is in the box, a man were to come in at the door, and the witness
were to exclaim, “That man picked my pocket.” I can hardly think that would be
privileged. I can scarcely think a witness would be protected for anything he might
say in the witness-box, wantonly and without reference to the inquiry. I do not say
he would not be protected. It might be held that it was better that everything a
witness said as a witness should be protected, than that witnesses should be under
the impression that what they said in the witness-box might subject them to an
action. I certainly should pause before I affirmed so extreme a proposition, but
without affirming that, I think the words “having reference to the inquiry” ought to
have a very wide and comprehensive application, and ought not to be limited to
statements for which, if not true, a witness might be indicted for perjury, or the
exclusion of which by the judge would give ground for a new trial; but ought to
extend to that which a witness might naturally and reasonably say when giving
evidence with reference to the inquiry as to which he had been called as a witness.
Taking that view, I think the first proposition is established, that the statement of
the defendant was made as witness and had reference to the inquiry.
As to the second proposition, that, if the first be made out, no inquiry can be
gone into as to whether the statement was false or malicious or as a volunteer, we
are bound by authority. The case of Dawkins v. Lord Rokeby, Law Rep. 7 H. L. 744,
is directly in point, and binding upon us even if we disliked the decision. Mr.
Chambers has not attempted to distinguish that case except on the ground that the
inquiry in that case was before a military court. But it is clearly not distinguishable
on that ground. The learned Lords determined that what is true of a civil tribunal is
true of a military court of inquiry; and they affirmed most distinctly the
proposition that if the evidence has reference to the inquiry, the witness is
absolutely privileged. There is also the case in the Court of Error of Henderson v.
Broomhead, 4 H. & N. 569, which is precisely to the same effect, and
undistinguishable from the present case.
I am, therefore, of opinion that the judgment of the Common Pleas Division was
right, and must be affirmed.
Judgment affirmed.[459]
WHITE v. CARROLL
Court of Appeals, New York, March 18, 1870.
Reported in 42 New York Reports, 161.
RICE v. COOLIDGE
Supreme Judicial Court, Massachusetts, December 1,
1876.
Reported in 121 Massachusetts Reports, 393.
RYALLS v. LEADER
In the Exchequer, May 26, 1866.
Reported in Law Reports, 1 Exchequer, 296.
USILL v. HALES
In the Common Pleas Division, January 30, 1878.
Reported in 3 Common Pleas Division, 319.
WASON v. WALKER
In the Queen’s Bench, November 25, 1868.
Reported in Law Reports, 4 Queen’s Bench, 73.