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

Raspberry Pi Computing Analog Measurement Malcolm Maclean - Quickly access the ebook and start reading today

The document is a guide for using Raspberry Pi for analog measurement, authored by Malcolm Maclean. It includes an introduction, history, versions, peripherals, operating systems, and network setup instructions. The content is structured to assist users in understanding and utilizing Raspberry Pi effectively.

Uploaded by

qasqaylover
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)
14 views

Raspberry Pi Computing Analog Measurement Malcolm Maclean - Quickly access the ebook and start reading today

The document is a guide for using Raspberry Pi for analog measurement, authored by Malcolm Maclean. It includes an introduction, history, versions, peripherals, operating systems, and network setup instructions. The content is structured to assist users in understanding and utilizing Raspberry Pi effectively.

Uploaded by

qasqaylover
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/ 62

Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.

com

Raspberry Pi Computing Analog Measurement Malcolm


Maclean

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

OR CLICK HERE

DOWLOAD EBOOK

Visit and Get More Ebook Downloads Instantly at https://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

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


Raspberry Pi Versions 10

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.

Raspberry Pi B Models HDMI Video Output

Ethernet Network Connection


There is an integrated Ethernet Port for network access. On the B2 and B3 the connection speed
is fast ethernet (10/100 bps). The B3+ introduced a 300bps connection speed.

Raspberry Pi Model B Ethernet Connector


Raspberry Pi Versions 11

USB Power Input Jack


The boards include a 5V 2A Micro USB Power Input Jack.

Raspberry Pi Model B+ USB Power Input

MicroSD Flash Memory Card Slot


There is a microSD card socket on the ‘underside ‘of the board. On the Model B2 this is a ‘push-
push’ socket. On the B3 and later this is a simple friction fit.

Raspberry Pi B+ MicroSD Card Socket


Raspberry Pi Versions 12

Stereo and Composite Video Output


The B+, B2, B3 and B3+ includes a 4-pole (TRRS¹⁵) type connector that can provide stereo sound
if you plug in a standard headphone jack and composite video output with stereo audio if you
use a TRRS adapter.

Raspberry Pi B+ A/V Connector

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

Raspberry Pi B+ GPIO Connector

¹⁵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.

MicroSD Card Positioning

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.

Wired Keyboard and Mouse

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.

Wireless Keyboard and Mouse


Raspberry Pi Peripherals 15

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.

HDMI Connected Monitor

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.

VGA to HDMI Adapter


Raspberry Pi Peripherals 16

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.

HDMI Connected Monitor

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.

Power Supply Connection

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;

Simple ABS plastic case

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.

Official Raspberry Pi case

¹⁶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!

Writing the Operating System image to the SD Card


Once we have an image file we need to get it onto our SD card.
Operating Systems 21

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

Select the img file that you want to install.

Etcher SD Card Selection

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

Flash the drive

Then click on ‘Flash!’ to burn the card.

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.

Enabling Secure Shell Access


One of the awesome things when learning to use a Raspberry Pi comes when you begin to access
it remotely from another computer. This is a bit of an ‘Ah Ha!’ moment for some people as they
begin to appreciate just how networks and the Internet is built. We are going to enable and use
remote access via what is called ‘SSH’. We’ll start using it later in the book, but for now we can
take the opportunity to enable it for later use. We do this by creating a file called ‘ssh’ on our
freshly written SD card. Then, when the Pi then boots up it sees the file and automatically knows
to enable SSH.
SSH used to be enabled by default, but doing so presents a potential security concern, so it has
been disabled by default as of the end of 2016. In our case it’s a feature that we want to use.
Eject the card from the computer and then re-insert it. When the computer recognises the card,
open it and right-click in the folder to create a new file. This can be a simple txt file so long as
the file prefix is ‘ssh’. It doesn’t need to have anything in it, there just needs to be a file there.
Now we can unmount the SD card and eject it again.

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

The Command Line interface


Because we have installed the ‘Lite’ version of Raspbian, when we first boot up, the process
should automatically re-size the root file system to make full use of the space available on your SD
card. If this isn’t the case, the facility to do it can be accessed from the Raspberry Pi configuration
tool (raspi-config) that we will look at in a moment.
Once the reboot is complete (if it occurs) you will be presented with the console prompt to log
on;

Raspbian GNU/Linux 7 raspberrypi tty1

raspberrypi login:

The default username and password is:


Username: pi
Password: raspberry
Enter the username and password.
Congratulations, you have a working Raspberry Pi and are ready to start getting into the thick
of things!
Firstly we’ll do a bit of house keeping.

Raspberry Pi Software Configuration Tool

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.
Operating Systems 25

Raspberry Pi Software Configuration Tool

Use the up and down arrow keys to move the highlighted section to the selection you want to
make then press tab to highlight the <Select> option (or <Finish> if you’ve finished).
Lets change the settings for our operating system to reflect our location for the purposes of
having the correct time, language and WiFi regulations. These can all be located via selection ‘4
Localisation Options’ on the main menu.

Select Localisation Options

Select this and work through any changes that are required for your installation based on
geography.

Localisation Options
Operating Systems 26

Once you exit out of the raspi-config menu system, if you have made a few changes, there is a
probability that you will be asked if you want to re-boot the Pi. That’s a pretty good idea.
Once the reboot is complete you will be presented with the console prompt to log on again;

Software Updates

After configuring our Pi we’ll want to make sure that we have the latest software for our system.
This is a useful thing to do as it allows any additional improvements to the software we will be
using to be enhanced or security of the operating system to be improved. This is probably a good
time to mention that we will need to have an Internet connection available.
Type in the following line which will find the latest lists of available software;

sudo apt-get update

You should see a list of text scroll up while the Pi is downloading the latest information.
Then we want to upgrade our software to latest versions from those lists using;

sudo apt-get upgrade

