100% found this document useful (1 vote)
3 views

Raspberry Pi Computing Analog Measurement 1st Malcolm Maclean pdf download

The document is about the book 'Raspberry Pi Computing Analog Measurement' by Malcolm Maclean, which provides insights into analog measurement using Raspberry Pi. It includes links to download the book and other related titles, along with a detailed table of contents covering various aspects of Raspberry Pi computing. The content is aimed at individuals interested in learning about Raspberry Pi and its applications in computing and electronics.

Uploaded by

bertokqarloq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
3 views

Raspberry Pi Computing Analog Measurement 1st Malcolm Maclean pdf download

The document is about the book 'Raspberry Pi Computing Analog Measurement' by Malcolm Maclean, which provides insights into analog measurement using Raspberry Pi. It includes links to download the book and other related titles, along with a detailed table of contents covering various aspects of Raspberry Pi computing. The content is aimed at individuals interested in learning about Raspberry Pi and its applications in computing and electronics.

Uploaded by

bertokqarloq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

Raspberry Pi Computing Analog Measurement 1st

Malcolm Maclean download

https://ebookbell.com/product/raspberry-pi-computing-analog-
measurement-1st-malcolm-maclean-47409000

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Raspberry Pi Computing Analog Measurement Malcolm Maclean

https://ebookbell.com/product/raspberry-pi-computing-analog-
measurement-malcolm-maclean-232307276

Raspberry Pi Computing Monitoring With Prometheus And Grafana 2024


Update Malcolm Maclean

https://ebookbell.com/product/raspberry-pi-computing-monitoring-with-
prometheus-and-grafana-2024-update-malcolm-maclean-54791064

Learn Electronics With Raspberry Pi Pysical Computing With Circuits


Sensors Outputs And Projects Watkiss

https://ebookbell.com/product/learn-electronics-with-raspberry-pi-
pysical-computing-with-circuits-sensors-outputs-and-projects-
watkiss-22006172

Learn Electronics With Raspberry Pi Physical Computing With Circuits


Sensors Outputs And Projects 2nd Ed Stewart Watkiss

https://ebookbell.com/product/learn-electronics-with-raspberry-pi-
physical-computing-with-circuits-sensors-outputs-and-projects-2nd-ed-
stewart-watkiss-22417580
Cuttingedge Computing With Raspberry Pi Krystyna Poray Goddu

https://ebookbell.com/product/cuttingedge-computing-with-raspberry-pi-
krystyna-poray-goddu-48692838

Computing With The Raspberry Pi Command Line And Gui Linux 1st Edition
Brian Schell

https://ebookbell.com/product/computing-with-the-raspberry-pi-command-
line-and-gui-linux-1st-edition-brian-schell-23627082

Make Games With Python Create Your Own Entertainment With Raspberry Pi
1st Edition Sean M Tracey

https://ebookbell.com/product/make-games-with-python-create-your-own-
entertainment-with-raspberry-pi-1st-edition-sean-m-tracey-50478096

Experiment With The Sense Hat 1st Edition Raspberry Pi

https://ebookbell.com/product/experiment-with-the-sense-hat-1st-
edition-raspberry-pi-5465058

Official Raspberry Pi Camera Guide Raspberry Pi

https://ebookbell.com/product/official-raspberry-pi-camera-guide-
raspberry-pi-11115238
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

The History of the Raspberry Pi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

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

Setting up the Raspberry Pi Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52


Web Server, PHP and Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Install NGINX and PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Create a database and a table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

Connecting Analog Sensors to the Raspberry Pi . . . . . . . . . . . . . . . . . . . . . . . . 57


Analog and Digital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Analog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Digital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
The Boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
The Analog Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
The Light Dependant Resistor (LDR or Photoresistor) . . . . . . . . . . . . . . 59
Analog to Digital Conversion (ADC) . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
The ADS1015 Analog to Digital Converter . . . . . . . . . . . . . . . . . . . . . 61
Measure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Hardware required . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Connect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
CONTENTS

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

Directory Structure Cheat Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138


Introduction
Welcome!
Hi there. Congratulations on getting your hands on this book. You’re interested in learning about
connecting analog sensors to the Raspberry Pi. So, you’ve come to the right place.
This will be a journey of discovery for both of us. By experimenting with computers we will
be learning about what is happening in the physical environment. Others have done this sort of
thing, but I have an ulterior motive. I write books to learn and document what I’ve done. The
hope is that by sharing the journey others can learn something from my efforts :-).
Ambitious? Maybe :-). But if you’re reading this, I managed to make some headway. I dare say
that like other books I have written (or are currently writing) it will remain a work in progress.
They are living documents, open to feedback, comment, expansion, change and improvement.
Please feel free to provide your thoughts on ways that I can improve things. Your input would
be much appreciated.
You will find that I eschew a simple “Do this approach” for more of a story telling exercise. Some
explanations are longer and more flowery than might be to everyone’s liking, but there you go,
that’s my way :-).
There’s a lot of information in the book. There’s ‘stuff’ that people with a reasonable under-
standing of computers will find excessive. Sorry about that. I have gathered a lot of the content
from other books I’ve written to create this guide. As a result, it is as full of usable information
as possible to help people who could be using the Pi and coding for the first time. Please bear
in mind, this is the description of ONE simple project. I could describe it in 5 pages but I have
stretched it out into a lot more. If we need to recreate the project from scratch, this guide will
leave nothing out. It will also form a basis for other derivative books (as books before this one
have done). As the Raspberry Pi’s and OS’s improve, the descriptions will evolve.
I’m sure most authors try to be as accessible as possible. I’d like to do the same, but be warned…
There’s a good chance that if you ask me a technical question I may not know the answer. So
please be gentle with your emails :-).
Email: [email protected]
Cover photo via Good Free Photos¹ and fluxworkshop².

