0% found this document useful (0 votes)
25 views

(Ebook) Getting Started with Sensors: Measure the World with Electronics, Arduino, and Raspberry Pi by Kimmo Karvinen, Tero Karvinen ISBN 9781449367084, 1449367089 instant download

Getting Started with Sensors by Kimmo and Tero Karvinen is a hands-on guide that teaches readers how to connect and read various sensors using Arduino and Raspberry Pi. The book includes a series of projects that cover different types of sensors, such as light, temperature, and proximity sensors, enabling users to create their own devices. It emphasizes the accessibility of sensors and microcontrollers, making it suitable for beginners interested in electronics and DIY projects.

Uploaded by

stongmasey17
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
0% found this document useful (0 votes)
25 views

(Ebook) Getting Started with Sensors: Measure the World with Electronics, Arduino, and Raspberry Pi by Kimmo Karvinen, Tero Karvinen ISBN 9781449367084, 1449367089 instant download

Getting Started with Sensors by Kimmo and Tero Karvinen is a hands-on guide that teaches readers how to connect and read various sensors using Arduino and Raspberry Pi. The book includes a series of projects that cover different types of sensors, such as light, temperature, and proximity sensors, enabling users to create their own devices. It emphasizes the accessibility of sensors and microcontrollers, making it suitable for beginners interested in electronics and DIY projects.

Uploaded by

stongmasey17
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/ 57

(Ebook) Getting Started with Sensors: Measure

the World with Electronics, Arduino, and


Raspberry Pi by Kimmo Karvinen, Tero Karvinen
ISBN 9781449367084, 1449367089 download
https://ebooknice.com/product/getting-started-with-sensors-
measure-the-world-with-electronics-arduino-and-raspberry-
pi-4928970

Explore and download more ebooks at ebooknice.com


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

(Ebook) Make: Arduino Bots and Gadgets: Six Embedded Projects with
Open Source Hardware and Software by Tero Karvinen, Kimmo Karvinen
ISBN 1449389716

https://ebooknice.com/product/make-arduino-bots-and-gadgets-six-
embedded-projects-with-open-source-hardware-and-software-2118704

(Ebook) Make: Arduino Bots and Gadgets: Six Embedded Projects with
Open Source Hardware and Software by Tero Karvinen, Kimmo Karvinen
ISBN 9781449389710, 1449389716

https://ebooknice.com/product/make-arduino-bots-and-gadgets-six-
embedded-projects-with-open-source-hardware-and-software-2269498

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles, James


ISBN 9781459699816, 9781743365571, 9781925268492, 1459699815,
1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

(Ebook) Make a Mind-Controlled Arduino Robot: Use Your Brain as a


Remote by Tero Karvinen, Kimmo Karvinen ISBN 9781449311544, 1449311547

https://ebooknice.com/product/make-a-mind-controlled-arduino-robot-
use-your-brain-as-a-remote-37605416
(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena Alfredsson, Hans
Heikne, Sanna Bodemyr ISBN 9789127456600, 9127456609

https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II Success)


by Peterson's ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018

(Ebook) Getting Started with Python and Raspberry Pi by Dan Nixon

https://ebooknice.com/product/getting-started-with-python-and-
raspberry-pi-54981210

(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT
Subject Test: Math Levels 1 & 2) by Arco ISBN 9780768923049,
0768923042

https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-
arco-master-the-sat-subject-test-math-levels-1-2-2326094

(Ebook) Cambridge IGCSE and O Level History Workbook 2C - Depth Study:


the United States, 1919-41 2nd Edition by Benjamin Harrison ISBN
9781398375147, 9781398375048, 1398375144, 1398375047

https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044
Make:

Make:
Sensors/ DIY Projects

Getting Started with Sensors


Getting

Getting Started with Sensors


Sensors surround us. The world is full of them: infrared sensors in
motion detectors, carbon monoxide detectors in homes—even

Started with
tiny accelerometers, GPS modules, and cameras inside your
smartphone. Thanks to the proliferation of mobile devices,
sensors are now remarkably affordable, meaning you can

Sensors
combine inexpensive sensors and microcontroller boards to
make your own devices.
This fully-illustrated, hands-on book teaches you to connect and
read sensors through a series of short projects. You’ll learn to use
the immensely popular Arduino and Raspberry Pi boards to
process data through simple programs you develop.

In Getting Started with Sensors, you’ll write programs and


build devices that respond to:

Karvinen & Karvinen


» Rotation with a potentiometer
» Distance with ultrasound
» Proximity with infrared
» Light and dark with a photoresistor
» Temperature with a thermometer
» Relative humidity with a humidity sensor

You’ll also work with resistive and electromechanical sensors, as


well as switches, transducers, potentiometers, buzzers, 555
timers, and voltage dividers.

There’s a whole world out there full of sensory impressions you


can control, track, and manage. How will you capture it?

For more sensor projects, check out the authors’ other


books: Make: Arduino Bots and Gadgets and Make: Sensors.
US $19.99 CAN $20.99
ISBN: 978-1-4493-6708-4 Measure the World with Electronics,
Make: Arduino, and Raspberry Pi
makezine.com
Kimmo Karvinen & Tero Karvinen
Make:

Make:
Sensors/ DIY Projects

Getting Started with Sensors


Getting

Getting Started with Sensors


Sensors surround us. The world is full of them: infrared sensors in
motion detectors, carbon monoxide detectors in homes—even

Started with
tiny accelerometers, GPS modules, and cameras inside your
smartphone. Thanks to the proliferation of mobile devices,
sensors are now remarkably affordable, meaning you can

Sensors
combine inexpensive sensors and microcontroller boards to
make your own devices.
This fully-illustrated, hands-on book teaches you to connect and
read sensors through a series of short projects. You’ll learn to use
the immensely popular Arduino and Raspberry Pi boards to
process data through simple programs you develop.

In Getting Started with Sensors, you’ll write programs and


build devices that respond to:

Karvinen & Karvinen


» Rotation with a potentiometer
» Distance with ultrasound
» Proximity with infrared
» Light and dark with a photoresistor
» Temperature with a thermometer
» Relative humidity with a humidity sensor

You’ll also work with resistive and electromechanical sensors, as


well as switches, transducers, potentiometers, buzzers, 555
timers, and voltage dividers.

There’s a whole world out there full of sensory impressions you


can control, track, and manage. How will you capture it?

For more sensor projects, check out the authors’ other


books: Make: Arduino Bots and Gadgets and Make: Sensors.
US $19.99 CAN $20.99
ISBN: 978-1-4493-6708-4 Measure the World with Electronics,
Make: Arduino, and Raspberry Pi
makezine.com
Kimmo Karvinen & Tero Karvinen
Getting
Started with
Sensors
Kimmo Karvinen and
Tero Karvinen
Getting Started with Sensors
by Kimmo Karvinen and Tero Karvinen

Copyright © 2014 Kimmo Karvinen, Tero Karvinen. All rights reserved.

Printed in the United States of America.