The Pi should tell you the lists of packages that it has identified as suitable for an upgrade along
with the amount of data that will be downloaded and the space that will be used on the system.
It will then ask you to confirm that you want to go ahead. Tell it ‘Y’ and we will see another list
of details as it heads off downloading software and installing it.
Power Up the Pi
To configure the Raspberry Pi for our purpose we will extend our Pi a little. This makes
configuring and using the device easier and to be perfectly honest, making life hard for ourselves
is so exhausting! Let’s not do that.

Static IP Address
As we mentioned earlier, enabling remote access is a really useful thing. This will allow us to
configure and operate our raspberry Pi from a separate computer. To do so we will want to assign
our Raspberry Pi a static IP address.
An Internet Protocol address (IP address) is a numerical label assigned to each device (e.g.,
computer, printer) participating in a computer network that uses the Internet Protocol for
communication.
There is a strong likelihood that our Raspberry Pi already has an IP address and it should appear
a few lines above the ‘login’ prompt when you first boot up;

My IP address is 10.1.1.25

Raspbian GNU/Linux 7 raspberrypi tty1

raspberrypi login:

The My IP address... part should appear just above or around 15 lines above the login line,
depending on the version of Raspbian we’re using. In this example the IP address 10.1.1.25 belongs
to the Raspberry Pi.
This address will probably be a ‘dynamic’ IP address and could change each time the Pi is booted.
For the purposes of using the Raspberry Pi with a degree of certainty when logging in to it
remotely it’s easier to set a fixed IP address.
This description of setting up a static IP address makes the assumption that we have a device
running on our network that is assigning IP addresses as required. This sounds complicated, but
in fact it is a very common service to be running on even a small home network and most likely
on an ADSL modem/router or similar. This function is run as a service called DHCP²¹ (Dynamic
Host Configuration Protocol). You will need to have access to this device for the purposes of
knowing what the allowable ranges are for a static IP address.
²¹http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol
Power Up the Pi 28

The Netmask
A common feature for home modems and routers that run DHCP devices is to allow the user to
set up the range of allowable network addresses that can exist on the network. At a higher level
we should be able to set a ‘netmask’ which will do the job for us. A netmask looks similar to an
IP address, but it allows you to specify the range of addresses for ‘hosts’ (in our case computers)
that can be connected to the network.
A very common netmask is 255.255.255.0 which means that the network in question can have
any one of the combinations where the final number in the IP address varies. In other words
with a netmask of 255.255.255.0, the IP addresses available for devices on the network ‘10.1.1.x’
range from 10.1.1.0 to 10.1.1.255 or in other words any one of 256 unique addresses.

CIDR Notation

An alternative to specifying a netmask in the format of ‘255.255.255.0’ is to use a system called


Classless Inter-Domain Routing, or CIDR. The idea is to add a specification in the IP address
itself that indicates the number of significant bits that make up the netmask.
For example, we could designate the IP address 10.1.1.17 as associated with the netmask
255.255.255.0 by using the CIDR notation of 10.1.1.17/24. This means that the first 24 bits of
the IP address given are considered significant for the network routing.
Using CIDR notation allows us to do some very clever things to organise our network, but at
the same time it can have the effect of confusing people by introducing a pretty complex topic
when all they want to do is get their network going :-). So for the sake of this explanation we can
assume that if we wanted to specify an IP address and a netmask, it could be accomplished by
either specifying each separately (IP address = 10.1.1.17 and netmask = 255.255.255.0) or in CIDR
format (10.1.1.1/24)

Distinguish Dynamic from Static


The other service that our DHCP server will allow is the setting of a range of addresses that can
be assigned dynamically. In other words we will be able to declare that the range from 10.1.1.20
to 10.1.1.255 can be dynamically assigned which leaves 10.1.1.0 to 10.1.1.19 which can be set as
static addresses.
You might also be able to reserve an IP address on your modem / router. To do this you will
need to know what the MAC (or hardware address) of the Raspberry Pi is. To find the hardware
address on the Raspberry Pi type;

ifconfig -a

(For more information on the ifconfig command check out the Linux commands section)
This will produce an output which will look a little like the following;
Power Up the Pi 29

eth0 Link encap:Ethernet HWaddr 00:08:C7:1B:8C:02


inet addr:10.1.1.26 Bcast:10.1.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:53 errors:0 dropped:0 overruns:0 frame:0
TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4911 (4.7 KiB) TX bytes:4792 (4.6 KiB)

The figures 00:08:C7:1B:8C:02 are the Hardware or MAC address.


Because there are a huge range of different DHCP servers being run on different home networks,
I will have to leave you with those descriptions and the advice to consult your devices manual to
help you find an IP address that can be assigned as a static address. Make sure that the assigned
number has not already been taken by another device. In a perfect World we would hold a list
of any devices which have static addresses so that our Pi’s address does not clash with any other
device.

Be aware that if you don’t have a section of your IP address range set aside for static
addresses you run the risk of having the DHCP service unwittingly assign a device that
wants a dynamic address with the same value that you have already assigned for your
Raspberry Pi. Such a conflict is not a good thing.

For the sake of the upcoming projects we will assume that the address 10.1.1.120 is available.

Default Gateway
Before we start configuring we will need to find out what the default gateway is for our network.
A default gateway is an IP address that a device (typically a router) will use when it is asked to go
to an address that it doesn’t immediately recognise. This would most commonly occur when a
computer on a home network wants to contact a computer on the Internet. The default gateway
is therefore typically the address of the modem / router on your home network.
We can check to find out what our default gateway is from Windows by going to the command
prompt (Start > Accessories > Command Prompt) and typing;

ipconfig

This should present a range of information including a section that looks a little like the following;
Power Up the Pi 30

Ethernet adapter Local Area Connection:

IPv4 Address. . . . . . . . . . . : 10.1.1.15


Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.1.1.1

The default router gateway is therefore ‘10.1.1.1’.

Lets edit the dhcpcd.conf file