¹https://www.goodfreephotos.com
²https://www.ebay.com/usr/fluxworkshop
Introduction 2

What are we trying to do?


Put simply, we are going to examine the wonder that is the Raspberry Pi computer and use it to
accomplish something.
In this specific case we will be connecting an analog sensor (specifically a Light Dependent
Resistor (LDR)) to an Analog to Digital Converter (ADC) which will be connected to the Pi.
We’ll be measuring the values that it returns, recording them in a database and then making
those values available via web a interface!
Along the way we’ll;

• Look at the Raspberry Pi and its history.


• Work out how to get software loaded onto the Pi.
• Learn about networking and configure the Pi accordingly.
• Install and configure a web server and a database.
• Write some code to interface with our ADC and our LDR.

Who is this book for?


You!
By getting hold of a copy of this book you have demonstrated a desire to learn, to explore and
to challenge yourself. That’s the most important criteria you will want to have when trying
something new. Your experience level will come second place to a desire to learn.
It may be useful to be comfortable using the Windows operating system (I’ll be using Windows
7 for the set-up of the devices). You should be aware of Linux as an alternative operating system,
but you needn’t have tried it before. Before you learn anything new, it pretty much always
appears indistinguishable from magic. but once you start having a play, the mystery falls away.

What will we need?


Well, you could just read the book and learn a bit. By itself that’s not a bad thing, but trust me
when I say that actually experimenting with physical computers is fun and rewarding.
The list below is flexible in most cases and will depend on how you want to measure the values.

• A Raspberry Pi (I’m using a Raspberry Pi Model B 2 / 3)


• Probably a case for the Pi
• A MicroSD card
• A power supply for the Pi
• A keyboard and monitor that you can plug into the Pi (there are a few options here, read
on for details)
• A remote computer (like your normal desktop PC that you can use to talk to connect to the
Pi). This isn’t strictly necessary, but it makes the experience way cooler.
Introduction 3

• 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.

Why on earth did I write this rambling tome?


That’s a really good question. This is another project that I wanted to update from an earlier book
(Raspberry Pi: Measure, Record, Explore⁵) and to be brutally hones I picked it at random over
other options. Writing the previous books in this series⁶ was an enjoyable process, so I thought
that I’d carry on and continue to adapt the book for subsequent projects. This is book three in
this series, so I suppose it’s a ‘thing’ by now. Will this continue? Who knows, stay tuned…
Included is a bunch of information from my books on the Raspberry Pi, Linux and d3.js. I hope
you find it useful.

Where can you get more information?


The Raspberry Pi as a concept has provided an extensible and practical framework for introduc-
ing people to the wonders of computing in the real world. At the same time there has been a
boom of information available for people to use them. The following is a far from exhaustive list
of sources, but from my own experience it represents a useful subset of knowledge.
raspberrypi.org⁷
Google+⁸
reddit⁹
Raspberry Pi Stack Exchange¹⁰

³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.

Early Alpha Board (Credit: Paul Downey)

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.

raspberrypi.org blog lights the fuse.

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

Raspberry Pi B+ and Raspberry Pi B2

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.

The Raspberry Pi B+ Board

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+, B2, B3 and B3+

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)

Raspberry Pi B+ USB Ports


Random documents with unrelated
content Scribd suggests to you:
LORD STRATHCONA—LORD MOUNT STEPHEN—SIR WILLIAM VAN HORNE

