Make: Sensors

Book description

Make: Sensors is the definitive introduction and guide to the sometimes-tricky world of using sensors to monitor the physical world. With dozens of projects and experiments for you to build, this book shows you how to build sensor projects with both Arduino and Raspberry Pi. Use Arduino when you need a low-power, low-complexity brain for your sensor, and choose Raspberry Pi when you need to perform additional processing using the Linux operating system running on that device.You'll learn about touch sensors, light sensors, accelerometers, gyroscopes, magnetic sensors, as well as temperature, humidity, and gas sensors.

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. It’s About Your Ideas
    2. How to Read This Book
    3. Input, Processing, Output
    4. Protocols
    5. Building Things Your Way
    6. Buying Components
    7. Conventions Used in This Book
    8. Using Code Examples
    9. Safari® Books Online
    10. How to Contact Us
    11. Acknowledgments
  2. 1. Raspberry Pi
    1. Raspberry Pi from Zero to First Boot
      1. Extract NOOBS*.zip
      2. Connect Cables
      3. Boot and Install Raspbian
      4. Troubleshooting Your Raspberry Pi Installation
    2. Feeling at Home in Linux
      1. Command-Line Interface is Everywhere, Forever
      2. Looking Around
      3. Text Files for Configuration
      4. sudo Make Me a Sandwich
    3. Connecting Electronics to Raspberry Pi Pins
      1. Hello GPIO, Blink an LED
      2. Building the Circuit
      3. Two Numbering Systems: Purpose and Location
      4. Controlling GPIO Pins from the CLI
      5. Writing to Files Without an Editor
      6. Light Up the LED
      7. Troubleshooting
    4. GPIO Without Root
      1. Troubleshooting GPIO
    5. GPIO in Python
      1. Hello Python
        1. Python GPIO
        2. Troubleshooting
      2. What’s Next?
  3. 2. Arduino
    1. Basic Arduino Setup
      1. Ubuntu Linux
      2. Windows 7 and Windows 8
      3. OS X
      4. Hello World
      5. Anatomy of an Arduino Program
      6. Shields Make It Easy and Robust
  4. 3. Distance
    1. Experiment: Measure Distance with Ultrasonic Sound (PING)
      1. Ping Code and Connections for Arduino
      2. Ping Code and Connections for Raspberry Pi
    2. HC-SR04 Ultrasonic Sensor
      1. HC-SR04 Code and Connection for Arduino
      2. HC-SR04 Code and Connections for Raspberry Pi
      3. Echo Calculations Explained
      4. Environment Experiment: Invisible Objects
    3. Experiment: Detect Obstacles With Infrared (IR Distance Sensor)
      1. IR Switch Code and Connections for Arduino
      2. IR Switch Code and Connections for Raspberry Pi
    4. Environment Experiment: How to See Infrared
    5. Experiment: Follow Movement with Infrared (IR Compound Eye)
      1. Compound Eye Code and Connection for Arduino
      2. Compound Eye Code and Connections for Raspberry Pi
      3. Installing SpiDev
      4. Alternative Circuits for Raspberry Pi
    6. Test Project: Posture Alarm (Arduino)
      1. What You’ll Learn
      2. Piezo Beeper
      3. Alarm, Alarm!
      4. Combining Piezo and IR Sensor
      5. Putting Everything in a Neat Package
  5. 4. Smoke and Gas
    1. Experiment: Detect Smoke (Analog Gas Sensor)
      1. MQ-2 Code and Connection for Arduino
      2. MQ-2 Code and Connection for Raspberry Pi
      3. Environment Experiment: Smoke Goes Up
      4. Experiment: Breathalyzer (Alcohol Sensor MQ-303A)
      5. Environment Experiment: Try It Without Drinking
    2. Test Project: Emailing Smoke Alarm
      1. What You’ll Learn
      2. Python for Email and Social Media
      3. Building It
      4. How Does Email Work?
      5. Could Arduino Send Email? Not Easily
      6. Code for Raspberry Pi
      7. Packaging
  6. 5. Touch
    1. Experiment: Button
      1. Pull-Up Resistor
      2. Code and Connection for Arduino
      3. Code and Connection for Raspberry Pi
    2. Experiment: Microswitch
      1. Microswitch Code and Connection for Arduino
      2. Microswitch Code and Connection for Raspberry Pi
    3. Experiment: Potentiometer (Variable Resistor, Pot)
      1. Potentiometer Code and Connection for Arduino
      2. Potentiometer Code and Connection for Raspberry Pi
    4. Experiment: Sense Touch Without Touch (Capacitive Touch Sensor QT113)
      1. QT113 Code and Connection for Arduino
      2. QT113 Code and Connection for Raspberry Pi
    5. Environment Experiment: Sensing Touch Through Wood
    6. Experiment: Feel the Pressure (FlexiForce)
      1. FlexiForce Code and Connection for Arduino
      2. FlexiForce Code and Connection for Raspberry Pi
    7. Experiment: Build Your Own Touch Sensor
      1. Capsense Code and Connection for Raspberry Pi
    8. Test Project: Haunted Ringing Bell
      1. What You’ll Learn
      2. Servo Motors
        1. Finding Servo Range
      3. Haunted Bell Code and Connection for Arduino
      4. Attaching Servo to Ringing Bell
  7. 6. Movement
    1. Experiment: Which Way Is Up? (Tilt Ball Switch)
      1. Tilt Sensor Code and Connection for Arduino
      2. Tilt Sensor Code and Connection for Raspberry Pi
    2. Experiment: Good Vibes with Interrupt (Digital Vibration Sensor)
      1. Vibration Code and Connection for Arduino
      2. Vibration Code and Connection for Raspberry Pi
    3. Experiment: Turn the Knob
      1. Rotary Encoder Code and Connection for Arduino
      2. Rotary Encoder Code and Connection for Raspberry Pi
    4. Experiment: Thumb Joystick (Analog Two-Axis Thumb Joystick)
      1. Joystick Code and Connection for Arduino
      2. Joystick Code and Connection for Raspberry Pi
    5. Environment Experiment: Salvage Parts from an Xbox Controller
    6. Experiment: Burglar Alarm! (Passive Infrared Sensor)
      1. Burglar Alarm Code and Connection for Arduino
      2. Burglar Alarm Code and Connection for Raspberry Pi
      3. Environment Experiment: Cheating an Alarm
    7. Test Project: Pong
      1. What You’ll Learn
      2. Pong Packaging Tips
      3. Automatically Start Your Game When Raspberry Pi Boots
      4. Run Game on Login
      5. Automatic Login
  8. 7. Light
    1. Experiment: Detecting Flame (Flame Sensor)
      1. Flame Sensor Code and Connection for Arduino
      2. Flame Sensor Code and Connection for Raspberry Pi
    2. Environment Experiment: Flame Precision
    3. Experiment: See the Light (Photoresistor, LDR)
      1. LDR Code and Connection for Arduino
      2. LDR Code and Connection for Raspberry Pi
    4. Environment Experiment: One Direction
    5. Experiment: Follow the Line
      1. Line Sensor Code and Connection for Arduino
      2. Line Sensor Code and Connection for Raspberry Pi
    6. Environment Experiment: Black is White
    7. Experiment: All the Colors of the ’Bow
      1. Color Sensor Code and Connection for Arduino
      2. Color Sensor Code and Connection for Raspberry Pi
    8. Test Project: Chameleon Dome
      1. What You’ll Learn
      2. RGB LED
        1. Finding the Leads of an RGB LED
        2. RGB Code and Connection for Arduino
        3. Moving Average
        4. RGB LED Shows Any Color
      3. Easing Input to Output
      4. Combining Codes
      5. Dome Building Tips
  9. 8. Acceleration
    1. Acceleration vs. Angular Velocity
    2. Experiment: Accelerate with MX2125
      1. Decoding MX2125 Pulse Length
      2. Accelerometer Code and Connection for Arduino
      3. Accelerometer Code and Connection for Raspberry Pi
    3. Experiment: Accelerometer and Gyro Together
      1. MPU 6050 Code and Connection for Arduino
      2. MPU 6050 Code and Connection for Raspberry Pi
        1. SMBus and I2C Without Root
      3. Hexadecimal, Binary, and Other Numbering Systems
      4. Bitwise Operations
        1. Bit Masking with Bitwise AND &
        2. Bitwise OR |
        3. Bit Shifting <<
        4. Endianness—Typically on the Small Side
    4. Experiment: Hacking Wii Nunchuk (with I2C)
      1. Nunchuk Code and Connection for Arduino
      2. Nunchuk Code and Connection for Raspberry Pi
    5. Test Project: Robot Hand Controlled by Wii Nunchuk
      1. What You’ll Learn
      2. Adding Hand Mechanics
  10. 9. Identity
    1. Keypad
      1. Keypad Code and Connection for Arduino
      2. Keypad Code and Connection for Raspberry Pi
    2. Environment Experiment: Revealing Fingerprints
    3. Fingerprint Scanner GT-511C3
      1. Fingerprint Sensor Code and Connection for Arduino Mega
      2. Fingerprint Sensor Code and Connection for Raspberry Pi
    4. RFID with ELB149C5M Electronic Brick
      1. RFID Code and Connection for Arduino Mega
      2. RFID Code and Connection for Raspberry Pi
    5. Test Project: Ancient Chest from the Future
      1. What You’ll Learn
      2. Operating the Chest
      3. The Box
      4. Ancient Chest Code and Connection for Arduino
    6. Who or What Is It?
  11. 10. Electricity and Magnetism
    1. Experiment: Voltage and Current
      1. AttoPilot Code and Connection for Arduino
      2. AttoPilot Code and Connection for Raspberry Pi
    2. Experiment: Is It Magnetic?
      1. Hall Effect Sensor Code and Connection for Arduino
      2. Hall Effect Sensor Code and Connection for Raspberry Pi
    3. Experiment: Magnetic North with LSM303 Compass-Accelerometer
      1. Calibrate Your Module
      2. LSM303 Code and Connection for Arduino
      3. LSM303 Code and Connection for Raspberry Pi
      4. LSM303 Protocol
      5. Compass Heading Calculation
    4. Experiment: Hall Switch
      1. Hall Switch Code and Connection for Arduino
      2. Hall Switch Code and Connection for Raspberry Pi
    5. Test Project: Solar Cell Web Monitor
      1. What You’ll Learn
      2. Connecting Solar Cells
      3. Turn Raspberry Pi into Web Server
      4. Finding Your IP Address
      5. Making Your Home Page on Raspberry Pi
      6. Solar Panel Monitor Code and Connection for Raspberry Pi
      7. Timed Tasks with Cron
    6. What’s Next?
  12. 11. Sound
    1. Experiment: Hearing Voices/Volume Level
      1. Microphone Breakout Code and Connection for Arduino
      2. Microphone Breakout Code and Connection for Raspberry Pi
    2. Environment Experiment: Can You Hear a Pin Drop?
    3. Test Project: Visualize Sound over HDMI
      1. What You’ll Learn
      2. Enabling the Serial Port in Raspberry Pi
      3. Visualizer Code and Connection for Raspberry Pi
      4. Fast Fourier Transformation
    4. What Next?
  13. 12. Weather and Climate
    1. Experiment: Is It Hot in Here?
      1. LM35 Code and Connection for Arduino
      2. LM35 Code and Connection for Raspberry Pi
    2. Environment Experiment: Changing Temperature
    3. Experiment: Is It Humid in Here?
      1. How Humid Is Your Breath?
      2. DHT11 Code and Connection for Arduino
      3. DHT11 Code and Connection for Raspberry Pi
      4. Talking to Arduino from Raspberry Pi
    4. Atmospheric Pressure GY65
      1. GY65 Code and Connection for Arduino
      2. Using Arduino Libraries
      3. GY65 Arduino Library Explained
      4. GY65 Code and Connection for Raspberry Pi
    5. Experiment: Does Your Plant Need Watering? (Build a Soil Humidity Sensor)
      1. Soil Sensor Code and Connection for Arduino
      2. Soil Sensor Code and Connection for Raspberry Pi
    6. Test Project: E-paper Weather Forecast
      1. What You’ll Learn
      2. Weather Forecast Code and Connection for Arduino
    7. Environment Experiment: Look Ma, No Power Supply
    8. Storing Images in Header Files
      1. BMP to C Conversion Program
    9. Enclosure Tips
  14. A. Raspberry Pi Linux Quick Reference
  15. Index
  16. About the Authors
  17. Colophon
  18. Copyright

Product information

  • Title: Make: Sensors
  • Author(s): Tero Karvinen, Kimmo Karvinen, Ville Valtokari
  • Release date: May 2014
  • Publisher(s): Make: Community
  • ISBN: 9781449368104