On the Raspberry Pi at the command line we are going to start up a text editor and edit the file
that holds the configuration details for the network connections.
The file is /etc/dhcpcd.conf. That is to say it’s the dhcpcd.conf file which is in the etc directory
which is in the root (/) directory.
To edit this file we are going to type in the following command;

sudo nano /etc/dhcpcd.conf

Remember, the sudo portion of the command makes sure that you will have the
permission required to edit the dhcpcd.conf file, nano is the name of the text editor
and /etc/dhcpcd.conf is telling the computer which file to edit.

The nano²² file editor will start and show the contents of the dhcpcd.conf file which should look
a little like the following;

A sample configuration for dhcpcd.


# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.


hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID per RFC4361.
#duid

²²http://www.nano-editor.org/
Power Up the Pi 31

# Persist interface configuration when dhcpcd exits.


persistent

# Rapid commit support.


# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.


option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.


require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones


slaac private

# Example static IP configuration:


#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

# It is possible to fall back to a static IP if DHCP fails:


# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0


#interface eth0
#fallback static_eth0

The file actually contains some commented out sections that provide guidance on entering the
correct configuration.
We are going to add the information that tells the network interface to use eth0 at our static
address that we decided on earlier (10.1.1.120) along with information on the netmask to use
(in CIDR format) and the default gateway of our router. To do this we will add the following
lines to the end of the information in the dhcpcd.conf file;
Power Up the Pi 32

# Custom static IP address for eth0.


interface eth0
static ip_address=10.1.1.120/24
static routers=10.1.1.1
static domain_name_servers=10.1.1.1

Here we can see the IP address and netmask (static ip_address=10.1.1.120/24), the gateway
address for our router (static routers=10.1.1.1) and the address where the computer can also
find DNS information (static domain_name_servers=10.1.1.1).

In a simplistic explanation, the Domain Name System (DNS) makes sure that the Internet
can find resources easily based on a naming convention.

Once you have finished press ctrl-x to tell nano you’re finished and it will prompt you to confirm
saving the file. Check your changes over and then press ‘y’ to save the file (if it’s correct). It will
then prompt you for the file-name to save the file as. Press return to accept the default of the
current name and you’re done!
To allow the changes to become operative we can type in;

sudo reboot

This will reboot the Raspberry Pi and we should see the (by now familiar) scroll of text and when
it finishes rebooting you should see;

My IP address is 10.1.1.120

Raspbian GNU/Linux 7 raspberrypi tty1

raspberrypi login:

Which tells us that the changes have been successful (bearing in mind that the IP address above
should be the one you have chosen, not necessarily the one we have been using as an example).
Power Up the Pi 33

Remote access
To allow us to work on our Raspberry Pi from our normal desktop we can give ourselves the
ability to connect to the Pi from another computer. The will mean that we don’t need to have
the keyboard / mouse or video connected to the Raspberry Pi and we can physically place it
somewhere else and still work on it without problem. This process is called ‘remotely accessing’
our computer .
To do this we need to install an application on our windows desktop which will act as a ‘client’
in the process and have software on our Raspberry Pi to act as the ‘server’. There are a couple of
different ways that we can accomplish this task, but because we will be working at the command
line (where all we do is type in our commands (like when we first log into the Pi)) we will use
what’s called SSH access in a ‘shell’.

Remote access via SSH


Secure Shell (SSH²³) is a network protocol that allows secure data communication, remote
command-line login, remote command execution, and other secure network services between
two networked computers. It connects, via a secure channel over an insecure network, a server
and a client running SSH server and SSH client programs, respectively (there’s the client-server
model again).
In our case the SSH program on the server is running sshd and on the Windows machine we will
use a program called ‘PuTTY’.

Setting up the Server (Raspberry Pi)

SSH is already installed and operating but to check that it is there and working type the following
from the command line;

/etc/init.d/ssh status

The Pi should respond with the message that the program sshd is active (running).

pi@raspberrypi:~ $ /etc/init.d/ssh status


� ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
Active: active (running) since Tue 2017-04-25 03:30:16 UTC; 1h 28min ago
Main PID: 2135 (sshd)
CGroup: /system.slice/ssh.service
└─2135 /usr/sbin/sshd -D

If it isn’t, run the following command;


²³http://en.wikipedia.org/wiki/Secure_Shell
Power Up the Pi 34

sudo raspi-config

Raspberry Pi Software Configuration Tool

Use the up and down arrow keys to move the highlighted section to the selection you want to
make then press tab to highlight the <Select> option (or <Finish> if you’ve finished).
To enable SSH select ‘5 Interfacing Options’ from the main menu.

Interfacing Options

From here we select ‘P2 SSH’