“I’m sorry, Mistah Blake, that I swore and cussed as I did, an’
I’ve gotta ’pologize, but ye see, Mistah Blake, that blankety, blank
son of a black, blank his blank eyes, soaked me good an’ hard wif’
his blankety blank ol’ water an’—”
But he got no further, for Mr. Blake, convulsed with laughter, said
it was all right. And Jimmy told me afterwards that it was a hell of
an apology.
Early Advertising.
When the passenger service of the C.P.R. was inaugurated, the
citizens of Montreal, Toronto, Ottawa and other large centres were
puzzled and astonished one morning on seeing numerous billboards
decorated with streamers on which were printed: “Said the Prince to
the Duke: ‘How high we live on the C.P.R.’ ” and “What the Duke said
to the Prince: ‘All sensible people travel by the C.P.R.’ ” “Parisian
Politeness on the C.P.R.” “Great Salome on the C.P.R.” “Wise Men of
the East Go West on the C.P.R.” and “By Thunder-Bay passes the
C.P.R.,” the final four words of the latter being in comparatively small
type.
They created quite a little stir at the time, being something novel
in advertising. Twenty-five years later an advertising man recalled
the advertisements and gave as his opinion that they were no good,
and also intimated that they were really idiotic. “And yet you
remember them for a quarter of a century?” I asked. “They must
have been pretty good advertising.”
And they were.
His Work in Cuba.
At the time that Sir William Van Horne was constructing his
railroad in Cuba, the “Foracker Resolution” was in force, and its
terms prohibited any public concession to build railroads or other
public works during the life of the U.S. Interventory Government. In
spite of this, however, Sir William went ahead with the Cuba railroad,
by getting private right-of-way agreements with owners of land over
which the railroad was to run. He skipped all public roads and lands,
and at the conclusion of the office of the Interventory Government,
the Cuban Administration authorized the road so that the missing
stretches were constructed, and the road went into operation almost
immediately.
When Sir William was constructing this railroad, he decided to
install a typical railroad hotel in Camaguey, and with his keen eye for
detail he had an idea for its decoration.
“Why not fit up one of the parlors,” said he, “with panellings of
the beautiful native woods of the island? It seems to me that such a
room would interest visitors greatly, and give a handsome effect.”
His suggestion was carried out to the letter. Next time he arrived
in Camaguey the hotel was practically complete, and Sir William
recollected his hardwood room and expressed a desire to see it.
There was a singular lack of enthusiasm on the part of the officials,
and they didn’t make any effort to hurry out Sir William, who was
deaf, dumb and blind to the beauty of the weather, the excellence of
the service, and the sudden death of anybody’s great-grandmother.
He wanted to see that hardwood room, and with drooping eyes and
ears, everybody, checkmated, led him to it.
It had been panelled in all the different varieties of beautiful
native hardwoods, according to schedule, from ceiling to floor. It had
given a beautiful effect, as Sir William had foreseen. And then a
gang of native painters, putting finishing touches on halls and
corridors, had wandered in, observed its painlessness, and given it
two heavy coats of ivory white.
Like the black on a colored person, it wouldn’t wash off, and
ivory-white that parlor still is and provoked Sir William’s great disgust
to his dying day.
When Sir William passed away, there was general sorrow, and a
feeling that in his death Canada and the world had lost a great man
whose name will live in history.
Lord Shaughnessy.
T. G. Shaughnessy was the natural and logical successor to the
presidency. He had made a name and acquired distinction in railway
circles through the great purchasing system which he formulated,
and which, by the way, was adopted by the city of New York. It had
been a life’s study with him, and beginning at the age of fifteen with
the Milwaukee road, he quickly rose in the service and was selected
in 1882 to take charge of the purchasing department of the C.P.R. In
two years he was made assistant to the general manager, and in five
became assistant to the president. In 1891 he became a director
and vice-president. Then came the presidency to him in less than
eight years, and with it honors from the King, who created him a
Knight Bachelor, a Knight Commander of the Victorian Order, and
greatest of all, a Peer of the Realm—Baron Shaughnessy, K.C.V.O., of
Montreal, Canada, and of Ashford, County Limerick, Ireland. In
another way he has gained an equally high distinction in that of
being “the greatest living Canadian,” as he is claimed to be by those
who, knowing him best, appreciate his many estimable qualities of
head and heart, his great executive ability, his unerring business
judgment, his untiring energy, and his undoubted honesty and
integrity. He ever enjoyed the fullest confidence of his board of
directors and of his subordinates, and was always “the court of last
resort” in cases of disagreement between the company and its
employees, owing to his high sense of honor and fair play.
While Lord Shaughnessy has acquired wealth, it was not for
money alone he labored unceasingly, but from an earnest and
honest endeavor to benefit Canada, through making his railroad a
powerful factor in its development. Many instances could be given
where the interests of the country overshadowed those of the
company, and Lord Shaughnessy never hesitated a moment as to
what course to pursue when duty called. For instance, during the
continued strikes some years ago in the western coal mines, there
was every prospect of a dire scarcity of coal on the prairies.
Regardless of cost, he instructed that hundreds of thousands of tons
of Pennsylvania anthracite should be purchased and distributed at
advantageous points to furnish the settlers with fuel should the
threatened shortage materialize. Fortunately, the strikes were called
off just in time to avert the impending catastrophe, but to ensure
the settlers an ample supply, the C.P.R. refused to buy the cheaper
coal at the mines, and utilized its own more costly supply. And this
cost the company a round million of dollars. But it would have saved
many a settler from perishing on the prairies had not the strikes
been settled.
Lord Shaughnessy’s Big Heart.
Maintaining the strictest discipline, usually dignified, he was one
of the kindest of men, and frequently looked leniently upon the
errors of omission and commission of those under him. His
generosity was unbounded, and in helping many a “lame dog over
the stile”—well, that was a matter solely between the benefactor and
the benefited. His home life has always been an ideal one, with Lady
Shaughnessy an able and kindly helpmate, and dutiful children to
brighten the hearth. But, as in the case of many another household,
keen, bitter sorrow has entered. I shall never forget when the news
came of the tragic death of his son, Fred, who lost his life in the
defence of his country in France in 1916, how rapidly the heart-
broken father had aged, and how sympathetically he grasped my
hand, and with tear-dimmed eyes recalled memories of the dead
boy, of whom I, too, was especially fond. Poor, dear Fred, his
memory will linger long with many, for he was a bright cheerful lad—
we always looked upon him as a boy—with many admirable
qualities. Nor shall I ever forget his coming to me when he was in
the service of the C.P.R., and bemoaning his fate. “It’s awful,” he
would say to me, “to be the president’s son. Of course, I don’t mind
obeying the rules and regulations of the company, and I work the
same hours as anybody else, but hang it all, it’s a constant complaint
that I am favored because I am the president’s son, when, perhaps,
I am favored less than the others. Why, father wouldn’t allow it. I
am going to quit.”
And he did.
Of a naturally modest, retiring disposition, except when
aggressiveness demanded other qualities, Lord Shaughnessy disliked
the limelight into which his prominence in social and business circles
forced him, and I doubt if he did not enjoy a quiet game of solitaire
or a few hours on the links far better than he did the great glittering
banqueting board or other public festivities. He is an ideal host, and
enjoys having companionable people with him. I remember meeting
him one morning when the Eucharistic Congress was being held in
Montreal. He wore a bright cheery smile and laughingly remarked:
“Yes, I had a very pleasant morning. Met Cardinal Gibbons and
Archbishop Ireland at the station and drove them to my house.
When we arrived there, the Cardinal kindly remarked, ‘Make yourself
at home, Shaughnessy, we are.’ ”
It was that little touch of human nature that appealed to him.
He Eschewed Public Honors.
Although closely and prominently connected with many public
movements, especially those of a patriotic and charitable character,
an exceptionally able and forcible speaker, with a full knowledge of
the world’s affairs, Lord Shaughnessy could never be induced to
enter political life, although he was frequently approached with
tempting offers to devote himself to public affairs. He could have at
different times been a Cabinet Minister or the leader of the
Opposition, but he invariably declined. The presidency of the C.P.R.
was the height of his ambition. Besides, between you and me, his
ideas of how governments should be run—on strictly business
principles—would probably not have retained the staunch support of
the practical politician and the ward healer and others of that stripe.
This incident may give an idea of his attitude:
BARON SHAUGHNESSY, K.C.V.O.
In 1911, several weeks before the general election, a telegram—
prompted, no doubt, by the appearance of Sir William Van Horne at
several of the Conservative meetings—was received from an Ontario
news agency. It read:
“Sir Thos. Shaughnessy,
Montreal.
“Reported here that ‘C.P.’ behind anti-reciprocity movement. Is
this correct?”
Without a moment’s hesitation the following reply was dictated
and sent off:
“Yes! ‘C.P.’ behind anti-reciprocity movement—‘Canadian People.’
T. G. Shaughnessy.”
He held pronounced views on the temperance question, and,
while not by any means a total abstainer, believed that intoxicants
should be greatly restricted and sparingly used. When the Montreal
Witness attacked the C.P.R. for selling liquor on its dining-cars, I
called upon my good friend, John Dougall, the editor of that paper,
and explained that the flask had almost entirely disappeared from
the smoking-rooms in the trains through passengers being able to
get a drink in the diner. It was the same old story of Adam and Eve
and the forbidden fruit. My argument was that the C.P.R. was as
great a temperance reformer as any temperance organization, for no
trainman was allowed to go on his run if there was the slightest taint
of liquor on his breath, and sobriety was required of all employees
when on duty. Besides, when one happened to fall from grace, he
was called on the carpet, and a repetition of his offence was
punished with dismissal. Then I instanced that once, out at Moose
Jaw, when Lord Shaughnessy saw some trainmen entering the bar at
the company’s hotel, he called to Sir William Whyte: “Whyte close
that bar.” Several hours passed and Lord Shaughnessy noticed that
the bar was still open. Calling Sir William, he sharply said: “Whyte, I
told you to close that bar. Why wasn’t it closed?”
“I am going to do so to-night at closing time.”
“No, you’re not. Close it now.”
And it was closed instanter.
His Repartee Like Rapier Thrust.
With the sole object of encouraging the thoroughbred horse
industry in the Province of Quebec, Lord Shaughnessy not only
became a member of the then newly-formed Montreal Jockey Club,
but also imported a fashionably-bred race mare. Although highly
recommended this mare “Silk Hose” finished in most of her races a
very bad last. In one when she had galloped past the stand probably
thirty lengths behind the other starters, Charles M. Hays, then
president of the G.T.R., who was standing beside Lord Shaughnessy,
remarked, “That’s a fast mare you have, Shaughnessy.”
“Yes,” replied Lord Shaughnessy, “she’s about as fast as a Grand
Trunk train.”
After her unsuccessful racing career, “Silk Hose” was placed in
the stud. Her first foal, a filly named “Lisle Hose,” seemed to inherit
the mother’s hoo-doo. She became ill as a yearling; was sick as a
two-year-old, and the following season—died. The morning after she
“kicked out,” Tom Callary, his secretary, told his lordship that he had
bad news for him. “What is it?” he asked. “The trainer has just told
me that the filly died last night—”
“That’s not bad news,” replied Lord Shaughnessy. “That’s good
news; we won’t have to feed the blessed thing any longer, will we?”
When her second foal—this one a colt—became sick also as a
two-year-old, and was thereby unable to race; and when, the
following spring—unlike the maple trees—he did not show the least
inclination to run, Lord Shaughnessy told Callary to do whatever he
pleased with the colt. This colt, that had been named “Silk Bird,”
eventually got to the races. Before the first start his secretary
informed Lord Shaughnessy that he thought the colt had a good
chance to win.
“What is it,” asked his lordship, “a walking race?”
He never could be persuaded to make a bet, remarking on one
occasion “that he wouldn’t bet on that horse even if it were alone in
the race.” And yet this colt, probably the best thoroughbred raised in
the Province of Quebec, won, not only his first start but also nine or
ten other races, including the King’s Plate of 1916. But the winnings
of that season, that should have gone to recoup the losses sustained
during the several lean years, were distributed under his Lordship’s
direction, to the hospitals and charitable institutions most in need at
the time. Many people must have wondered when they saw the
name “Silk Bird” amongst the lists of subscribers, more especially as
the contributions were rather “hefty.” And then to cap all, and, as it
were, to make it unanimous, his Lordship gave away the colt.
As I stated previously, Lord Shaughnessy absolutely refused to
bet on the chances of his colt, but there were employees by the
score who backed “the C.P.R. horse,” (as he was known throughout
the country) at every start. And as he won with prices ranging
against him from “evens” to as high as forty-to-one, his supporters,
unlike his owner, came out well ahead. No better indication could be
had of the loyalty to, and affection for, “the big boss,” than by the
manner in which all those under his Lordship pulled so whole-
heartedly and so consistently, in good years and in bad, for the
success of the Shaughnessy colors—old gold and scarlet—whenever
and wherever they appeared on the Canadian tracks. On race days
the secretary was bombarded with telephone calls from vice-
presidents right down to call boys, enquiring as to the colt’s chances,
his condition, the name of the jockey, etc., etc. But Lord
Shaughnessy knew nothing of this very important feature of his
secretary’s duties.
Hats Off to the Chief.
When Lord Shaughnessy relinquished the presidency, he became
chairman of the board, and is to be found in his office every week-
day when in town, maintaining an active interest in the affairs of the
company. When his successor was appointed, Lord Shaughnessy,
much to Mr. Beatty’s chagrin, insisted upon changing offices with
him, and the new president reluctantly took possession of the more
pretentious quarters. The next day there was a presentation of a
silver shield which Lord Shaughnessy had given to the Order of St.
John’s Ambulance Association. It took place in the board room of the
Windsor Street Station. The ex-president was a few minutes late,
and he cheerfully apologized, quaintly adding: “But it makes no
difference. I am only a supernumerary now.” And that showed the
kind of man Lord Shaughnessy is.
Beloved by all, with an affection that permeates the ranks from
the higher to the lower grades, still in harness, Lord Shaughnessy’s
evening of life is pleasantly passed, and the hope is fervently
expressed, not only by those who have grown grey in the service,
but by thousands of others, that the “T.G.” of years ago, of “Mr.
President,” of “Sir Thomas” and “My Lord” will long remain to be the
“guide, philosopher and friend” of those, who, like myself, have
learned his actual worth, fully realize the true nobility of his
character, and fondly cherish the inspiring memories of his unfailing
loyalty and deep-rooted affection and friendship.
Hats off to the Chief, boys, hats off!
The Present President.
If I were writing an article about a man, in which I was desirous
of exposing the intimate characteristics not generally known, I think
I would start with the fundamentals of character, ability and the
most obsolete virtue of modesty. I would then pass on to the
consideration of other personal qualities, such as humanness, sense
of humor and magnetism, and I would tell the extent to which they
existed in the subject of the sketch. The next step would be to give
instances indicating the possession of the characteristics described,
and, if anything further were necessary, I would allow the reader to
assume some of the characteristics from the number of activities not
connected with his official position that he indulged in.
There is a great deal to be said of the presiding genius of the
C.P.R. in this way. To be the youngest president of the greatest
transportation company in the world is something to be proud of.
But Edward Wentworth Beatty would be the very last one to boast of
that or any of the other high honors that have been showered upon
him. Why his head wasn’t turned at the overwhelming, fulsome
flattery and never-ending high compliments and congratulations and
beautiful bouquets that were lavishly thrown at him by voice and
pen, is a wonder to those who do not know the man. It could be
said that a mighty big percentage of ordinary humanity would have
at once affected an English accent, donned a monocle and taken to
spats. He didn’t even flicker an eyelash. He must have attended
scores upon scores of schools in his youth, and spent most of his
time playing football all over the universe, for I have met a mighty
multitude of his school-fellows, and a regular regiment of brother
chasers of the pigskin, every blessed one of whom claims to know
him well. All this doesn’t faze him either. He keeps on the even tenor
of his way serenely, familiarly calls his close associates by their first
names and is far more approachable than the average man in a
similar position of lofty responsibilities. High honors have not
affected him in the slightest. He has the same old familiar spirit of
his youth and early manhood, with all the same kindly good-natured
characteristics and the same creditable creed——to do well whatever
there is to be done. He is the “Prince Eddie of Wales of the C.P.R.
and of Canada.”
His Father a Transportation Pioneer.
Born in Thorold, Ontario, on October 16, 1877, his father being
Henry Beatty, a well-known steamboat man on the Great Lakes,
whose steamers of the Beatty Line were amongst the pioneers of
navigation on those inland waters, his early youth was spent at
Thorold, where he was an apt scholar in the town school. At ten
years of age his family moved to Toronto where he attended the
Model School, Harbord Collegiate, Toronto University and Osgoode
Hall, and in 1898 was articled as a law student with the law firm of
McCarthy, Osler, Hoskin & Creelman. On the appointment of the last
named as chief counsel of the C.P.R. at Montreal in 1901, Mr. Beatty
went with him and five years later was appointed his assistant. He
was elevated to the chief solicitorship in 1910. Four years later, on
the retirement of Mr. Creelman, he succeeded to the office of chief
counsel, and also made a vice-president of the company. Mr. Beatty’s
high ability had already been fully recognized, and on Lord
Shaughnessy’s retirement, he was chosen to succeed him. Everyone
will candidly admit that it is a difficult task to fill Lord Shaughnessy’s
shoes, but the ex-president will as candidly admit that they fit his
successor admirably.
E. W. BEATTY, K.C. President of the C.P.R.
The president makes no pretence to oratory, but he is a forceful
public speaker, who says what he means clearly and succinctly, and
has the magnetism to hold his audience deeply interested. The kind
of speech that he makes is one that is frequently punctuated with
applause, and his enthusiastic reception on rising is invariably
magnified into an ovation when he closes his peroration. He always
catches the crowd. He has no fads, and, well, he just has an old
head on young shoulders. He still enjoys witnessing athletic sports
which he indulged in during his boyhood days, likes a good play at
the theatre, though I am afraid grand opera may be a little too much
for him, delights in a horse race, and plays solitaire and other card
games which require four or more players. He still pays the bachelor
tax, and I don’t believe he would refuse a drink of Scotch in Quebec
or British Columbia, but he wouldn’t chase off to Mexico or Cuba to
get one. His politics are “Canada and the Canadian Pacific Railway.”
He enjoys the unbounded confidence of his large circle of friends,
and the 100,000 officials and employees of the company look to him
as one pre-eminently fitted to fill the high position which came to
him because of his great personality, clean forceful character, and his
many estimable qualities of head and heart.
David McNicoll of the Old Guard.
Amongst the old guard of the C.P.R. the name of David McNicoll
will long be remembered. He was with the company almost since its
inception, joining the staff in 1883. He had previous railway
experience in Scotland and in Canada, to which country he came
when a young man, and when he joined the C.P.R., at the age of
thirty-one years, his energy and ambition found the vent they could
not find in the positions he had previously occupied. Passenger
agent, passenger traffic manager, assistant general manager, vice-
president and general manager, he graduated from the
comparatively humble position to that in which he exerted plenary
authority, and always to the advantage of the company.
His judgment was sound, his observation keen, his knowledge of
the C.P.R. in all its ramifications remarkable; his perspicacity notable.
Close to his desk was a series of maps. These he studied by the
hour when a policy of expansion was to be decided upon. He knew
every bit of rail on the system; he made the west his familiar
companion; he was wedded to the great corporation to which he
gave his best powers. A tireless worker, he never spared himself, and
mastered even the minutest detail in all his labors, and it was this
constant attention to his duties that broke his health. While
generous to a fault, he had full possession of the proverbial Scotch
thrift, so that no one was surprised when it was told of him that in a
certain office there were five clerks and only four desks, and another
desk was required, he wanted to know if it wouldn’t be better to fire
the extra clerk instead of buying a new desk. He had also Scotch
reliance and determination, and was a hard man to bluff.
A bank manager, with a real or fancied grievance, angrily
bounced into his office one day and threatened that if a certain thing
wasn’t done and done P.D.Q., he would give orders that not a single
passenger or pound of freight, or express parcel or telegraph
message would be given to the C.P.R.
“Well, sir,” replied Mr. McNicoll, “Just let me know when you issue
that order, will you, and I’ll issue an order to all C.P.R. agents to
refuse the bills of your confounded old bank.”
The bank manager discreetly pulled in his horns.
Mr. McNicoll was one of the builders of the C.P.R., and he should
be accorded a fair measure of the glory which attaches to those who
helped to bring the company up to its present proud position.
Vice-President Ogden.
Prominent among the high officials is I. G. Ogden, who is known
as the financial genius of the C.P.R. During his long connection with
the company, dating from 1881, forty years ago, when he started as
auditor on western lines, with headquarters at Winnipeg, until to-
day, when he is vice-president in charge of finances, Mr. Ogden has
steadily risen in official positions. In 1883 he was appointed auditor
for the entire system, in 1887 was comptroller, and in 1901 became
vice-president. There is no more popular official in the company’s
service, and many a grateful heart there is for his help in hour of
financial depression. Of his abilities—why, he wouldn’t have been
where he is if he were not big enough for the job. Of course, he is
not as young as he used to be, but his years fall lightly upon him,
and he trips along the corridors as if he were a care-free lad, and
tackles large questions with a full knowledge of the details and great
comprehension of his responsibility.
“I.G.,” whose initials on the corner of a cheque and at the bottom
of many a pay roll have disseminated happiness and sunshine to
thousands, was honored by having the immense Ogden works near
Calgary named after him. He doesn’t take very many holidays, but
when he does the waters of the Rideau Lakes are considerably
lowered by the big catches he pulls out at his camp on the shores of
that lake. Mr. Ogden has always surrounded himself by capable men
like John Leslie, the kindly and always tactful Comptroller, W. J.
Moule, whose untimely death was a distinct loss to the Company, H.
L. Penny, Ernie Lloyd, J. H. Shearing, C. J. Flanagan, Jim Steele,
Charley Black, the late F. E. Shrimpton, G. C. Gahan; the affable and
evergreen George Jackson, W. J. Percival, W. H. Langridge, H. J.
Dalton, W. M. Taylor, E. J. Bulgin, W. H. Blackaller, W. J. Sudcliffe, E.
Emery, W. J. Cherry, B. Arnum, R. Urwin, and others who have
grown old or are getting gray-haired in the Accounting department.
In the early evening of his life—because years do not always
make age with some—he is as genial and jovial as ever, with a keen
appreciation of the humorous. His frequent sallies always provoke
laughter. One of his best was when some time after the formation of
the Montreal millionaire club, the Mount Royal, which led to the
desertion of some of the habitués of the well-known fashionable St.
James’ Club for the new attraction, one day a friend, who had been
conspicuous by his absence from the St. James and presence at the
Mount Royal, dropped in casually at the former, and when Mr. Ogden
saw him gaily greeted him with, “Hello, old man, slumming again?”
I. G. OGDEN D. McNICHOLL
R. B. ANGUS

