Preface

This book is all about making the invisible visible.

Each project introduces a particular environmental condition, and then teaches you step by step how to build a small, inexpensive electronic device that can monitor that condition, and communicate back what it finds.

When you start monitoring the environment, something happens: You start to understand the world around you in a new way.

Build a water quality tester, and a beautiful, clear-running stream may become a beautiful clear stream with a high particulate count (see Chapter 6).

Build a gadget to measure temperature and humidity, and you’ll see for yourself that “high noon” is not the hottest part of the day; that actually comes around 3 p.m. (see Chapter 8).

Build an electromagnetic field detector, and you’ll discover even a quiet room is buzzing with unseen, unheard electrical vibrations (see Chapter 4).

We usually turn environmental monitoring over to the scientific experts at government agencies, universities, and corporations. They come armed with complicated and expensive equipment as well as specialized educations, and occasionally their own institutional agendas.

Since the natural environment is complex, even more so for all the stuff we human beings and our activities have added to the mix, this sort of expertise has an important role in our lives and in our communities. Scientific analysis and expertise are key to creating effective regulations that control the impacts human activities have on the environment and our health.

Monitoring the environment for ourselves, however, pulls the curtain back on what all those experts are doing. Understanding brings knowledge, and with knowledge comes the power to make decisions that can change our lives for the better—from lowering the electric bill, to holding polluters accountable, to helping scientists study the changing climate.

How to Use This Book

We suggest that you build the projects that follow in the given order, since they progress from easier to more complex.  

If you already have some experience with Arduino, and want more challenges in making and using these gadgets, look for the “Things to Try” section at the end of each project chapter. We make suggestions for changing the build or the programming that will exercise your skills. We hope you’ll come up with your own ideas, too, and tell us about them.

One straightforward way to increase each project’s difficulty, once you have built and tested a gadget, is to rebuild it in a more permanent way by soldering the components together. We also offer a few general suggestions for creating enclosures—handy and rugged cases for your gadgets—at the end of this book. You can make enclosures as simply or elaborately as you choose.

Finally: We do our best to describe how to build each gadget as clearly as possible.  But as it’s almost inevitable that even a “simple” project will frustrate you now and then, here are some tips to keep things fun and interesting:

Break it down
It may be difficult to get a gadget to work correctly the first time. But don’t get discouraged! Most of these gadgets didn’t work the first time for us, either.  What we’ve found, and what we think will work for you, is to break every gadget down into separate components, typically input and output components.
Don’t skip the preliminaries
Make sure each component works individually before connecting it with others. If it’s working on its own, it will be much more likely to work when combined into a gadget. 
Save. Back up. Document.

When it comes to coding, this is our mantra:

  1. Save: Save your code frequently as you work on it.
  2. Back up:  Always back up your code to at least one location other than your hard drive, such as a peripheral drive, memory card, or flash drive.
  3. Document: As you write programming code, include comments (more on this in Chapter 2) that explain what the code does; when you look at your code several days later, you might not remember. As you build a gadget, take notes about what you discover, so that you can refer to them later.

Do these three simple things consistently, and when your computer crashes, your laptop falls out of your bag and onto the concrete, or your cat walks across the keyboard, you will be calm in the knowledge that you always have a copy of your work safely stored somewhere else.

Change only one thing at a time

If you decide to make any changes to the code or the design of these gadgets (and we heartily encourage you to do so), we suggest that you change only one thing at a time, and test it before making another change.

This is important because your change may cause the gadget to stop working.  If you’ve made only one change, it will be easy to undo it and return to a working version of the gadget.  This allows you to move ahead with confidence, because you know that any glitch is easy to fix.

Mash it up

We’ve done our best to design these gadgets in a modular fashion, so that with only a little tweaking, you can swap the the input and output components between them.  Want to modify the temperature gadget to output to Pachube rather than a display?  Go for it! The hardware should be easy to modify, and changing the code will usually be a simple matter of cutting and pasting from one gadget’s code to the next.

Granted, some swaps don’t seem to make much sense: it might be rather odd to build a thermometer with an audio output. But give it a try if you want to. Who knows what you’ll come up with? Here’s our own favorite mashup so far: If you combine the audio output of the electromagnetic field detector with the Geiger counter input, and then tweak the code just right, you can make an old-fashioned click-click-click radiation detector, just like in the movies. So mix and match! Have fun! Be bold!  

Ask for help

There is absolutely zero shame in asking for help, and there is less than zero shame in asking for help with an Arduino project.  The entire Arduino ecosystem is built on a philosophy of open access to knowledge. Some people may know more about building circuits or writing code than you know. You might know more than someone else.

But to a certain extent, no one is an expert, because no one has made Arduino do everything it can do. Whether online or face-to-face, people will be happy to help you learn if you’re respectful, gracious, and willing to share.  We guarantee that after weeks of feeling like all you ever do is ask questions, there is nothing like the thrill you’ll get the first time you’re able to help someone else solve a problem.

Here are some resources for connecting with fellow Arduino users:

Don’t be afraid to experiment

There’s more than one way to put together any device in this book.  Don’t have a 1 megaohm resistor to use in the EMF detector?  Try using a 470K resistor plus a 560K resistor instead.  They add up to a bit more than 1 megaohm, but that’s OK.

We know that there are other, perhaps even better ways to build each and every one of the gadgets shown here.  We hope you’ll find them and let us know about them.The code examples in the following chapters are available for download at GitHub at the official code repository for this book. We encourage you to monitor this repository for the latest bugfixed code, as well as extended examples by the author and the rest of the social coding community.

Get Environmental Monitoring with Arduino now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.