Another Random Scribd Document
with Unrelated Content
"Daughter," said Mr. Torrens, taking her hand, "you must and you
shall know the worst now—for I find that the miscreant Jeffreys has
indeed told you too much for me to attempt to conceal the truth
——"
"Just heavens! my father—stained with blood—the blood of
vengeance on account of his dishonoured daughter;" said
Rosamond, speaking in broken sentences and with hysterical
excitement, while her eyes were fixed intently and with a fearfully
wild expression upon the haggard countenance of her sire.
"No—not so, Rosamond," answered Mr. Torrens emphatically. "Sit
down—there—and try and compose yourself for a few moments,
while I give you an explanation which circumstances have rendered
imperative."
The wretched girl suffered herself to be placed on a seat: her father
then drew another chair close to the one which she occupied—and,
leaning with folded arms over the back of it, he continued in these
terms:——
"Last night—after you had retired to your room—Sir Henry
Courtenay called. Yes—he dared to visit the house into which such
dishonour and so much misery had been brought by his means. But
he came to offer every possible atonement which it was in his power
to make; and then I ascended to your room—here—to make you
aware of his presence in the parlour below and of the proposals
which I had received. But I found you in a state of mind too
profoundly excited to bear the announcement—I remained with you
to console and tranquillise you—and, when I saw that you were
growing more calm, I retraced my way down stairs. Merciful
heavens! what a spectacle then met my eyes!"
And Mr. Torrens, having introduced his fearful history by this
deceptive and well coloured preface, proceeded to narrate the facts
of the murder precisely as they had really occurred,—not forgetting
to mention the robbery of a sum of money which he had left on the
table. He then explained the part which John Jeffreys had
subsequently performed in the occurrences of the preceding night;
and he wound up in the following manner:——
"Thus you perceive, dear Rosamond, how a fearful combination of
circumstances would fix dark and dreadful suspicions on me, were
this tragedy to be brought to light. And now, too, you can
understand how that miscreant Jeffreys dared to presume upon his
knowledge of the shocking event—how, believing me to be
completely in his power, he fancied that I dared not defend my own
daughter from his licentious ruffianism. And, more than all this,
Rosamond—Mrs. Slingsby holds me also beneath the rod of
terrorism! For she knew that the baronet came hither last night—she
knew also that he did not return—and I was compelled to reveal to
her the whole truth, even as circumstances have now forced me to
reveal it to you. And this is the secret of my intended marriage with
her—a marriage that will take place to-morrow, and into which she
has coerced me! Thus, Rosamond, if you ever loved and if you still
love your unhappy father—pity him, pity him—but do not reproach
him—nor aggravate his grief and his mental anguish by thought or
deed on your part!"
So ingeniously had Mr. Torrens blended truth and fiction in his
narrative, to work upon the feelings of his daughter,—so artfully had
he combined and explained the various incidents in order to
represent himself as the victim of cruel circumstances—that the
generous-minded Rosamond felt the deepest commiseration and
sympathy on behalf of her father rapidly taking possession of her
soul.
"My dearest parent," she said, "I crave your pardon—I implore your
forgiveness, for having wronged you by the most unjust—the most
horrible suspicions! But the conduct of that man Jeffreys—his awful
accusation—the reluctance you appeared to exhibit in dealing
summarily with him, when you entered the room the first time this
night,—all these things operated powerfully upon my mind, which
has been attenuated by so many dreadful shocks within the last ten
or twelve days! Alas! what sorrows have overtaken us—what perils
environ us! Let us fly from this neighbourhood, dear father—let us
leave England——"
"It is impossible, Rosamond!" interrupted Mr. Torrens hastily. "I had
myself thought of that means of ensuring personal safety: but I
abandoned the idea almost as soon as formed—for it was better to
stay here, surrounded by danger, yet having bread to eat, than seek
a foreign clime to starve!"
"We can work, dear father—we can toil for our livelihood! But, no—
never should you be reduced to such a painful necessity, so long as
your daughter has health and strength to labour for our mutual
support!" exclaimed the excellent-hearted girl. "Oh! let us fly—let us
quit this country—let us repair to France! I have some few
accomplishments—drawing—music—a knowledge of all the branches
of needlework; and it will be hard indeed if I cannot earn enough to
procure us bread."
"No—no, Rosamond—it cannot be!" said Mr. Torrens, tears now
trickling down his cheeks—for the better he became acquainted with
the admirable traits of his daughter's character—traits which
adversity, misfortune, and danger now developed—the more bitterly
did his heart smite him for the awful treachery he had perpetrated
with regard to her.
"And wherefore is it impossible?" she asked. "Consider, my dear
father, by what circumstances you are now surrounded. On one side
is Jeffreys whom you dare not offend—whom you cannot discharge
—and from whose ruffianism your daughter is not safe. On the other
side, is this marriage with Mrs. Slingsby—a marriage which I now
perceive to be forced upon you—a marriage that will bring into this
house a person whom neither of us can ever love or respect!"
"Enough! enough! Rosamond," exclaimed Mr. Torrens: "all these sad
things—these dangers and these sacrifices—have become
interwoven with the destiny which it is mine to fulfil; and I must
pursue my painful course—follow on my sad career, in the best
manner that I may. I cannot risk starvation in a foreign land—I could
not support an existence maintained by the toils of my daughter.
Besides, I am confident of being able to realise a fortune by my
speculations in this neighbourhood. Here, then, must I remain. And
now, Rosamond, it remains for you to decide whether you will
receive the mother-in-law whom imperious circumstances force upon
you—or whether you will abandon your father!"
"Never, never will I leave you!" cried the affectionate girl, throwing
her arms around her parent's neck, and embracing him tenderly.
The interview—the painful interview between the father and his child
then terminated. The former retired to his own apartment, a prey to
feelings of the most harrowing nature; and the latter sought her
couch, to which slumber was brought through sheer exhaustion.
But the horrors of the early portion of the night were perpetuated in
her dreams!
CHAPTER LXXXII.
THE FORGED CHEQUE.