Mr. Ogden is an indefatigable worker, and seldom is away from


his office unless called to New York or elsewhere on business—or to
Rideau Lake.
My “Fidus Achates.”
There could be no warmer friend or congenial spirit or lovable
companion than William Stitt, general passenger agent of the C.P.R.,
who represented the company in Winnipeg and Montreal and for
several years in Sydney, Australia. He had a great personality, was
generous to a fault, and had a happy knack of making and keeping
friends. A pleasant-faced Scotchman from Kirkcudbrightshire, which
he always contended I could never pronounce properly, though I
could—“Kirk-cu-brig-sheer”—he was happily mentioned by a lady
writer in one of the Australian papers upon leaving that country: “No
man could possibly be as innocent as William Stitt looks.” That was
William to a T. Full of Scotch wit, always affable, and pleasant
spoken, he had gained the undying friendship of a host of friends,
amongst whom was myself. Circumstances frequently brought us
together in our work in Windsor Street Station and on the road. To
tell all our experiences would require a volume by itself, but a few
incidents should be recalled:
Once we were occupying a drawing-room on the C.P.R. train to
Quebec. During the night, I went to the toilet, and the opening of
the door awakened him.
“What time is it, George?” he drowsily asked.
“It’s 4.10, Weelum,” I replied. I always called him “Weelum” after
the character in “Bunty Pulls the Strings.”
Weelum immediately resumed his slumbers, but I didn’t, and
after tossing around for half-an-hour or so, I grabbed him by the
hand—he was sleeping opposite me—and cried, “Weelum, Weelum,
wake up.”
He accommodatingly did, and then I very seriously said to him:
“Weelum, do you know that when I said it was 4.10 it wasn’t. It was
4.15.”
“Oh, go to blazes, you old heathen yon. What did you want to
wake me up for to tell me that?”
“Weelum, say, Weelum,”—but he would not listen to what I had
to say.
Finally I managed to make him hear me, and I explained that I
had been brought up by good God-fearing parents, who had
admonished me never to go to sleep with a lie on my lips, and that
my conscience wouldn’t let me sleep until I had confessed my sin.
His unmistakable directions as to my immediate destination,
which wasn’t Quebec, were forcibly given, and to the sweet music of
his impassioned declamation as to the innumerable varieties of a
blithering idiot that I was, I peacefully fell asleep, while his
continued sarcastic remarks were rendered inaudible by the roar of
the wheels.
Floored James Oborne.
On another occasion, we were out in James Oborne’s private car
through the Muskoka country. James, as you know, besides being
general superintendent of the C.P.R. was a total abstainer, and as
pernickety as they make them on the liquor question. As James and
I were sitting together one morning in the rear end of the car,
Weelum’s name came up incidentally, and I remarked quite off-hand-
like:
“Weelum is a grand man, a nature’s nobleman, but—but—”
“But, what?” demanded James.
“Oh, I don’t like to tell, but, between you and me, Weelum
crooks his elbow too much.”
James was astounded; it wasn’t possible, and he wanted to know
if he drank very heavily.
“Like a fish,” I mendaciously retorted.
Just then Weelum entered, and James Oborne immediately
informed him of what I had told him.
“Oborne,” said Weelum, “did he say that? And I suppose he told
you he never touched a drop himself. Oh, but he’s an awful liar. Did
you notice how frequently he goes into his bedroom?” And James
bowed affirmatively. “Well, the old villain has a bottle of Scotch in
there. That’s why. Do you know that the last time he was in my
place, he drank up every drop of liquor there was in the house?”
James reproachfully looked at me and silently awaited some sort
of an explanation.
“It’s true, James, alas, it’s only too true,” I unblushingly
remarked. “But he hasn’t told you the whole story. You know what a
charming woman Mrs. Stitt is. Now, I leave it to you, James, I leave
it to you, what would you do if a lovely woman like Mrs. Stitt came
up and put her arms around your neck and with tears streaming
down her rosy cheeks would say to you: ‘For goodness’ sake,
George, drink up all the whiskey there is in this house, or William will
have the D.T.’s?”
Mr. Oborne was completely obfuscated, and to the day of his
death was undecided whether I was an inveterate liar or William a
confirmed drunkard.
Don’t think I got the best of it every time. Weelum generally
evened up on me. One day at a little gathering, somebody or other
remarked that everybody knew me and that I knew everybody.
“Nothing of the sort,” says Weelum. “Not a word of truth in it.
He’s an awful faker. Why I went to see some prominent people who
were about to make a trip to the coast, and I told them that George
would be on the train, but they didn’t know him at all. I called in the
colored porter, and explained that this party was going out, but that
George Ham would be on the train, and to see him about them. The
porter said: ‘George Ham—who is he? Never heard of him.’ ”
And Weelum led in the laughter in which everybody joined.
Haunted by Presentiment.
When Weelum passed away suddenly on April 1st four years ago,
I was in Los Angeles, and could not sleep the previous night. There
was a premonition of impending misfortune haunting me, so I
hurried to the local C.P.R. office next morning where Polly—Mr. A. A.
Polhamus—handed me two telegrams. While I am nearly as blind as
a bat without spectacles, I hastily and distinctly read the despatches
without glasses. One was from Charlie Foster, saying that Mr. Stitt
was dangerously ill; the other of later sending was from my
secretary, Bessie James, that he had died that morning in Captain
Walsh’s office, adjoining mine. I was grief-stricken, and sadly walked
over to where Alex. Calder and John McKechnie, two dear old
Winnipeg friends of both Weelum and myself, were awaiting me, and
wistfully whispered: “William Stitt is dead.” Their sorrowing downcast
looks were pathetic. There was a sickening tugging of the heart-
strings and tear-dimmed eyes, for we mourned as many another did
over the passing away of one of the dearest souls God ever put life
in.
Captains Courageous.
Vessels of the C.P.R. plough the waters of two oceans, and I
don’t know how many lakes and rivers, but enough to require a
large fleet. Let me tell you something about the sailors bold who
have been for years in the company’s service, and some of whom
distinguished themselves during the great war.
Capt. Troup, now manager of the B.C. coast steamers, was a
“swift-water” man whose early training among the rapids of the
Columbia River served him in good stead on the Columbia and
Kootenay lakes. He has made a wonderful success of our coast fleet,
and is still going strong. His able assistant was Capt. Gore, who is
now pensioned.
Capt. Rudhlin, who was of the original crew of the Hudson’s Bay
Company’s Beaver, the first steamship to ply the waters of the
Pacific Ocean, served many years with the C. P. Navigation Company,
and after amalgamation with the C.P.R., he was the first commander
of the crack Princess Victoria. Capts. Hickey and Griffin keep the
boats on the triangular run going with such regularity in all weather
that residents of Vancouver, Victoria and Seattle set their watches by
the Princess boats.
Of the transpacific officers, Capt. Marshall brought the Empress
of India out in 1890, and after successfully sailing her for many
years was appointed an Elder Brother of Trinity House, the highest
honor open to men of the mercantile marine. Capt. Lee commanded
the Abyssinia, when first chartered for the China trade, and took the
Empress of Japan, when built in 1891, and had great success with
her until his retirement on a well-earned pension.
Capt. Harry Mowatt fitted out the Athenian for the Skagway trade
when the Klondyke firs opened up. He made a wonderful record for
his ship as a horse and troop transport to the Philippines during the
Spanish-American war, and went to Liverpool as marine
superintendent when the Atlantic Steamships Line was inaugurated
in 1903, where he did yeoman service during the early anxious years
of the new venture.
Capt. William Stewart, a fine example of the old school North
Atlantic skipper, was in command of the Lake Champlain when first
acquired by the company. He took over the Empress of Britain, when
built. Originally a ship’s carpenter, he helped to build and was the
first commander of the barque Lake Simcoe. She was also his first
ship. Going home on the Britain on his last voyage before retirement
a vessel on fire was sighted. Approaching closer, the barque was
found to be abandoned but was identified as the Lake Simcoe. He
and his first ship ended their career together.
Capt. Frank Casey, first commander of the Empress of Ireland,
with a humorous cock to his eye and the most delightfully soft Irish
brogue, was popular with passengers and greatly beloved by his
brother officers. Crossing the banks of Newfoundland in dense fog
he could always smell ice, and while he took regulation soundings
his officers say it was only a matter of form for he would call the
depth and bottom before it was officially reported.
Capt. Murray, who succeeded to the Empress of Britain, was very
popular, highly respected and is deeply regretted. He was killed in
the Halifax explosion while engaged in war transport work for the
Government.
Capt. Walsh, who was taken over with the Elder Dempster fleet
in 1903, still remains as manager of the C.P.O.S. at Montreal. He has
sailed the seas over for many a year, and was in the Gold Coast of
Africa trade before joining the C.P.R.
And then there was Capt. Evans, “Bully” Evans, not nicknamed as
you might suppose, but from his many years of piloting cattle ships.
He had a keen sense of humor and a wonderfully hearty and
infectious laugh. His gruff, bass voice and sometimes frowning
eyebrows, hid one of the kindest hearts that ever beat, and now,
alas, it’s stilled for ever.
Capt. Smith sailed the Milwaukee for years. She went a long way
in a long time. Early in her career, before his command, she lost her
nose in an argument with the east coast of Scotland. The new one
supplied by the generous owners served a purpose, but did not add
to her speed, and although she was credited with 9.2 on her trials
her fair sea average was nearer 2.9. Capt. Smith was heading her
out into the broad Atlantic, when a submarine broke water on his
starboard bow. He was unarmed save for a ten-foot log of wood he
had mounted on the bow, and some detonating caps. Swinging his
ship bow on, he trained his “ordnance” and one cap exploded so
realistically that the sub. promptly ducked. A few hours later the
Hesperian went to the bottom through, it is supposed, the same
submarine.
Capt. Boothby, whose brother is the English author, Guy Boothby,
and Capt. Hodder, who stood six feet two inches in his stocking feet
and weighed three and a half pounds for every inch of his height,
were born of the sea. I nearly “beat up” Capt. Hodder once, but
explained afterward I had refrained principally on account of his size
and his sex. One of his boys was torpedoed three times, and he
thought the last time was particularly hard luck as the boy only
saved his pyjamas and a red flannel undershirt.
Capt. Gillies brought the Keewatin out from the Clyde on her way
to her home on the Upper Lakes. Like Silas Wegg, he occasionally
dropped into poetry and could see a joke less slowly than most of
his fellow-countrymen. He was less concerned about the subs. than
he was about the instructions for avoiding them. His verses on the
trials of the commander of a convoyed ship are amusing now, but at
the time of writing they contained as much truth as they did poetry.
Capt. Jimmy Turnbull, who served with great distinction in the
great war, was decorated, mentioned in despatches, and has since
been promoted to the highest commissioned rank in the R.N.R., that
of full captain. Multum in parvo with a vengeance.
Capt. Clews, whose jovial face and perennial smile compel a
return in kind, was going to New York for a few days, and hearing
that except for an uncle he was without friends in the American
metropolis, I offered some letters of introduction. On his return, he
apologized for not having presented them, but explained he found it
impossible to get away from his uncle. Long afterwards it developed
that the uncle in question was Henry Clews, the great banker.
Capt. Griffiths, now on the Empress of Britain, Capt. Griffith
Evans, now I think the senior of the Ocean Service shippers, and
Capt. Parry, are all fellow countrymen of Lloyd George, and very
properly proud of it. Capt. Webster is also well among the seniors,
but as fit and hearty as ever. Capt. Kendall, to whom belongs the
credit of the capture of Dr. Crippen, Capt. Murray, who was chief
officer on the Lake Champlain when I crossed on her sixteen years
ago, bore a gallant part in the action and was severely wounded
when the Carmania sank the Cap Trafalgar.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like