Published by Maker Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
Maker Media books may be purchased for educational, business, or sales promotional use.
Online editions are also available for most titles (http://my.safaribooksonline.com). For more
information, contact O’Reilly Media’s corporate/institutional sales department:
800-998-9938 or [email protected].

Editors: Brian Jepson, David Scheltema, and Emma Dvorak


Production Editor: Nicole Shelby
Copyeditor: Sonia Saruba
Technical Editor: Philipp Marek
Proofreader: Jasmine Kwityn
Cover Designer: Brian Jepson
Interior Designer: Nellie McKesson
Illustrator: Kimmo Karvinen
Photographer: Kimmo Karvinen
Cover Art: Kimmo Karvinen
Technical Advisor: Paavo Leinonen

August 2014: First Edition

Revision History for the First Edition:

2014-08-06: First release

See http://oreilly.com/catalog/errata.csp?isbn=9781449367084 for release details.

Make:, Maker Shed, and Maker Faire are registered trademarks of Maker Media, Inc. The
Maker Media logo is a trademark of Maker Media, Inc.

Many of the designations used by manufacturers and sellers to distinguish their products
are claimed as trademarks. Where those designations appear in this book, and Maker Media,
Inc. was aware of a trademark claim, the designations have been printed in caps or initial
caps.

While every precaution has been taken in the preparation of this book, the publisher and
authors assume no responsibility for errors or omissions, or for damages resulting from the
use of the information contained herein.

ISBN: 978-1-449-36708-4

[LSI]
Contents

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

1/Sensors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Project 1: Photoresistor to Measure Light. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Discussion: Photoresistors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Interactive Sensor Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Going Forward. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2/Basic Sensors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Project 2: A Simple Switch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Troubleshooting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
An LED Needs a Resistor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Project 3: Buzzer Volume Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Troubleshooting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Project 4: Hall Effect. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Troubleshooting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Project 5: Firefly. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Integrated Circuits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
555 Timer IC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Light Up an LED When It’s Bright. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Light to Darkness. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Transistors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Fading an LED. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
555 Fading Blink. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

iii
Capacitors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Firefly. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3/Sensors and Arduino. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33


Project 6: Momentary Push-Button and Pull-Up Resistors. . . . . . . . . . . . . . . . . 34
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Pull-Up Resistors and Arduino. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Project 7: Infrared Proximity to Detect Objects. . . . . . . . . . . . . . . . . . . . . . . . . . 40
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Project 8: Rotation (Pot). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Project 9: Photoresistor to Measure Light. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Project 10: FlexiForce to Measure Pressure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Project 11: Measuring Temperature (LM35). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Project 12: Ultrasonic Distance Measuring (HC-SR04). . . . . . . . . . . . . . . . . . . . 56
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

4/Sensors and the Raspberry Pi. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63


Project 13: Momentary Push Button. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Run the Button Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Troubleshooting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

iv Contents
Hello, Python World. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Project 14: Blink an LED with Python. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Build the LED Blink Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Project 15: Adjustable Infrared Switch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Build the IR Switch Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Voltage Divider. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Analog Resistance Sensors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Project 16: Potentiometer to Measure Rotation. . . . . . . . . . . . . . . . . . . . . . . . . . 77
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Install SpiDev. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Allow SPI Without root. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Project 17: Photoresistor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Playing with Resistance Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Project 18: FlexiForce. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Project 19: Temperature Measurements (LM35). . . . . . . . . . . . . . . . . . . . . . . . . 86
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Project 20: Ultrasonic Distance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Build It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Run the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Real Time or Fast?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

A/ Troubleshooting Tactics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

B/ Arduino IDE Setup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

Contents v
C/ Setting Up Raspberry Pi. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

D/ Bill of Materials. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

vi Contents
Preface

There is a world of things happening around


you, most of which become knowable to you
thanks to one or more of your five senses. Sen-
sory perception happens so quickly, and so
often, that it’s easy to overlook how impressive
a system you actually are.
Take a moment and think how many sensory events happened to you from
the time you woke up to the time you began reading this book. It’s likely that
you can’t even list all the sensory occurrences. Not only do you constantly
sense the environment, but your senses also work together to compile a pic-
ture of the universe. For example, events such as people passing by, warm
sun shining on your face, or observing that a cool breeze in the morning is
getting warmer in the afternoon are all fine examples of your senses at work
and your mind processing sensations. But how can a robot or gadget have
similar input? You probably already know what makes this possible (you did
buy a book on the topic): sensors.
Adding sensors to a circuit expands its capabilities just as your own senses
expand your awareness and inform you about the world. Sensors provide an
input for information about an environment and work much like your own
senses. But sensation isn’t the only issue with sensors. A component doesn’t
necessarily have the ability to draw conclusions when a particular event oc-
curs. Say, for instance, that it is –5 degrees outside and you want to go for a
walk; what should you wear? You know, of course, that a coat and winter
clothing are in order, but a temperature sensor does not know this. It can
certainly provide you with a temperature reading, but it does not make judg-
ments or inferences about what you should wear—at least not at the com-
ponent level. For sensors to matter in the same way that your own sensations
and your reflection on these sensations matter, a level of data processing
needs to occur on the sensor data. Ultimately, sensors are components that
you wire so that, either through hardware or software, their data is processed
—and that’s what this book is about: how to wire sensors and process their
data.
In the first part of this book, you’ll learn how to wire up sensors to other
components. The level of data processing isn’t too robust at the component

vii
level, and the focus is really on just getting a sensor safely wired and teaching
some of the basics. The second part of the book deals with how to process
sensor data. You will learn how to easily and quickly write programs with
Arduino to process sensor data, as well as how to wire and program a Rasp-
berry Pi to support analog sensors.
In this book, you’ll gain hands-on experience with some of the most useful
and instructive sensors available. Among the sensors and applications in this
book, you’ll learn how to detect and respond to:

• Clicks and rotation with a potentiometer


• Distance with ultrasound
• Proximity with infrared sensors
• Light and dark with a photoresistor
• Temperature with a thermometer
• Relative humidity with a capacitive relative humidity sensor

What Sensors to Buy?


This book covers a number of specific sensors and components (a few are
illustrated in Figure P-1). To make sourcing parts easier, we’ve included Ap-
pendix D, which lists a complete bill of materials for all the projects in this
book.

Figure P-1. Arduino, sensors, and components

Some well-known sellers of Arduino boards and related parts include Maker
Shed, SparkFun Electronics, Parallax, and Adafruit. All four of these shops
should stock most of the individual sensors used in this book, and all sell
original, high-quality parts. Start with these shops.
Global electronics distributors, like Element14 and RS Components, are
great places to order parts from, too. However, their product lists can be
daunting for beginners to navigate. These global suppliers stock parts that
differ from each other only in the pin format or voltage tolerances, which can

viii Preface
be quite exhaustive. The parts sold from both of these global suppliers are
high quality parts and very well documented.
Some online shops are very cheap, but these places typically do not sell of-
ficial Arduino boards—they will say the product is “compatible.” The sensors
they sell may differ slightly in their pin configuration or even general appear-
ance. At the time of writing, DealExtreme is one of the most popular shops
of this sort. Even though they are based in Hong Kong and Shenzhen and
offer free worldwide shipping, the quality of their parts varies a lot and de-
livery time can be slow. AliExpress is another popular Asian shop.
If you’re ordering from abroad, research your local laws regarding custom
fees. In some countries, small orders may be exempt from customs and
taxes.

Conventions Used in This Book


The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file exten-
sions.
Constant width
Used for program listings, as well as within paragraphs to refer to pro-
gram elements such as variable or function names, databases, data
types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by val-
ues determined by context.

This element signifies a tip, suggestion, or general note.

This element indicates a warning or caution.

Using Code Examples


You can download all the source code for this book from http://getstar
ted.botbook.com.

Preface ix
You can extract the zip package by double-clicking it, or by right-clicking and
selecting Extract from the pop-up menu.
This book is here to help you get your job done. In general, you may use the
code in this book in your programs and documentation. You do not need to
contact us for permission unless you’re reproducing a significant portion of
the code. For example, writing a program that uses several chunks of code
from this book does not require permission. Selling or distributing a CD-ROM
of examples from Make: books does require permission. Answering a ques-
tion by citing this book and quoting example code does not require permis-
sion. Incorporating a significant amount of example code from this book into
your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes
the title, author, publisher, and ISBN. For example: “Getting Started With
Sensors by Kimmo Karvinen and Tero Karvinen (Maker Media). Copyright
2014, 978-1-4493-6708-4.”
If you feel your use of code examples falls outside fair use or the permission
given here, feel free to contact us at [email protected].

Safari® Books Online


Safari Books Online is an on-demand digital library that
delivers expert content in both book and video form from
the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business


and creative professionals use Safari Books Online as their primary resource
for research, problem solving, learning, and certification training.
Safari Books Online offers a range of product mixes and pricing programs for
organizations, government agencies, and individuals. Subscribers have ac-
cess to thousands of books, training videos, and prepublication manuscripts
in one fully searchable database from publishers like Maker Media, O’Reilly
Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft
Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley &
Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT
Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course
Technology, and dozens more. For more information about Safari Books On-
line, please visit us online.

How to Contact Us
Please address comments and questions concerning this book to the pub-
lisher:

Make:

x Preface
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

Make: unites, inspires, informs, and entertains a growing community of re-


sourceful people who undertake amazing projects in their backyards, base-
ments, and garages. Make: celebrates your right to tweak, hack, and bend
any technology to your will. The Make: audience continues to be a growing
culture and community that believes in bettering ourselves, our environ-
ment, our educational system—our entire world. This is much more than an
audience, it’s a worldwide movement that Make: is leading—we call it the
Maker Movement.
For more information about Make:, visit us online:

Make: magazine: http://makezine.com/magazine/


Maker Faire: http://makerfaire.com
Makezine.com: http://makezine.com
Maker Shed: http://makershed.com/

We have a web page for this book, where we list errata, examples, and any
additional information. You can access this page at: http://bit.ly/get-start-
sensors.
To comment or ask technical questions about this book, send email to: book
[email protected]

Acknowledgments
The authors would like to thank Hipsu, Marianna, Nina, and Valtteri.

Preface xi
1/Sensors

Sensors surround you in daily life. The world is


full of them: from passive infrared sensors in
motion detectors, to CO2 detectors in air con-
ditioning systems, and even tiny accelerome-
ters, GPS modules, and cameras inside your
smartphone and tablet—sensors are every-
where! The variety of sensor applications is re-
markable.
It’s safe to assume that if an electronic device is considered “smart,” it’s full
of sensors (Figure 1-1). In fact, thanks to the proliferation of smart devices,
especially phones, the price of sensors has been driven to affordability. Not
only is it economically viable to add advanced sensors to your projects, but
they vastly expand the kinds of projects you can make.
You’ll learn about sensors in this book by making small projects and reflecting
on the experience. It’s more fun to build first and discuss later, but both are
equally important. It’s best to avoid the temptation to only build projects and
skip the conceptual sections.
Getting started with sensors is easy, and only the sky is the limit. Electronics
challenge some of the best brains daily and produce new innovations and
dissertations. On the other hand, even a child can get started with some
guidance.
If you don’t know much about sensors yet, try to remember what it feels like
now. After you’ve tackled some challenges and built a couple of gadgets,
many dark mysteries of sensors will probably seem like common sense to
you.
This book is suitable for anyone with an interest in sensors (see Figure 1-2).
After you’ve built the gadgets and have read this book, you can get ideas for
bigger projects from our book Make: Arduino Bots and Gadgets or learn more
advanced sensors in Make: Sensors. For a wider view of the basics, see Get-
ting Started with Arduino, 2nd Edition by Massimo Banzi, Getting Started with
Raspberry Pi by Matt Richardson and Shawn Wallace, or Make: Electronics
by Charles Platt.

1
Figure 1-1. Various sensors: infrared proximity, rotation, brightness, but-
ton, temperature, and distance

What are sensors? Sensors are electrical components that function as input
devices. Not all inputs are explicitly sensors, but almost all inputs use sen-
sors! Consider your computer mouse or trackpad, a keyboard, or even a
webcam; these are not sensors, but they definitely use sensors in their de-
sign. More abstractly, you can frame sensors as a component to measure a
stimulus that is external to the system it is in (its environment). The output
data is based on the measurement. For example, when you type at a key-
board, the letter that appears on your screen (the output) is based on the
measurement (which switch, or key, you pressed on the keyboard). How
many letters appear on screen is based on another measurement (how long
you keep the key pressed).

Figure 1-2. Simple AND connection with buttons, built and designed by a
four-year-old with help from an adult

The first project uses a photoresistor to measure light. Without the photo-
resistor (or similar sensor), there is no way the circuit can know how bright

2 Getting Started with Sensors


the light is in the environment. By adding the sensor, your circuit knows
something it didn’t know before.
All of the projects in this book evaluate a particular stimulus within the envi-
ronment. None of this would be possible without sensors. Let’s get building
so you can experience the inputs and outputs that sensors provide to
projects.

Project 1: Photoresistor to Measure


Light
Light in an environment is quite informative: you can determine what time of
day it is based on the sun’s angle, you operate a car more safely at night when
its lights are on, and people who do not experience enough light in daily life
can become depressed with seasonal affective disorder. As such, light influ-
ences many aspects of your life and it’s fun to measure it, too.
The simplest sensor for detecting light is a photoresistor. It’s not uncommon
to also encounter another name for the exact same sensor: light-dependent
resistor (LDR). The component works by changing its resistance based on
the amount of light hitting it.
Now that you know the right sensor to use, the next question to think about
is how to process the sensor’s measurements. If you’ve ever worked with a
light-emitting diode (LED) , shown in Figure 1-3, you might know that resist-
ance is an electrically important consideration. For example, if you’ve ever
used a larger-value resistor for the LED than a project called for, you’ve seen
that too much resistance can restrict an LED from illuminating. This same
basic observation is applicable to this project.

Figure 1-3. LEDs

Sensors 3
The circuit is designed so that an LED is dependent on the photoresistor’s
measurement. Too much resistance and the LED simply will not turn on.
Enough discussion—it’s time to build! Figure 1-4 shows the finished project.

Figure 1-4. The finished photoresistor project

Parts
You need the following parts for this project:

• Photoresistor
• 5 mm red LED (different LEDs will work differently with this circuit; later,
you’ll learn a more sophisticated way to fade LEDs)
• 470 Ω resistor (four-band resistor: yellow-violet-brown; five-band resis-
tor: yellow-violet-black-black; the last band will vary depending on the
resistor’s tolerance)
• Breadboard
• 9 V battery clip
• 9 V battery

All of these parts, except the 9 V battery and 470 Ω resistor,


are available in the Maker Shed Mintronics: Survival Pack, part
number MSTIN2. You can use two of the 220 Ω resistors in
series or one 1 kΩ resistor in place of the 470 Ω resistor; both
of these are available from electronics retailers such as
RadioShack.

4 Getting Started with Sensors


Build It
Here are the steps for building this project:

1. Orient your breadboard so that it is wider than it is tall, as shown in


Figure 1-5.

Figure 1-5. Circuit digram for photoresistor project

2. Look at your LED and determine which lead has a flat side above it on
the colored plastic housing—this indicates the negative lead of the LED
(the negative lead is also the shorter of the two), as shown in
Figure 1-6. LEDs have a certain polarity and putting them in backward
might damage them.

Figure 1-6. Negative leg of the LED

3. Insert the photoresistor so that the negative lead of the LED and one of
the photoresistor leads occupy the same column. The second (positive)

Sensors 5
LED lead should occupy its own column for now. Refer back to Figure 1-5
to see how they should be arranged.

Do you see the gap in the middle of the breadboard in


Figure 1-7? That gap separates the two groups of columns,
and there’s no connection across it. If you want two leads
in the same column to be connected, be sure they are on
the same side of the gap.

Figure 1-7. Breadboard layout

4. Connect the 470 Ω resistor to the column with the positive LED lead and
make sure it’s not the same column that already has the photoresistor
and LED’s negative lead in it. Make sure that the resistor’s other lead is
in a separate column.
5. Attach the black wire from the battery clip to the column that contains
only a photoresistor lead.
6. Insert the red wire from the battery clip to the column that contains only
a resistor lead.
7. Double-check the steps and if everything looks like Figure 1-5, connect
the 9 V battery.

That’s it. You’ve built your first sensor circuit. Congratulations!

Discussion: Photoresistors
It might not seem like the circuit is doing much. That’s because the light levels
probably have not changed much in your room. Put your finger over the pho-
toresistor and watch the LED closely. Did anything seem to change with the
LED? There should have been some change in the LED brightness. Try adding
more light to the photoresistor. The opposite happened, right? Now that
you’ve seen the photoresistor in action, how would you describe what is going

6 Getting Started with Sensors


Exploring the Variety of Random
Documents with Different Content
58, a law which had been made forbidding foreign temples to be
located within a certain area of the city, necessitated the destruction
of a temple of Isis, not one man could be found who would touch
the sacred building, and at last the Consul, Lucius Paullus, was
obliged to tuck up his toga and set to work upon the demolition of
the edifice with his own hands. Thus, this inaugural ceremony, so
lavishly organised by Cæsar, was a marked success; and in spite of
the indignation of Cicero, the statue of Cleopatra took its permanent
place, with popular consent, in the sanctuary of Venus. No expense
was spared on this or on any other occasion to please the people;
and at one time twenty-two thousand persons partook of a
sumptuous meal at Cæsar’s expense. Such a courting of the people
was, indeed, necessary at this time; for although the Dictator was at
the moment practically omnipotent, and though there was talk of
securing him in his office for a term of ten years, his party had not
that solidity which was to be desired of it. Antony, the right-hand
man of the Cæsarians, was, at the time, in some disgrace owing to a
quarrel with his master; and there were rumours that he wished to
revenge himself by assassinating Cæsar. It was already becoming
clear that the Pompeian party, in spite of Pharsalia and Thapsus, was
not yet dead, and still waited to receive its death-blow. Some of the
Dictator’s actions had given considerable offence, and there were
certain people in Rome who made use of every opportunity to
denounce him, and to offer their praise to the memory of his enemy
Cato, whose tragic death after the battle of Thapsus, and the
vilification of whose memory in the recent Triumph, had caused such
a painful impression. Cicero wrote an encomium upon this
unfortunate man, to which Cæsar, in self-defence, replied by
publishing his Anti-Cato, which was marked by a tone of bitter and
even venomous animosity. All manner of unpleasant remarks were
being made in better-class circles in regard to Cleopatra; and when
the Dictator publicly admitted the parentage of their child, and
authorised him to bear the name of Cæsar, it began to be whispered
that his legal marriage to the Queen was imminent.
The mixed population of Rome delighted in political strife, and
though Cæsar’s position seemed unassailable, there were always
large numbers of persons ready to make sporadic attacks upon it.
There was at this time constant rioting in the Forum, and an almost
continuous restlessness was to be observed in the streets and public
places. In the theatres topical allusions were received with frantic
55
applause; and even in the Senate disturbances were not
infrequent. The people had always to be humoured, and Cæsar was
obliged at all times to play to the gallery. Fortunately for him he
56
possessed in the highest degree the art of self-advertisement; and
his charm of manner, together with his striking and handsome
appearance, made the desired appeal to the popular fancy. His
relationship to Cleopatra stood, on the whole, in his favour amongst
the lower classes, who had hailed him with coarse delight as the
terror of the women of Gaul; and the fact that she was a foreigner
mattered not in the least to the heterogeneous population of Rome.
They themselves were largely a composition of the nations of the
earth; and that Cæsar’s mistress, and probable future wife, was a
Greek, was to them in no wise a matter for comment. In any theatre
in Rome at that date one might sit amidst an audience of foreigners
to hear a drama given (at Cæsar’s expense, by the way) in language
such as Greek, Phœnician, Hebrew, Syrian, or Spanish. To them
Cleopatra must have appeared as a wonderful woman, closely
related to the gods, come from a famous city across the waters to
enjoy the society of their own half-godlike Dictator; and they were
quite prepared to accept her as a pleasant and romantic adjunct to
the political situation.
Among the many reforms which Cæsar now introduced there
was one which was the direct outcome of his visit to Egypt. For
some time the irregularities of the calendar had been causing much
inconvenience, and the Dictator, very probably at the Queen of
Egypt’s suggestion, now decided to invite some of Cleopatra’s court
astronomers to Rome in order that they might establish a new
system based upon the Egyptian calendar of Eudoxus. Sosigenes
was at that time the most celebrated astronomer in Alexandria, and
it was to him, perhaps at Cleopatra’s advice, that Cæsar now turned.
After very careful study it was decided that the present year, B.C. 46,
should be extended to fifteen months, or 445 days, in order that the
nominal date might be brought round to correspond with the actual
season. The so-called Julian calendar, which was thus established, is
that upon which our present system is based; and it is not without
interest to recollect that but for Cleopatra some entirely different set
of months would now be used throughout the world.
Cæsar’s mind at this time was full of his plans for the conquest
of the East. In B.C. 65 Pompey had brought to Rome many details
regarding the overland route to the Orient. This route started from
the Port of Phasis on the Black Sea, ascended the river of that name
to its source in Iberia, passed over to the valley of the river Cyrus
(Kur), and so came to the coast of the Caspian Sea. Crossing the
water the route thence led along the river Oxus, which at that time
flowed into the Caspian, to its source, and thus through Cashmir into
India. There must then have been some talk of carrying the eagles
along this highway to the Orient; and while Cæsar was in Egypt it
seems probable, as we have seen, that he had studied the question
of leading Roman arms thither by the great Egyptian trade route.
Though this latter road to the wonderful Orient, however, must have
seemed to him, after consideration, to be very suitable as a channel
for the despatch of reinforcements, he appears to have favoured the
land route across Asia for his original invasion. This approach to the
East was blocked by the Parthians, and Cæsar now announced his
intention of conducting a campaign against these people. There is
no evidence to show that he desired to follow Alexander’s steps
beyond Parthia into India, but I am of opinion that such was his
intention. In view of the facts that the exploits of Alexander the
Great had been studied by him, that he publicly declared his wish to
rival them, that he must have heard from Pompey of the overland
route to India with which the Romans had become acquainted
during the war against Mithridates, that his love of distant conquest
and exploration was inordinate, that he had spent some months in
studying conditions in Egypt—a country which was in those days full
of talk of India and of the new trade with the Orient, that after
leaving Egypt he began at once to prepare for a campaign against
the one nation which obstructed the overland route to the East, that
no other part of the known world, save poverty-stricken Germania,
remained to be brought by conquest under Roman sway, that India
offered possibilities of untold wealth, and that Cleopatra herself
ultimately made an attempt to reach those far countries,—the
inference seems to me to be clear that Cæsar’s designs upon Parthia
were only preliminary to a contemplated invasion of the East. The
riches of those distant lands were already the talk of the age, and
within the lifetime of young men of this period streams of Indian
merchandise, comprising diamonds, precious stones, silks, spices,
and scents, began to pour into Rome and were sold each year,
according to the somewhat exaggerated account of Pliny, for some
57
forty million pounds sterling. Could Cæsar, the world’s greatest
spendthrift, the world’s most eager plunderer, have resisted the
temptation of making a bid for the loot which lay behind Parthia?
Does the fact that he said nothing of such an intention preclude the
possibility that thoughts of this kind now filled his mind, and formed
a topic of conversation between him and the adventurous Cleopatra,
the Ruler of the gateway of the Orient, who herself sent Cæsar’s son
to India, as we shall see in due course? Napoleon, when he invaded
Egypt in 1798, said very little about his contemplated attack upon
India; but it was none the less dominant in his mind for that. Egypt
and Parthia in conjunction formed the basis of any attempt to
capture the Orient: Egypt with its route across the seas, and Parthia
with its highroad overland. Are we really to suppose that Cæsar did
waste his time in Egypt, or was he then studying the same problem
which now directed his attention to Parthia? By means of his
partnership with Cleopatra he had secured one of the routes to
India; and the merchants of Alexandria, if not his own great
imagination, must have made clear to him the value of his
possession in that regard; for ever since the discovery of the over-
sea route to the East that value has been recognised. The Venetian
Sanuto in later years told his compatriots of the effect on India
which would follow from the conquest of the Nile Valley; the Comte
Daru said that the possession of Egypt meant the opening up of
India; Leibnitz told Louis XIV. of France that an invasion of Egypt
would result in the capture of the Indian highroad; the Duc de
Choiseul made a similar declaration to Louis XV.; Napoleon stated in
his ‘Memoirs’ that his object in attacking Egypt was to lead an army
of 60,000 men to India; and at the present day England holds the
Nile Valley as being the gateway of her distant possessions. On the
other side of the picture we see at the present time the attempts of
Russia to establish her power in Northern Persia and Afghanistan,
where once the Parthians of old held sway, in order to be ready for
that day when English power in India shall decline. Was Cæsar, then,
straining every nerve only for the possession of the two gateways of
the Orient, or did his gaze penetrate through those gateways to the
vast wealth of the kingdoms beyond? I am disposed to see him
walking with Cleopatra in the gardens of the villa by the Tiber, just
as Napoleon paced the parks of Passeriano, “frequently betraying by
his exclamations the gigantic thoughts of his unlimited ambition,” as
Lacroix tells us of the French conqueror.
Such dreams, however, were rudely interrupted by the news that
the Pompeian party had gathered its forces in Spain; and Cæsar was
obliged to turn his attention to that part of the world. In the winter
of B.C. 46, therefore, he set out for the south-west, impatient at the
delay which the new campaign necessitated in his great schemes.
He was in no mood to brook any opposition in Rome, and before
leaving the capital he arranged that he should be made Consul
without a colleague for the ensuing year B.C. 45, as well as Dictator,
thus giving himself absolutely autocratic power. On his way to Spain
he sent a despatch to Rome, appointed eight praefecti urbi with full
powers to act in his name, thus establishing a form of cabinet
government which should entirely over-ride the wishes of the Senate
and of the people; and in this manner he secured the political
situation to his own advantage. Naturally there was a very great
outcry against this high-handed action; but Cæsar was far too
deeply occupied by his vast schemes, and far too annoyed by this
Spanish interruption of his course towards the great goal of his
ambitions, to pay much attention to the outraged feelings of his
political opponents.
The enemy in Spain were led by the two sons of the great
Pompey, but at the battle of Munda, fought on March 17, B.C. 45,
they were entirely defeated with a loss of some thirty thousand men.
The elder of the two leaders, Cnæus Pompeius, who was said to
have once been a suitor for Cleopatra’s heart, was killed shortly after
the battle, but the younger, Sextus, escaped. Cæsar then returned to
Rome, being met outside the capital by Antony, with whom he was
reconciled; and in the early summer he celebrated his Triumph. In
this he offended a number of persons, owing to the fact that his
victory had been won over his fellow-countrymen, whose defeat,
therefore, ought not to have been the cause of more than a silent
satisfaction. After Pharsalia Cæsar had celebrated no triumph, since
Romans had there fought Romans; and, indeed, as Plutarch says,
“he had seemed rather to be ashamed of the action than to expect
honour from it.” But now he had come to feel that he himself was
Rome, and that his enemies were not simply opposed to his party
but were in arms against the State.
Knowing now that the Pompeians were at last crushed, Cæsar
decided to attempt to appease any ill-feeling directed against himself
by the friends of the fallen party; and for this purpose he caused the
statues of Pompey the Great, which had been removed from their
pedestals, to be replaced; and furthermore, he pardoned, and even
gave office to, several leaders of the Pompeian party, notably to
Brutus and Cassius, who afterwards were ranked amongst his
murderers. He then settled down in Rome to prepare for his
campaign in the East, and, in the meantime, to put into execution
the many administrative reforms which were maturing in his restless
brain. It appears that he lived for the most part of this time in the
house of which his wife Calpurnia was mistress; but there can be
little doubt that he was a constant visitor at his transpontine villa,
and that he spent all his spare hours there in the society of
Cleopatra, who remained in Rome until his death.
CHAPTER IX.

THE FOUNDATIONS OF THE EGYPTO-ROMAN


MONARCHY.

The people of Rome now began to heap honours upon Cæsar,


and the government which he had established did not fail to justify
its existence by voting him to a position of irrevocable power. He
was made Consul for ten years, and there was talk of decreeing him
Dictator for life. The Senate became simply an instrument for the
execution of his commands; and so little did the members concern
themselves with the framing of new laws at home, or with the
details of foreign administration, that Cicero is able to complain that
in his official capacity he had received the thanks of Oriental
potentates whose names he had never seen before, for their
elevation to thrones of kingdoms of which he had never heard.
Cæsar’s interests were world-wide, and the Government in Rome
carried out his wishes in the manner in which an ignorant Board of
Directors of a company with foreign interests follows the advice of
its travelling manager. He had lived for such long periods in foreign
countries, his campaigns had carried him over so much of the known
world’s surface, that Rome appeared to him to be nothing more than
the headquarters of his administration, and not a very convenient
centre at that. His intimacy with Cleopatra, moreover, had widened
his outlook, and had very materially assisted him to become an
arbiter of universal interests. Distant cities, such as Alexandria, were
no longer to him the capitals of foreign lands, but were the seats of
local governments within his own dominions; and the throne towards
which he was climbing was set at an elevation from which the
nations of the whole earth could be observed.
In accepting as his own business the concerns of so many lands,
he was assuming responsibilities the weight of which no man could
bear; yet his dislike of receiving advice, and his uncontrolled vanity,
led him to resent all interference, nor would he admit that the strain
was too great for his weakened physique. Intimate friends of the
Dictator, such as Balbus and Oppius, observed that he was daily
growing more irritable, more self-opinionated; and the least
suggestion of a decentralisation of his powers caused him increasing
annoyance. He wished always to hold the threads of the entire
world’s concerns in his own hands. Now he was discussing the future
of North African Carthage and of Grecian Corinth, to which places he
desired to send out Roman colonists; now he was regulating the
affairs of Syria and Asia Minor; and now he was absorbed in the
agrarian problems of Italy. There were times when the weight of
universal affairs pressed so heavily upon him that he would exclaim
that he had lived long enough; and in such moods, when his friends
warned him of the possibility of his assassination, he would reply
that death was not such a terrible matter, nor a disaster which could
come to him more than once. The frequency of his epileptic seizures
was a cause of constant distress to him, and his gaunt, almost
haggard, appearance must have indicated to his friends that the
strain was becoming unbearable. Yet ever his ambitions held him to
his self-imposed task; and always his piercing eyes were set upon
that goal of all his schemes, the monarchy of the earth.
People were now beginning to discuss openly the subject of his
elevation to the throne. It was freely stated that he proposed to
make himself King and Cleopatra Queen, and, further, that he
intended to transfer the seat of his government to Alexandria, or
some other eastern city. The site of Rome was not ideal. It was too
far from the sea ever to be a first-rate centre of commerce; nor had
it any natural sources of wealth in the neighbourhood. The streets,
which were narrow and crookedly built, were liable to be flooded at
58
certain seasons by the swift-flowing Tiber. Pestilence and sickness
were rife amongst the congested quarters of the city; and in the
middle ages, as Mommsen has pointed out, “one German army after
another melted away under its walls and left it mysteriously
victorious.” After the battle of Actium, Augustus wished to change
the capital to some other quarter of the globe, as, for example, to
Byzantium; and it is very possible that the idea originated with
Cæsar. At the period with which we are now dealing Rome was far
less magnificent than it became a few years later, and it must have
compared unfavourably with Alexandria and other cities. Its streets
ascended and descended, twisted this way and that, in an amazing
manner; and so narrow were they that Cæsar was obliged to pass a
law prohibiting waggons from being driven along them in the
daytime, all porterage being performed by men or beasts of burden.
The great public buildings and palaces of the rich rose from amidst
the encroaching jumble of small houses like exotic plants hemmed in
by a mass of overgrown weeds; and Cæsar must often have given
envious thought to Alexandria with its great Street of Canopus and
its Royal Area.
Those who study the lives of Cleopatra and Cæsar in conjunction
cannot fail to ask themselves how far the Queen influenced the
Dictator’s thoughts at this time. During these last years of his life—
the years which mark his greatness and give him his unique place in
history—Cleopatra was living in the closest intimacy with him; and,
so far as we know, there was not another man or woman in the
world who had such ample opportunities for playing an influential
part in his career. If Cleopatra was interested, as we know she was,
in the welfare of her country and her royal house, or in the career of
herself and Cæsar, or in the destiny of their son, it is palpably
impossible to suppose that she did not discuss matters of statecraft
with the man who was, in all but name, her husband. At a future
date Cleopatra was strong enough to play one of the big political
rôles in history, dealing with kingdoms and armies as the ordinary
woman deals with a house and servants; and in the light of the
knowledge of her character as it is unfolded to us in the years after
the Dictator’s death, it is not reasonable to suppose that in Rome
she kept aloof from all his schemes and plans, deeming herself
capable of holding the attention of the master of the world’s
activities by the entertainments of the boudoir and the arts of the
bedchamber. Her individuality does not dominate the last years of
the Roman Republic, merely because of the profligacy of her life with
Antony and the tragedy of their death, but because her personality
was so irresistible that it influenced in no small degree the affairs of
the world. I am of opinion that Cleopatra’s name would have been
stamped upon the history of this period even though the events
which culminated at Actium had never occurred. The romantic
tragedy of her connection with Antony has captured the popular
taste, and has diverted the attention of historians from the facts of
her earlier years. There is a tendency completely to overlook the
influence which she exercised in the politics of Rome during the last
59
years of Cæsar’s life. The eyes of historians are concentrated upon
the Alexandrian drama, and the tale of Cleopatra’s life in the
Dictator’s villa is overlooked. Yet who will be so bold as to state that
a Queen, whose fortunes were linked by Cæsar with his own at the
height of his power, left no mark upon the events of that time?
When Cleopatra came to Rome her outlook upon life must have been
in striking contrast to that of the Romans. The republic was still the
accepted form of government, and as yet there was no definite
movement towards monarchism. The hereditary emperors of the
future were hardly dreamed of, and the kings of the far past were
nigh forgotten. Now, although it may be supposed that Cleopatra, by
contact with the world, had adopted a moderately rational view of
her status, yet there can be no doubt that the sense of her royal and
divine personality was far from dormant in her. Her education and
upbringing, as I have already said, and now the adulation of Cæsar,
must have influenced her mind, so that the knowledge of her royalty
was at all times almost her predominant characteristic; and it would
be strange indeed if the Dictator’s thoughts had been proof against
the insinuating influence of this atmosphere in which he chose to
spend a great portion of his time. Did Rome herself supply Cæsar’s
stimulus, Rome which had not known monarchy for four hundred
and fifty years? But admitting that Rome was ripe for monarchy, and
that circumstances to some extent forced Cæsar towards that form
of government, can we declare that the Dictator would, of his own
accord, have embraced sovereignty and even divinity so rapidly had
his consort not been a Queen and a goddess?
During the last months of his life—namely, from his return to
Rome in the early summer after the Spanish campaign to his
assassination in the following March—Cæsar vigorously pressed
forward his schemes in regard to the monarchy. Originally, it would
seem, he had intended to complete his eastern conquests before
making any attempt to obtain the throne; but now the long delay in
his preparations for the Parthian campaign had produced a feeling of
impatience which could no longer be controlled. Moreover, his
attention had been called to an old prophecy which stated that the
Parthians would not be conquered until a King of Rome made war
upon them; and Cæsar was sufficiently acute, if not sufficiently
superstitious, to be influenced to an appreciable extent by such a
declaration. Little by little, therefore, he assumed the prerogatives of
kingship, daily adding to the royal character of his appearance, and
daily assuming more autocratic and monarchical powers.
It was not long before he caused himself to be given the
hereditary title of Imperator, a word which meant at that time
“Commander-in-chief,” and had no royal significance, though the fact
that it was made hereditary gave it a new significance. It is to be
observed that the persons who framed the decree must have
realised that the son to whom the title would descend would
probably be that baby Cæsar who now ruled the nurseries of the
villa beside the Tiber; for there can be little doubt that the Dictator’s
legitimate marriage to Cleopatra at the first opportune moment was
confidently expected by his supporters; and we are thus presented
with the novel spectacle of enthusiastic Roman statesmen offering
the hereditary office of Imperator to the future King of Egypt. There
can surely be no clearer indication than this that the people of Rome
60
took no exception to Cleopatra’s foreign blood, nor thought of her
in any way as an Oriental. The attitude of the majority of modern
historians suggests that they picture the Dictator at this time as
living with some sort of African woman whom he had brought back
with him from Egypt; but I must repeat that I am convinced that in
actual fact the Romans regarded Cleopatra as a royal Greek lady
whose capital city of Alexandria was the rival of the Eternal City in
wealth, magnificence, and culture, bearing to Rome, to some extent,
the relationship which New York bears to London. It was rumoured
at this time that a law was about to be introduced by one of the
tribunes of the people which would enable Cæsar, if necessary, to
have two wives—Calpurnia and Cleopatra—and that the new wife
need not be a Roman. The people could have felt no misgivings at
the thought of Cleopatra’s son being Cæsar’s heir; for already they
knew well enough that Cæsar was to be King of Rome, and by his
marriage with Cleopatra they realised that he was adding to Rome’s
dominions without force of arms the one great kingdom of the
civilised world which was still independent, and was securing for his
heirs upon the Roman throne the honourable appendage of the
oldest crown in existence, and the vast fortune which went with it.
In later years, when Cleopatra as the consort of Antony had become
a public enemy, there was much talk of an East-Mediterranean peril,
and the Queen came to represent Oriental splendour as opposed to
Occidental simplicity; but at the time with which we are now dealing
this attitude was entirely undeveloped, and Cleopatra was regarded
as the most suitable mother for that son of Cæsar who should one
day inherit his honours and his titles.
Vatican]