Oh! what a strange, and, at the same time, what a wondrous world
is this in which we live;—and how marvellous is human progress!
The utmost attainments effected by the wisdom of our ancestors
were but ignorance and short-sightedness compared with the
knowledge of the present day. Antiquity had its grand intellects and
its sublime geniuses; but it furnished not the same abundance of
materials to act upon as is afforded by the discoveries and likewise
by the spirit of this age!
But are we proportionately happier, on this account, than were our
forefathers? Is the working-man, for instance, more prosperous,
more comfortable, more enviable as to his condition, than the
aboriginal Briton who lived in a cave or the hollow of a tree, and
who painted his body to protect it against the cold?
With all our prosperity—with all the grandeur, the glitter, and the
refinement of our civilisation—with all our moralising institutions and
our love of social order and mental improvement, we yet find the
national heart devoured, tortured, and preyed upon by that undying
serpent—Pauperism!
Yes: the millions are not so happy, so prosperous, or so comfortable
as they ought to be;—for they are compelled to gnaw the tares of
civilisation's field, while the proud and heartless oligarchy self-
appropriate the corn!
Proud and heartless, indeed, are the rulers and the mighty ones of
this land; and if the millions remain passive and patient, that pride
and that heartlessness will grow, the one more despotic and the
other more selfish.
It was but a few days ago that we marked two distinct articles in the
morning newspapers, which formed a contrast fearfully significant in
its evidence of the pride and the heartlessness which we abominate
on the one hand, and of the distress and suffering which we so
deeply deplore on the other.
One of these articles consisted but of four lines: the other occupied
nearly two columns.
The first stated as laconically as possible that bread had risen to
thirteen-pence the quartern loaf, and recorded a rapidly-disposed of
regret that provisions should be so dear, on account of the poor. The
second gave a laboured, fulsome, and tediously wire-drawn narrative
of "Her Majesty's State Ball."
Thus the misery endured by millions in consequence of dearness and
scarcity, is a trivial matter deserving only of four lines; whereas the
trumpery nonsense and childish tom-foolery of a royal dance are
deemed of sufficient importance to merit nearly two columns!
Oh! instead of giving balls and splendid entertainments at such a
time, if the Sovereign of this land were to say to the people, "Ye are
starving, and it makes my heart bleed to think that from your very
vitals are wrung the hundreds of thousands of pounds which are
wasted by myself and the other members of the Royal Family on our
frivolities, our whims, our caprices, and our wanton extravagances:
therefore will I give ye back one half of the enormous income which
I have hitherto enjoyed, in the full confidence that my example will
be imitated by many others who prey upon you;"—did the Sovereign
thus speak to the nation, the nation would be justly proud of its
Sovereign; and yet this Sovereign would only be performing a duty
dictated by humanity and common justice.
What would be thought of the father of a family who feasted on
turtle and venison, accompanied by generous wines, every day,
while his children were thrust into the cold, humid cellar, to devour a
mouldy crust and drink water?
Yet the Sovereign delights in the attribute of a general and
comprehensive paternal solicitude in the welfare of the people: but it
is an attribute which exists only in the imaginations of grovelling
courtiers or lick-spittle historians.
Royalty and Aristocracy are intensely—necessarily—and thoroughly
selfish: and as for any anxiety on behalf of the toiling and suffering
millions, the idea is absurd—the notion is a mere delusion—the
assertion that such a feeling exists, is a lie—a monstrous, wicked,
atrocious lie!
There is more of the milk of human kindness in a single cottage than
in all the palaces of Europe taken together.
There is more true philanthropy in one poor man's hovel, than in a
thousand mansions of the great and wealthy in the fashionable
quarters of London.
Oh! if the father or the mother can dance and be glad while the
children are famishing, the sooner all ties are severed between such
worthless parents and such an oppressed and outraged offspring,
the better!
Nero danced and sang on the summit of a tower at the spectacle
presented to his eyes by burning Rome;—and festivity and rejoicing
reign in our English palaces, at a moment when scarcity menaces
the land with famine and its invariable attendant—pestilence!
People of England! ye now understand how much sympathy ye may
expect on the part of those who derive all their wealth from the
sweat of your brow!
People of Ireland! ye now comprehend how much pity your starving
condition excites on the part of your rulers!
People of Scotland! ye now perceive how worthy the great ones of
the realm are of your adulation!
But it is sickening, as it is sorrowful, to dwell on this subject. Some
of our readers may perhaps ask us wherefore we broach it at all? We
will reply by means of a few questions. Is not every individual
member of a society interested in the welfare of that society? or
ought he not at least to be so? Is he not justified in denouncing the
errors or the downright turpitude of the magistrates whom that
society has chosen to govern it, and who derive their power only
from its good will and pleasure? or is it not indeed his duty to
proclaim those errors and that turpitude? Should not this duty be
performed, even if it be unpleasant? and can we ever hope to
ameliorate our condition, unless we expose the abuses which
oppress, degrade, and demoralise us?
Oh! let no one rashly and in a random manner say that he cares
nothing about politics! Such an assertion denotes a wilful disregard
not only of his neighbour's interests, but also of his own. Were all
men to entertain such an indifference, the people would be the
veriest slaves that an unrestrained despotism and an unwatched
tyranny could render them. It is as necessary for the industrious
classes to protect their rights and privileges by zealously guarding
them, as to adopt precautions to save their houses from fire.
One word more. It is a common saying, and as absurd as it is
common—"Oh! women have no right to meddle in politics." Women,
on the contrary, have as much right as "the lords of the creation" to
exhibit an interest in the systems and institutions by which they are
governed. For the sake of their children, as well as for their own,
they should assert and exercise that right. It is a lamentable
delusion to suppose that the intellect of woman is not powerful nor
comprehensive enough to embrace such considerations. The intellect
of woman is naturally as strong as that of man; but it has less
chances and less opportunities of developing its capacity. The
masculine study of politics would aid the intellect of woman in
putting forth its strength; and we hope that the day is gone by when
the female sex are to be limited to the occupations of the drawing-
room, the nursery, or the kitchen. We do not wish to see women
become soldiers or sailors, nor to work at severe employment: but
we are anxious to behold them thinkers as well as readers—
utilitarians as well as domestic economists. And we know of no
greater benefit that could be conferred on society in general, than
that which might be derived from the influence of the well developed
intellect of woman. Her mind is naturally better poised than that of
man: far-seeing and quick-sighted is she;—a readiness at devising
and combining plans to meet emergencies, is intuitive with her. Her
judgment is correct—her taste good;—and she profits by experience
far more usefully than does man. Is it not absurd, then—is it not
unjust—and is it not unwise to deny to woman the right of exercising
her proper influence in that society of which she is the ornament and
the delight?
Alas! that there should be such exceptions to the general rule of
female excellence, as Martha Slingsby,—a woman whose principles
were thoroughly corrupt, whose licentious passions were of the most
devouring, insatiable kind, and whose talent for wicked combinations
and evil plottings was unfortunately so great!
Let us return to this hypocritical and abandoned creature, and follow
her in the vile scheme which now occupies all her attention.
Having breakfasted at an early hour, she seated herself at her desk,
whence she drew forth a packet of letters received by her at various
times from Sir Henry Courtenay, and the signatures of which now
became the objects of her special study. The art of counterfeiting
the late baronet's autograph was practised by her for nearly half an
hour; for though she was already tolerably confident of her ability to
forge his signature most successfully,—as she had assured Mr.
Torrens,—she nevertheless deemed it prudent to render the
imitation as perfect as possible.
At last the atrocious deed was accomplished to her complete
satisfaction; and a cheque for two thousand pounds lay, drawn in a
thoroughly business-like manner, upon her desk!
She was bold and courageous in the execution of plots and the
carrying out of deep schemes;—but this dark and dangerous crime
which she had just perpetrated, caused her to shudder from head to
foot! Hitherto all her wickedness had been of a nature calculated
only, if detected, to involve her in disgrace, and not in peril—to ruin
her character, but not place her life in jeopardy! Now she had taken
a step—a bold and desperate step—which at once set her on the
high road that conducts all those who are found treading its
pathway, to the foot of the scaffold!
Yes—she shrank back and she trembled violently as she rose from
the desk whereon the forged cheque now lay; and for a moment she
was inclined to seize it—to rend it into a thousand pieces—and thus
to dispel at once and in an instant the tremendous black cloud of
stormy danger which she had drawn over her own head.
But, no—she had courage enough to be wicked and rash; but she
had not strength of mind sufficient to render her prudent. She
therefore decided on daring all—risking everything, by the
presentation of the forged cheque!
Having dressed herself in a style of unusual elegance, she proceeded
in a hackney-coach to Lombard Street, and alighted at the door of
the banking-house on which the cheque was drawn.
Saying to herself,—"Now for the aid of all my courage!"—she
entered the spacious establishment, and advanced towards the
counter.
One of the numerous clerks in attendance instantly received the
cheque which she handed across to him;—and, as it left her hand, a
chill struck to her heart—and she would at that moment have given
worlds to recall it.
Her composure was now only the effect of utter desperation: but so
unruffled was her countenance, that not a lineament was so
changed as to be calculated to engender suspicion.
The clerk took the cheque to the nearest desk upon the counter;
and after reading it with more than usual attention, as Mrs. Slingsby
thought, he said, "This is dated the day before yesterday, madam.
Have you seen Sir Henry Courtenay since then?"
"I have not," answered Mrs. Slingsby, wondering how she was able
to speak in a tone so cold and collected. "I believe," she added,
"that he is gone out of town."
"Pardon the question, madam," observed the clerk; "but one of his
servants was here last evening, just before closing time, to enquire if
we had seen Sir Henry:"—then, after a few moments' pause, he
said, "How will you have this?"
Immense was the relief suddenly experienced by the guilty woman!
She seemed as if drawn abruptly forth from the depths of an ocean
in which she had been suffocating—drowning. The revulsion of
feeling was so great, that, whereas she had been enabled to stand
without support throughout the few minutes of frightful ordeal just
passed, she was now compelled to cling to the counter, though the
clerk observed not her emotion.
Having specified the manner in which she desired the amount of the
cheque to be paid her, Mrs. Slingsby received the produce of her
crime, and quitted the bank.
She was now so astounded at the complete success of her scheme,
—although, when able to reflect calmly upon it, she had never once
doubted the issue,—that she could scarcely believe in its realization.
Her brain whirled—her heart palpitated violently, as she ascended
the steps of the hackney-coach;—and its motion, as it rolled away
from the door of the bank, increased the excitement under which
she was now labouring.
On her return to Old Burlington Street, she found Mr. Torrens waiting
for her, it being nearly twelve o'clock—the hour appointed for their
visit to the solicitor.
The moment she entered the drawing-room, Mr. Torrens rose from
his seat, and advanced towards her, his eyes fixed intently upon her
countenance.
In fact Mr. Torrens was deeply anxious to learn the result of the bold
venture which Mrs. Slingsby was that morning to make. With him it
was now a matter of pecuniary ruin or salvation; and he had
overcome so many difficulties already,—stifling his own scruples at
taking an immodest woman for his wife, and reducing his daughter
to a belief in the necessity of his submitting to this matrimonial
arrangement,—that he trembled lest some unforeseen accident
should thwart him just at the moment when he appeared to be
touching on the goal of success. Moreover, he had that morning, ere
quitting home, so contrived matters with John Jeffreys as to induce
this man to leave his service without delay; and he had enjoyed the
supreme satisfaction of seeing that dangerous person leave his
house ere he himself had set out to keep his appointment with Mrs.
Slingsby. Thus every thing had progressed in accordance with Mr.
Torrens' views and wishes, so far as the preliminaries to his change
of condition were involved.
"Well, my dear madam, what tidings?" he eagerly demanded, as he
approached to meet Mrs. Slingsby.
"I have succeeded," she said, throwing herself into a chair. "But I
would not for worlds undergo again the same dreadful alternations
between acute suspense and thrilling joy—cold tremor and feverish
excitement."
"And yet the transaction has given a charming glow of animation to
your countenance," observed Mr. Torrens, now for the first time
inflamed by desire in respect to the amorous widow whom he was
shortly to make his wife. "I have procured the license; and——"
"And Rosamond—what of her?" demanded Mrs. Slingsby hastily.
"She will receive you with a respectful welcome at Torrens Cottage,"
was the answer. "By dint of reasoning with her, I overcame all her
scruples, and rendered her pliant and ductile to our purposes."
"All progresses well, then," said Mrs. Slingsby. "Let us now away to
Mr. Howard."
And to that gentleman's office did the pair proceed. Their business
was soon explained to the attorney, who manifested no surprise nor
any particular emotion at the singularity of the transaction; for Mr.
Howard was a perfect man of business, ready to receive instructions
without expressing any feelings at all calculated to annoy his clients,
and never indicating a curiosity to learn more than those clients
might choose to confide to him.
"I am to keep this sum of two thousand pounds until such time as
Mr. Torrens may claim it in the capacity of your husband?" he said,
as coolly and quietly as if he were receiving a deposit on the
purchase of an estate.
"Exactly so," answered Mrs. Slingsby.
"And to-morrow morning, my dear sir," added Mr. Torrens, with a
smile, "I shall come to claim it."
"Good," exclaimed Mr. Howard, locking up the bank-notes and gold
in his iron safe. "I give you joy, Mr. Torrens: Mrs. Slingsby, I wish you
all possible happiness."
Thus speaking, the attorney bowed his clients out of the office.
Mr. Torrens escorted Mrs. Slingsby back to Old Burlington Street, and
then repaired as fast as his horse and gig would take him to his own
dwelling, to sit down to an early dinner, and afterwards dress himself
for the interesting ceremony of the evening.
But on his arrival at the Cottage, he learnt from the female servant
who opened the door, that his daughter Rosamond had left home an
hour previously.
"Left home!" ejaculated Mr. Torrens. "But she will return?" he
continued interrogatively. "Did she not say that she would return?"
"She desired me to give you this note, sir," answered the domestic.
Mr. Torrens tore open the letter placed in his hands, and read the
following impressive lines:—
"Pardon me, dearest father, for the step which I am now taking;
but I cannot—cannot support the idea of dwelling beneath the
same roof with that lady who is soon to be my mother-in-law. I
know that I promised not to desert the paternal home: that
promise was given in sincerity—though maddening reflections
now render me incapable of keeping it. You are well aware how
dreadfully my feelings have been wounded—how cruelly my
heart has been lacerated, during the last few hours; and I have
struggled against the violence of my grief—I have endeavoured
to subdue my anguish;—but the occurrences of last night—the
outrage attempted by that villain Jeffreys—the revelation of the
terrible secret relative to Sir Henry Courtenay——Oh! my dear
father, a mind ten thousand times stronger than that of your
unhappy daughter could not endure the weight of all this
aggregate of misery! Therefore, sooner that my presence should
render my father's house unhappy, I depart thence, hoping to be
followed by your blessing! Grieve not for me, dear father—
heaven will protect me! From time to time I shall write to you;
and should happier days arrive——but of that, alas! I dare
entertain no hope at present. To you must I leave the painful
task of accounting to my dearest, dearest sister and her
esteemed husband for my absence when you see them again.
Farewell—farewell, my beloved father! I scarcely know what I
have written—my brain is on fire—my heart is ready to burst—
my eyes are dimmed with tears."
The servant watched the countenance of her master with evident
interest and curiosity as he perused this note.
"Did Miss Rosamond appear much excited?" he asked, in a
tremulous tone, and without raising his eyes from the letter which he
held in his hand.
"She was crying very much, sir," responded the servant; "and it
made me quite sad to see her. I attempted to comfort her; but she
only shook her head impatiently, and then sobbed as if her heart
would break. I knew that she was going to leave, because she had a
small package in her hand; and she did cry so dreadful when she
told me to give you this note."
Mr. Torrens turned aside, and hastened to his chamber, where he
remained until half-past five o'clock. He then descended to the
parlour, dressed for the nuptial ceremony. To the servant's enquiry
relative to the serving up of the dinner, he replied that he had no
appetite, and immediately gave orders for the horse and gig to be
got ready by a stable-boy, who had been hastily hired in the morning
to take the place of Jeffreys until a more efficient substitute could be
found.
This command was soon obeyed, and shortly before seven o'clock
Mr. Torrens arrived in Old Burlington Street.
The flight of his daughter from home had proved a more severe
shock to him than the reader might imagine, considering the cold
and heartless disposition of this man. It was not that he felt he
should miss her society;—no—he did not love her enough to harbour
a regret of that nature;—but her departure from the paternal
dwelling had made him writhe beneath the maddening—the galling
conviction that his independence was in a measure gone, and that a
stern necessity had compelled him to assent to link his fate with that
of a woman so vile and abandoned, that his own child fled at the
idea of her approach.
Influenced by such feelings as these, it was no easy task for Mr.
Torrens to assume a complacent demeanour suitable to the occasion
of his nuptials. He, nevertheless, managed to conceal the emotions
which wrung him so acutely, and played his part with tolerable
satisfaction to Mrs. Slingsby as she introduced him to Dr. Wagtail and
the other guests, including a clergyman, who were already
assembled at her house.
The ceremony was performed by the reverend gentleman just
alluded to, Dr. Wagtail giving the bride away. A splendid banquet
was then served up; and shortly after ten o'clock Mr. and Mrs.
Torrens departed together for the Cottage.
CHAPTER LXXXIII.
THE REWARD OF CRIME.

At half-past eleven on the following morning, Mr. Torrens entered the


office of Mr. Howard, the solicitor.
His countenance wore a smile of satisfaction, in spite of the various
events which had lately occurred to harass him; for he was about to
receive a large sum of money—and his fingers itched to grasp the
bank-notes and the gold which he had seen stowed away in the safe
on the preceding day.
He already beheld his debts paid—his mind freed from pecuniary
anxieties—and his speculations prospering in a manner giving
assurance of the realization of a splendid fortune; and these pleasing
visions, with which his imagination had cheered itself during the
drive from the Cottage to the attorney's office, naturally tended to
bestow on his countenance the expansiveness of good humour.
And, after all, it is a pleasant thing to enter a place where one is
about to receive a good round sum of money, even though the
amount will not remain long in pocket, but must be paid away
almost as soon as fingered.
Mr. Torrens had never felt more independent than he did on this
occasion; and the look which he bestowed upon a poor beggar-
woman with a child in her arms, as he ascended the steps leading to
the front-door of Mr. Howard's abode, was one of supreme contempt
—as if a pauper were indeed a despicable object!
Well—Mr. Torrens entered the office with a smiling countenance:—
but he was immediately struck by the strange aspect of things which
there presented itself.
The place was in confusion. The clerks were gathered together in a
group near the window, looking particularly gloomy, and conversing
in whispers;—several gentlemen were busily employed in examining
the japanned boxes which bore their names and contained their
title-deeds;—and two or three females were weeping in a corner,
and exchanging such dimly significant observations as—"Oh! the
rascal!"—"The villain!"—"To rob us poor creatures!"
Mr. Torrens recoiled, aghast and speechless, from the contemplation
of this alarming scene. A chill struck to his heart: and, in common
parlance, any one might have knocked him down with a straw.
"Good heavens! gentlemen," he exclaimed, at length recovering the
use of his tongue: "what is the meaning of this?"
"Ask those youngsters there, sir," said one of the individuals
engaged in examining the tin-boxes: and the speaker pointed
towards the clerks in a manner which seemed to imply that the news
were too shocking for him to unfold, and that it was moreover the
duty of the lawyer's subordinates to give the required information.
"Well, gentlemen, what is the matter?" demanded Mr. Torrens,
turning to the clerks. "Has any thing sudden happened to Mr.
Howard?"
"Oh! very sudden indeed, sir," was the answer vouchsafed by one of
the persons thus appealed to, and accompanied by a sinister grin.
"Is he dead?" enquired Mr. Torrens, his excitement now becoming
absolutely intolerable.
"No, sir—he isn't dead exactly—but——"
"But what?" cried Torrens, trembling from head to foot.
"He's bolted, sir!" was the astounding answer.
"Absconded!" murmured Mr. Torrens faintly;—and, reeling like a
drunken man, he would have fallen had he not come in contact with
the wall.
Yes—it was indeed too true: Mr. Howard—the cold, phlegmatic,
matter-of-fact, business-like lawyer—had decamped no one knew
whither, though numbers had to mourn or curse his flight!
"Are you ill, sir?" enquired one of the clerks, at the expiration of a
few moments; for Mr. Torrens was leaning against the side of the
room, his countenance pale as death, his eyes rolling wildly in their
sockets, and his limbs trembling convulsively.
"No—no—I shall be better in a minute," groaned the unhappy man.
"But this blow—is cruel—indeed!" he gasped in a choking voice.
"Two thousand pounds—ruin—ruin!"
"Ah! there's many who'll be ruined by this smash, sir," said the clerk:
"you're not the only one—and that's a consolation."
A consolation indeed!
It was none for Mr. Torrens, who saw himself ruined beyond all hope
of redemption,—ruined in spite of the immense sacrifices he had
made to avert the impending storm—the sacrifice of his daughter's
innocence to Sir Henry Courtenay, and the sacrifice of himself to an
abandoned and profligate woman!
Miserable—miserable man! what hast thou earned by all thine
intriguings—thy schemings—thy black turpitude—and thy deplorable
self-degradation? Oh! better—better far is it to become the
grovelling, whining beggar in the streets, than to risk happiness—
character—name—honour—all, on such chances as those on which
thou didst reckon!
And now, behold him issue forth from that office into which he had
entered with head erect, self-sufficient air, and smiling countenance:
—behold him issue forth—bent down—crushed—overcome—ten
years more aged than he was a few minutes previously,—and an
object of pity even for that poor beggar-woman whom ere now he
had treated with such sovereign contempt!
Miserable—miserable man! has not thy punishment commenced in
this world?—is there not a hell upon earth?—and is not thy heart
already a prey to devouring flames, and thy tongue parched with the
insatiate thirst of burning fever, and thy soul tortured by the undying
worm? Oh! how canst thou return to thy house in the vicinity of
which lies interred a corpse the discovery of which may at any time
involve thee in serious peril?—how canst thou go back to that
dwelling whence thine injured daughter has fled, and over the
threshold of which thou hast conducted a vile strumpet as thy bride?
When we consider how fearfully we are made,—how manifold are
the chances that extreme grief—sudden ruin—and overwhelming
anguish may cause a vessel in the surcharged heart to burst, or the
racked brain to become a prey to the thunder-clap of apoplexy,—it is
surprising—it is truly wondrous that man can support such an
enormous weight of care without being stricken dead when it falls
upon him!
And yet to what a degree of tension may the fibres of the heart be
wrung, ere they will snap asunder!—and what myriads of weighty
and maddening thoughts may agitate in the brain, ere reason will
rock on its throne, or a vein burst with the gush of blood!