[Photograph by Anderson.

JULIUS CÆSAR.

At about this date the baby actually became uncrowned King of


Egypt, for Cleopatra’s young brother, Ptolemy XV., mysteriously
passes from the records of history, and is heard of no more.
Whether Cleopatra and Cæsar caused him to be murdered as
standing in the way of their ambitions, or whether he died a natural
death, will now never be known. He comes into the story of these
eventful days like a shadow, and like a shadow he disappears; and
61
all that we know concerning his end is derived from Josephus, who
states that he was poisoned by his sister. Such an accusation,
however, is only to be expected, and would certainly have been
made had the boy died of a sudden illness. It is therefore not just to
Cleopatra to burden her memory with the crime; and all that one
may now say is that, while the death of the unfortunate young King
may be attributed to Cleopatra without improbability, there is really
no reason to suppose that she had anything to do with it.
Cæsar now caused a statue of himself to be erected in the
Capitol as the eighth royal figure there, the previous seven being
those of the old Kings of Rome. Soon he began to appear in public
clad in the embroidered dress of the ancient monarchs of Alba; and
he caused his head to appear in true monarchical manner upon the
Roman coins. A throne of gold was provided for him to sit upon in
his official capacity in the Senate and on his tribunal; and in his hand
he now carried a sceptre of ivory, while upon his head was a chaplet
of gold in the form of a laurel-wreath. A consecrated chariot, like the
sacred chariot of the Kings of Egypt, was provided for his
conveyance at public ceremonies, and a kind of royal bodyguard of
senators and nobles was offered to him. He was given the right,
moreover, of being buried inside the city walls, just as Alexander the
Great had been laid to rest within the Royal Area at Alexandria.
These marks of kingship, when observed in conjunction with the
hereditary title of Imperator which had been conferred upon him,
and the lifelong Dictatorship which was about to be offered to him,
are indications that the goal was now very near at hand; and both
Cæsar and Cleopatra must have lived at the time in a state of
continuous excitement and expectation. Everybody knew what was
in the air, and Cicero went so far as to write a long letter to Cæsar
urging him not to make himself King, but he was advised not to send
it. The ex-Consul Lucius Aurelius Cotta inserted the thin edge of the
wedge by proposing that Cæsar should be made King of the Roman
dominions outside Italy; but the suggestion was not taken up with
much enthusiasm. Cæsar himself seems to have been undecided as
to whether he should postpone the great event until after the
Parthian war or not, and the settlement of this question must have
given rise to the most anxious discussions.
There was no longer need for the Dictator to hide his intentions
with any great care; and as a preliminary measure he did not
hesitate to proclaim to the public his belief in the divinity of his
person. He caused his image to be carried in the Pompa circenis
amongst those of the immortal gods. A temple dedicated to Jupiter-
Julius was decreed, and a statue in his likeness was set up in the
temple of Quirinus, inscribed with the words, “To the Immortal God.”
A college of priestly Luperci, of whom we shall presently learn more,
was established in his honour; and flamines were created as priests
of his godhead, an institution which reminds one of the manner in
which the Pharaoh of Egypt was worshipped by a body of priests. A
bed of state was provided for him within the chief temples of Rome.
In the formulæ of the political oaths in which Jupiter and the
Penates of the Roman people had been named, the Genius of Cæsar
was now called upon, just as in Egypt the Ka, or genius, of the
sovereign was invoked. “The old national faith,” says Mommsen,
“became the instrument of a Cæsarian papacy”; and indeed it may
be said that it became the instrument actually of a supreme
Cæsarian deification.
By the end of the year B.C. 45 and the beginning of B.C. 44 there
was no longer any doubt in the minds of the Roman people that
Cæsar intended presently to ascend the throne; and the only
question asked was as to whether the event would take place before
or after the Eastern campaign. Some time before February 15th he
was made Dictator for life; and this, regarded in conjunction with the
homage now paid to his person, and the hereditary nature of his title
of Imperator, made the margin between his present status and that
of kingship exceedingly narrow. It is probable that Cæsar was not
determined to introduce the old title of “King,” although he affected
the dress and insignia of those who had been “kings” of Rome. It is
more likely that he was seeking some new monarchical title; and
when, on one occasion, he declared “I am Cæsar, and no ‘King,’” he
may already have decided to elevate his personal name to the
significance of the royal title which it ultimately became, and still in
62
this twentieth century continues to be.
His arrogance was daily becoming more pronounced, and his
ambition was now “swell’d so much that it did almost stretch the
63
sides o’ the world.” He severely rebuked Pontius Aquila, one of the
Tribunes, for not rising when he passed in front of the Tribunician
seats; and for some time afterwards he used to qualify any
declaration which he made in casual conversation by the sneering
words, “By Pontius Aquila’s kind permission.” Once, when a
deputation of Senators came to him to confer new honours upon
him, he, on the other hand, received them without rising from his
seat; and he was now wont to keep his closest friends waiting in an
anteroom for an audience, a fact of which Cicero bitterly complains.
When his authority was questioned he invariably lost his temper, and
would swear in the most horrible manner. “Men ought to look upon
what I say as law,” he is reported by Titus Ampius to have said; and,
indeed, there were very few persons who had the hardihood not to
do so. On a certain occasion it was discovered that some enthusiast
had placed a royal diadem upon the head of one of his statues, and,
very correctly, the two Tribunes caused it to be removed. This so
infuriated Cæsar, who declared the official act to be a deliberate
insult, that he determined to punish the two men at the first
convenient opportunity. On January 26th of the new year this
opportunity presented itself. As he was walking through the streets
some persons in the crowd hailed him as King, whereupon these
zealous officials ordered them to be arrested and flung into prison.
Cæsar at once raised an appalling storm, the result of which was
that the two Tribunes were expelled from the Senate.
Cleopatra’s attitude could not well fail to be influenced by that of
the Dictator; and it is probable that she gave some offence by an
occasional haughtiness of manner. Her Egyptian chamberlains and
court officials must also have annoyed the Romans by failing to
disguise their Alexandrian vanity; and there can be little doubt that
many of Cæsar’s friends began to regard the menage at the
transpontine villa with growing dislike. A letter written by Cicero to
his friend Atticus is an interesting commentary upon the situation. It
seems that the great writer had been favoured by Cleopatra with the
promise of a gift suitable to his standing, probably in return for some
service which he had rendered her. “I detest the Queen,” he writes,
“and the voucher for her promises, Hammonios, knows that I have
good cause for saying so. What she promised, indeed, were all
things of the learned sort and suitable to my character, such as I
64
could avow even in a public meeting. As for Sara (pion), besides
finding him an unprincipled rascal, I also found him inclined to give
himself airs towards me. I only saw him once at my house; and
when I asked him politely what I could do for him, he said that he
had come in hopes of seeing Atticus. The Queen’s insolence, too,
65
when she was living in Cæsar’s trans-tiberine villa, I cannot recall
without a pang. So I will not have anything to do with that lot.”
The ill-feeling towards Cæsar, which was very decidedly on the
increase, is sufficient to account for the growing unpopularity of
Cleopatra; but it is possible that it was somewhat accentuated by a
slight jealousy which must have been felt by the Romans owing to
the Dictator’s partiality for things Egyptian. Not only did it appear to
Cæsar’s friends that he was modelling his future throne upon that of
the Ptolemies and was asserting his divinity in the Ptolemaic
manner; not only had he been thought to desire Alexandria as the
capital of the Empire; but also he was employing large numbers of
Egyptians in the execution of his schemes. Egyptian astronomers
had reformed the Roman calendar; the Roman mint was being
improved by Alexandrian coiners; the whole of his financial
66
arrangements, it would seem, were entrusted to Alexandrians;
while many of his public entertainments, as, for example, the naval
displays enacted at the inauguration of the Temple of Venus, were
conducted by Egyptians. Cæsar’s object in thus using Cleopatra’s
subjects must have been due, to some extent, to his desire to
familiarise his countrymen with those industrious Alexandrians who
were to play so important a part in the construction of the new
Roman Empire.
The great schemes and projects which were now placed before
the Senate by Cæsar must have startled that institution very
considerably. Almost every day some new proposal was formulated
or some new law drafted. At one time the diverting of the Tiber from
its course occupied the Dictator’s attention; at another time he was
arranging to cut a canal through the Isthmus of Corinth. Now he was
planning the construction of a road over the Apennines; and now he
was deep in schemes for the creation of a vast port at Ostia. Plans of
great public buildings to be erected at Alexandria or in Rome were
being submitted to him; or, again, he was arranging for the
establishment of public libraries in various parts of the capital.
Meanwhile the preparations for the Parthian war must have occupied
the greater part of his time; for the campaign was to be of a vast
character. So sure was he that it would last for three years or more
that he framed a law by virtue of which the magistrates and public
officials for the next three years should be appointed before his
departure. He thereby insured the tranquillity of Rome during his
prolonged absence in the east, thus leaving himself free to carry his
arms into remote lands where communication with the capital might
be almost impossible. When we recollect that Cæsar’s recent
campaigns had all been of but a few months or weeks duration, and
that the words veni, vidi, vici now represented his mature belief in
his own capabilities, these plans for a three years’ absence from
Rome seem to me to indicate clearly that he had no intention of
confining himself to the conquest of Parthia, but desired to follow in
Alexander’s footsteps to India, and thence to return to Rome laden
with the loot of that vast country. He must have pictured himself
entering the capital at the end of the war as the conqueror of the
East, and there could have been no doubt in his mind that the
delighted populace would then accept with enthusiasm his claim to
the throne of the world.
As the weeks went by Cæsar’s plans in regard to the monarchy
became more clearly defined. He does not now seem to have
considered it very wise to press forward the assumption of the
sovereignty previous to the Parthian war, since his long absence
immediately following his elevation to the throne might prove
prejudicial to the new office. Moreover, a strong feeling had
developed against his contemplated assumption of royalty, and
Cæsar must have been aware that he could not put his plans into
execution without considerable opposition. Plutarch tells us that “his
desire of being King had brought upon him the most apparent and
mortal hatred,—a fact which proved the most plausible pretence to
those who had been his secret enemies all along.” Much adverse
comment had been made with reference to his not rising to receive
the Senatorial deputation; and indeed he felt it necessary to make
excuses for his action, saying that his old illness was upon him at the
time. A report was spread that he himself would have been willing to
rise, but that Balbus had said to him, “Will you not remember you
are Cæsar and claim the honour due to your merit?” and it was
further related that when the Dictator had realised the offence he
had given, he had bared his throat to his friends, and had told them
that he was ready to lay down his life if the public were angry with
him. Incidents such as this showed that the time was not yet wholly
favourable for his coup; and reluctantly Cæsar was obliged to
consider its postponement. On the other hand, there was something
to be said in favour of immediate action, and he must have been
more or less prepared to accept the kingship if it were urged upon
him before he set out for the East. The position of Cleopatra,
however, must have caused him some anxiety. Without her and their
baby son the creation of an hereditary monarchy would be
superfluous. His own wife Calpurnia did not seem able to furnish him
with an heir, and there was certainly no other woman in Rome who
could be expected to act the part of Queen with any degree of
success, even if she were proficient in the production of sons and
heirs. Yet how, on the instant, was he to rid himself of Calpurnia and
marry Cleopatra without offending public taste? If he were to accept
the kingship at once and make Cleopatra his wife, was she capable
of sustaining with success the rôle of Queen of Rome in solitude for
three years while he was away at the wars? Would it not be much
wiser to send her back to Egypt for this period, there to await his
return, and then to marry her and to ascend the throne at one and
the same instant? During his absence in the East Calpurnia might
conveniently meet with a sudden and fatal illness, and no man
would dare to attribute her death to his and the apothecary’s
ingenuity.
The will which he now made, or confirmed, in view of his
departure, shows clearly that his desire for the monarchy was
incompatible with his present marital conditions. Without a Queen
and a son and heir there could be little point in creating a throne,
since already he had been made absolute autocrat for his lifetime;
for unless the office was to be handed on without dispute to his son
Cæsarion, there was no advantage in striving for an immediate
elevation to the kingship. By his will, therefore, which was made in
view of his possible death before he had ascended his future throne,
he simply divided his property, giving part of it to the nation and part
to his relations, his favourite nephew, Octavian, receiving a
considerable share. A codicil was added, appointing a large number
of guardians for any offspring which might possibly be born to him
by Calpurnia after his departure; but so little interest did he take in
this remote contingency that he seems to have made no financial
provision for such an infant. There was no need to leave money to
Cleopatra or to her child, since she herself was fabulously wealthy.
This will was, no doubt, intended to be destroyed if he were raised
to the throne before his departure, and it was afterwards believed
that he actually wrote another testament in favour of Cæsarion,
which was to be used if a crown were offered to him; but if, as now
seemed probable, that event were postponed until his return, the
dividing of his property would be the best settlement for his affairs
should he die while away in the East. So long as he remained
uncrowned there was no occasion to refer either to Cleopatra or to
Cæsarion in his testamentary wishes; for if he died in Parthia or
India, still as Dictator, his hopes of founding a dynasty, his plans for
his marriage to the Queen of Egypt, his scheme for training up
Cæsarion to follow in his footsteps, indeed all his worldly ambitions,
would have to be bundled into oblivion. Cæsar was not a man who
cared much for the interests of other people; and, in the case of
Cleopatra, he was quite prepared to leave her to fight for herself in
Egypt, were he himself to be removed to those celestial spheres
wherein he would have no further use for her. His passion for her
appears now to have cooled; and though he must still have enjoyed
her society, and, to a considerable extent, must have been open to
her influence, her chief attraction for him in these latter days lay in
the recognition of her suitability to ascend the new throne by his
side. She, on her part, no doubt retained much of her old affection
for him; and, in spite of his increasing irritability and eccentricity, she
seems to have offered him the generous devotion of a warm-hearted
young woman for a great and heroic old man.
Cæsar, indeed, was old before his time. The famous portrait of
him, now preserved in the Louvre, shows him to have been haggard
and worn. He was still under sixty years of age, but all semblance of
youth had gone from him, and the burden of his years and of his
illness weighed heavily upon his spare frame. His indomitable spirit,
and the keen enthusiasm of his nature, held him to his appointed
tasks; but it is very doubtful whether his constitution could now have
borne the hardships of the campaign which lay before him. His ill-
health must have caused Cleopatra the gravest anxiety, for all her
hopes were centred upon him, and upon that day when he should
make her Queen of the Earth. The fact that he was now considering
the postponement of the creation of the monarchy until after the
Parthian war must have been a heavy blow to her, for there was
good reason to fear lest his strength should give out ere his task
could be completed. For three years and more she had worked with
Cæsar at the laying of the foundations of their throne; and now,
partly owing to the undesirability of leaving Rome for so long a
period immediately after accepting the crown, partly owing to the
difficulty in regard to Calpurnia, and partly owing to the hostility of a
large number of prominent persons to the idea of monarchy, Cæsar
was postponing for three years that coup which seemed to her not
only to mean the realisation of all her personal and dynastic
ambitions, but actually to be the only means by which she could
save Egypt from absorption into the Roman dominions or preserve a
throne of any kind for her son. In the Second Philippic Cicero says of
Cæsar that “after planning for many years his way to royal power,
with great labour and with many dangers, he had effected his
design. By public exhibitions, by monumental buildings, by bribes
and by feasts, he had conciliated the unreflecting multitude. He had
bound to himself his own friends by favours, his opponents by a
show of clemency;” and yet, when in sight of his goal, he hesitated,
believing it better to wait to be carried up to the throne by that wave
of popular enthusiasm which assuredly would burst over Rome when
he should lead back from the East his triumphant, loot-laden
legionaries, and should exhibit in golden chains in the streets of the
capital the captive kings of the fabulous Orient. The delay must have
been almost intolerable to Cleopatra; and it may have been due to
some arrangement made by her with the Dictator and Antony, who
now must have been a constant visitor at Cæsar’s villa, that an
event took place which brought to a head the question of the date of
the establishment of the monarchy.
On February 15th the annual festival of the Lupercalia was
celebrated in Rome; and upon this day all the populace, patrician
and plebeian, were en fête. The Romans of Cæsar’s time do not
seem to have known what was the origin of this festival, nor what
was the real significance of the rites therein performed. They
understood that upon this day they paid their respects to the god
Lupercus; and, in a vague manner, they identified this obscure deity
with Faunus, or with Pan, in his capacity as a producer of fertility
and fecundity in all nature. Two young men were selected from the
honourable order known as the College of the Luperci, and upon this
day these two men opened the proceedings by sacrificing a goat and
a dog. They were then “blooded,” and the ritual prescribed that as
soon as this was done they should both laugh. They next cut the
skins of the victims into long strips or thongs, known as februa; and,
using these as whips, they proceeded to run around the city, striking
at every woman with whom they came into contact. A thwack from
the februa was believed to produce fertility, and any woman who
desired to become a mother would expose herself to the blows
which the two men were vigorously delivering on all sides. By reason
of this strange old custom the day was known as the Dies
67
februatus; and from this is derived the name of the month of
February in which the festival took place.
It seems to me certain that this ceremony was originally related
to the Egyptian rites in connection with the god of fecundity, Min-
Amon, the Pan of the Nile Valley. This god is usually represented
holding in his hand a whip, perhaps consisting originally of jackal-
68
skins tied to a stick; and it has lately been proved that the
hieroglyph for the Egyptian word indicating the reproduction of
69
species is composed simply of these three jackal-skins tied
together, that is to say the februa. We know practically nothing of
the ceremonies performed in Egypt in regard to the februa, but
there is no reason to doubt that the rites were fundamentally similar
to those of the Roman Lupercalia. The dog which was sacrificed in
Rome had probably taken the place of the Egyptian jackal; and the
goat is perhaps to be connected with the Egyptian ram which was
sacred to Amon or Min-Amon.
Now it is very possible that in Alexandria Cleopatra and also
Cæsar had become well acquainted with the Egyptian equivalent of
the Roman Lupercalia, and it may be suggested, tentatively, that
since Cæsar was regarded in that country as the god Amon who had
given fertility to the Queen, he may, in Egypt, have been identified in
some sort of manner with these rites. One may certainly imagine
Cleopatra pointing out to Cæsar the similarity between the two
ceremonies, and suggesting to him that he was, or had acted in the
manner of, a kind of Lupercus. He had practically identified Cleopatra
with Venus Genetrix, the goddess of fertility; and he may well have
attributed to himself the faculties of that corresponding god who
carried on in Rome the traditions of the Egyptian Min, to whom
already Cæsar had been so closely allied by the priests of the Nile.
The Dictator certainly took great interest in the festival of the
Lupercalia in Rome, for he reorganised the proceedings, and actually
founded an order known as the Luperci Julii, a fact which could be
regarded as indicating a definite identification of himself with
Lupercus. Indeed, if he was identified with Min-Amon in Egypt, and
if, as I have suggested, Min-Amon is originally connected with the
Lupercalia celebrations, it may be supposed that Cæsar really
assumed by right the position of divine head of this order. Knowing
the Dictator to have been so careful an opportunist, one is almost
tempted to suggest that he found in this identification an excuse and
a justification for his behaviour to the many women to whom he had
lost his heart; or perhaps it were better to say that his unscrupulous
attitude towards the opposite sex, and the successful manner in
which, as with Cleopatra, he had succeeded in reproducing his kind,
appeared to fit him constitutionally for this particular godhead.
Whether or no Cæsar, in the intolerable arrogance of his last
years, was now actually naming himself the fruitful Lupercus in
Rome as he was the fecund Amon in Egypt, it is a fact that upon this
occurrence of the festival in the year B.C. 44 he was presiding over
the ceremonies, while his lieutenant Antony was enacting the part of
one of the two holders of the februa. On this day Cæsar, pale and
emaciated, was seated in the Forum upon a golden throne, dressed
in a splendid robe, in order to witness the celebrations, when
suddenly the burly Antony, hot from his run, bounded into view,
striking to right and left with the februa, and indulging, no doubt, in
the horse-play which he always so much enjoyed. An excited and
boisterous crowd followed him, and it is probable that both he and
his companions thereupon did homage to the majestic figure of the
Dictator, hailing him as Lupercus and king of the festivities. Profiting
by the enthusiasm of the moment, and acting according to
arrangements previously made with Cleopatra or with Cæsar himself,
Antony now stepped forward and held out to the Dictator a royal
diadem wreathed with laurels, at the same time offering him the
kingship of Rome. Cæsar, as we have seen, had already been
publicly hailed as a god upon earth, and now Antony seems to have
addressed him in his Lupercalian character, begging him to accept
this terrestrial throne as already he had received the throne of the
heavens. No sooner had he spoken than a shout of approval was
raised by a number of Cæsarians who had been posted in different
parts of the Forum for this purpose; but, to Cæsar’s dismay, the
cheers were not taken up by the crowd, who, indeed, appear to
have indulged in a little quiet booing; and the Dictator was thus
obliged to refuse the proffered crown with a somewhat half-hearted
show of disdain. This action was received with general applause, and
the temper of the crowd was clearly demonstrated. Again Antony
held the diadem towards him, and again the isolated and very
artificial cheers of his supporters were heard. Thereupon Cæsar,
accepting the situation with as good a grace as possible, definitely
refused to receive it; and at this the applause once more broke
forth. He then gave orders that the diadem should be carried into
the Capitol, and that a note should be inscribed in the official
calendar stating that on this day the people had offered him the
crown and that he had refused it. It seems probable that Antony,
appreciating the false step which had been made, now rounded off
the incident in as merry a manner as possible, beginning once more
to strike about him with his magical whip, and leading the crowd out
of the Forum with the same noise and horse-play with which they
had entered it.
The chances now in regard to the immediate assumption of the
kingship became more remote. Cæsar intended to set out for Parthia
in about a month’s time; and it must have been apparent to him that
his hopes of a throne would probably have to be set aside until the
coming war was at an end. In regard to Cleopatra nothing remained
for him to do, therefore, but to bid her prepare to return to Egypt,
there to await until the Orient was conquered; and during the next
few weeks it seems that the disappointed and troubled Queen
engaged herself in making preparation for her departure. Suetonius
tells us that Cæsar loaded her with presents and honours in these
last days of their companionship; and doubtless he encouraged her
as best he could with the recitation of his great hopes and ambitions
for the future. There was still a chance that the monarchy would be
created before the war, for there was some talk that Antony and his
friends would offer the crown once more to Cæsar upon the Calends
70
of March; but Cleopatra could not have dared to hope too eagerly
for this event in view of the failure at the Lupercalia. To the Queen,
who had expected by this time to be seated upon the Roman throne,
his reassuring words can have been poor comfort; and an
atmosphere of gloomy foreboding must have settled upon her as she
directed the packing of her goods and chattels and prepared herself
and her baby for the long journey across the Mediterranean to her
now uneventful kingdom of Egypt.
CHAPTER X.

THE DEATH OF CÆSAR AND THE RETURN OF


CLEOPATRA TO EGYPT.

There can be little reason for doubt that Antony, who is to play
so important a part in the subsequent pages of this history, saw
Cleopatra in Rome on several occasions. After his reconciliation to
Cæsar in the early summer of B.C. 45, he must have been a constant
visitor at the Dictator’s villa; and, as we shall presently see, his
espousal of Cleopatra’s cause in regard to Cæsar’s will suggests that
her charm had not been overlooked by him. It is said, as we have
seen, that he had met her, and had already been attracted by her,
ten years previously, when he entered Alexandria with Gabinius in
order to establish her father Auletes upon his rickety throne. He was
a man of impulsive and changeable character, and it is difficult to
determine his exact attitude towards Cæsar at this time. While the
Dictator was in Egypt Antony had been placed in charge of his affairs
in Rome, but owing to a quarrel between the two men, Cæsar, on
his return from Alexandria, had dismissed him from his service. Very
naturally Antony had felt considerable animosity to the Dictator on
this account, and it was even rumoured, as has been said, that he
desired to assassinate him. After the Spanish war, however, the
quarrel was forgotten; and, as we have just seen, it was Antony who
had offered him the crown at the festival of the Lupercalia. In spite
of this, Cæsar does not seem to have trusted him fully, although he
now appears to have been recognised as the most ardent supporter
of the Cæsarian party.
Cæsar had never excelled as a judge of men. Although
unquestionably a genius and a man of supreme mental powers, the
Dictator was ever open to flattery; and he collected around him a
number of satellites who had won their way into his favour by
blandishments and by countenance of their master’s many
eccentricities. Balbus and Oppius, Cæsar’s two most intimate
attendants, were men of mediocre standing; and Publius Cornelius
Dolabella, who now comes into some prominence, was a young
adventurer, whose desire for personal gain must have been
concealed with difficulty. This personage, although only five-and-
twenty years of age, had been appointed by Cæsar to the consulship
which would become vacant upon his own departure for the East, a
move that must have given grave offence to Antony; for Dolabella, a
few years previously, had fallen in love with Antony’s wife, Antonia,
who had consequently been divorced, the outraged husband
thereafter finding consolation in the marriage to his present wife
Fulvia. The various favours conferred by Cæsar on this young scamp
must therefore have caused considerable irritation to Antony; and it
is not easy to suppose that the latter’s apparent devotion to the
cause of the Dictator was altogether genuine. Indeed, the rumour
once more passed into circulation that Antony nursed designs upon
Cæsar’s life, this time, strange to say, in conjunction with Dolabella.
On hearing this report the Dictator remarked that he “did not fear
such fat, luxurious men as these two, but rather the pale, lean
fellows.”
Of the latter type was Cassius, a sour, fanatical soldier and
politician, who had fought against Cæsar at Pharsalia, and had been
freely pardoned by him afterwards. From early youth Cassius
entertained a particular hatred of any form of autocracy; and it is
related of him that when at school the boy Faustus, the son of the
famous Sulla, had boasted of his father’s autocratic powers, Cassius
had promptly punched his head. Cæsar’s attempts to obtain the
throne excited this man’s ferocity, and he was probably the
originator of the plot which terminated the Dictator’s life. The plot
was hatched in February B.C. 44, and, when Cassius and his friends
had prevailed upon the influential and studious Marcus Brutus to join
them, it rapidly developed into a widespread conspiracy. “I don’t like
Cassius,” Cæsar was once heard to remark; “he looks so pale. What
can he be aiming at?”
For Brutus, however, the Dictator entertained the greatest
affection and esteem, and there was a time when he regarded him
as his probable successor in office. One cannot view without
distress, even after the passage of so many centuries, the devotion
of the irritable old autocrat to this scholarly and promising young
man who was now plotting against him; for, in spite of his manifold
faults, Cæsar ever remains a character which all men esteem and
with which all must largely sympathise. On one occasion somebody
warned him that Brutus was plotting against him, to which the
Dictator replied, “What, do you think Brutus will not wait out the
appointed time of this little body of mine?” It is probable that Cæsar
thought it not at all unlikely that Brutus was his own son, for his
mother, Servilia, as early as the year of his birth, and for long
afterwards, had been on such terms of intimacy with Cæsar as
would justify this belief. Brutus, on the other hand, thought himself
to be the son of Servilia’s legal husband, and through him claimed
descent from the famous Junius Brutus who had expelled the
Tarquins. Servilia was the sister of Cato, whose suicide had followed
his defeat by Cæsar in North Africa, and Porcia, the wife of Brutus,
was Cato’s daughter. It might have been supposed, therefore, that
Brutus would have felt considerable antipathy towards the Dictator,
more especially after the publication of his venomous Anti-Cato.
There was, however, equally reasonable cause for Brutus to have
sympathised with Cæsar, for his supposed father had been put to
death by Pompey, an execution which Cæsar had, as it were, been
instrumental in avenging. As a matter of fact, Brutus was a young
man who lived upon high principles, as a cow does upon grass; and
such family incidents as the seduction of his mother, or the
destruction of his mother’s brother and his wife’s father, or the
bloodthirsty warfare between his father’s executioner and his father-
in-law’s enemy and calumniator, were not permitted to influence his
righteous brain. In his early years he had, very naturally, refused on
principle to speak to Pompey, but when the civil war broke out he
set aside all those petty feelings of dislike which, in memory of his
legal father, he had entertained towards the Pompeian faction, and,
on principle, he ranged himself upon that side in the conflict,
believing it to be the juster cause. Pompey is said to have been so
surprised at the arrival of this good young man in his camp, whither
nobody had asked him to come, and where nobody particularly
desired his presence, that he stood up and embraced him as though
he were a lost lamb come back to the fold. Then followed the battle
of Pharsalia, and Brutus had been obliged to fly for his life. He need
not, however, have feared for his safety, for Cæsar had given the
strictest orders that nobody was to hurt him either in the battle or in
the subsequent chase of the fugitives. From Larissa, whither he had
fled, he wrote, on principle, to Cæsar, stating that he was prepared
to surrender; and the Dictator, in memory, it is said, of many a
pleasant hour with Servilia, at once pardoned him and heaped
honours upon him. Brutus, then, on principle, laid information
against Pompey, telling Cæsar whither he had fled; and thus it came
about that the Dictator arrived in Egypt on that October morning of
which we have read.
Brutus was an intellectual young man, whose writings and
orations were filled with maxims and pithy axioms. He had, however,
a certain vivacity and fire; and once when Cæsar had listened, a
trifle bewildered, to one of his vigorous speeches, the Dictator was
heard to remark, “I don’t know what this young man means, but,
whatever he means, he means it vehemently.” He believed himself to
be, and indeed was, very firm and just, and he had schooled himself
to resist flattery, ignoring all requests made to him by such means.
He was wont to declare that a man who, in mature years, could not
say “no” to his friends, must have been very badly behaved in the
flower of his youth. Cassius, who was the brother-in-law of Brutus,
deemed it very advisable to introduce this exemplary young man
into the conspiracy, and he therefore invited him, as a preliminary
measure, to be present in the Senate on the Calends of March, when
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like