In the meantime occurrences of importance were taking place at


Torrens Cottage.
Mrs. Torrens—late Mrs. Slingsby—was whiling away an hour in
unpacking her boxes and disposing of her effects in the wardrobe
and cupboards of her bed-chamber; congratulating herself all the
time on the success which her various schemes had experienced.
She had obtained a husband to save her from disgrace; and that
husband had set out to receive, as she fancied, a considerable sum
of money, which would relieve him of his difficulties, and enable him
to pursue his undertakings in such a manner as to yield ample
revenues for the future! She was moreover rejoiced that Rosamond
had quitted the house;—for, shameless as this vile woman was, she
could not have failed to be embarrassed and constrained in her new
dwelling, had that injured girl met her there!
While Mrs. Torrens was thus engaged with her domestic avocations
and her self-gratulatory thoughts in her bed-chamber, the stable-boy,
who had been hired on the preceding day, was occupying himself in
the garden.
"Well, what do you think of your new missus?" he said to the maid-
servant, who had just been filling a stone-pitcher at the pump in the
yard.
"She seems a decent body enow," was the reply. "But I haven't seen
much of her yet. What are you doing there, Harry?"
"Why, you must know that I'm rather a good hand at gardening,"
answered the lad, desisting from his occupation of digging a hole in
the ground, and resting on his spade: "and I'm going to move that
young tree to this spot here—because it's all in the shade where it
stands now, and will never come to no good."

You might also like