Tom Igoe Make: PROJECTS Making Things Talk Practical Methods for Connecting Physical Objects PROJECTS AND IDEAS TO CREATE TALKING OBJECTS FROM ANYTHING Hardware/General y(7IA5J6*PLKPLK( +,!?!;!;!} US $29.99 CAN $35.99 ISBN–10: 0-596-51051-9 ISBN–13: 978-0-596-51051-0 Microcontrollers, personal computers, and web servers talking to each other. This book is perfect for people with little technical training but a lot of interest. Maybe you’re a science teacher who wants to show students how to monitor weather conditions at several locations at once, or a sculptor who wants to stage a room of choreographed mechanical sculptures. Whether you need to plug some sensors in your home to the Internet or create a device that can interact wirelessly with other creations, Making Things Talk explains exactly what you need. You will: » Make your pet’s bed send you email. » Make your own game controllers that communicate over a network. » Use ZigBee, Bluetooth, Infrared, and plain old radio to transmit sensor data wirelessly. » Work with three easy-to-program, open source environments: Arduino/Wiring, Processing, and PHP. » Write programs to send data across the Internet based on physical activity in your home, office, or backyard. Tom Igoe teaches courses in physical computing and networking at the Interactive Telecommunications Program in the Tisch School of the Arts at New York University. In his teaching and research, he explores ways to allow digital technologies to sense and respond to a wider range of human physical expression. He co-authored Physical Computing: Sensing and Controlling the Physical World with Computers with Dan O’Sullivan, which has been adopted by numerous digital art and design schools around the world. He is a contributor to MAKE magazine and a collaborator on the Arduino open source micro- controller project. He hopes someday to work with monkeys, as well. Through twenty-six simple projects, Making Things Talk shows how to get your creations to talk with one another by forming networks of smart devices that carry on conversations with you and your environment. Here are just a few of the projects: Blink Your very first program. Monski pong Control a video game with a fluffy pink monkey. Networked Air Quality Meter Download and display the latest report for your city. XBee Toxic Sensor Use ZigBee, sensors, and a cymbal monkey to warn of toxic vapors. Bluetooth GPS Build a battery-powered GPS that reports its location over Bluetooth. RFID Reader Bowl Turn your lights off when you leave the home or office. Building electronic projects that interact with the physical world is good fun. But when devices that you’ve built start to talk to each other, things really start to get interesting. Making Things Talk demonstrates that once you figure out how objects communicate — whether they’re microcontroller-powered devices, email programs, or networked databases — you can get them to interact. www.oreilly.com Making Things Talk Make: PROJECTS Make: PROJECTS Tom Igoe Making Things Talk
14
Embed
Make: PROJECTS Making Things Talk Making · Make: PROJECTS Making Things Talk Practical Methods for Connecting Physical Objects PROJECTS AND IDEAS TO CREATE ... rangers like the Sharp
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Tom Igoe
Make: PROJECTS
MakingThings Talk
PracticalMethods forConnecting
Physical Objects
PROJECTSAND IDEAS TO CREATE
TALKINGOBJECTS FROM
ANYTHING
Hardware/General
y(7IA5J6*PLKPLK( +,!?!;!;!} US $29.99 CAN $35.99ISBN–10: 0-596-51051-9ISBN–13: 978-0-596-51051-0
Microcontrollers, personal computers, and web servers talking to each other.
This book is perfect for people with little technical
training but a lot of interest. Maybe you’re a science
teacher who wants to show students how to
monitor weather conditions at several locations at
once, or a sculptor who wants to stage a room of
choreographed mechanical sculptures.
Whether you need to plug some sensors in your home
to the Internet or create a device that can interact
wirelessly with other creations, Making Things Talk
explains exactly what you need.
You will:
» Make your pet’s bed send you email.
» Make your own game controllers that communicate over a network.
» Use ZigBee, Bluetooth, Infrared, and plain old radio to transmit sensor data wirelessly.
» Work with three easy-to-program, open source environments: Arduino/Wiring, Processing, and PHP.
» Write programs to send data across the Internet based on physical activity in your home, offi ce, or backyard.
Tom Igoe teaches courses in physical computing and networking at the Interactive Telecommunications Program in the Tisch School of the Arts at New York University. In his teaching and research, he explores ways to allow digital technologies to sense and respond to a wider range of human physical expression. He co-authored Physical Computing: Sensing and Controlling the Physical World with Computers with Dan O’Sullivan, which has been adopted by numerous digital art and design schools around the world. He is a contributorto MAKE magazine and a collaborator on the Arduino open source micro-controller project. He hopes someday to work with monkeys, as well.
Through twenty-six simple projects, Making Things Talk shows how to get your creations to talk with one another by forming networks of smart devices that carry on conversations with you and your environment. Here are just a few of the projects:
Blink Your very fi rst program.
Monski pongControl a video game with a fl uffy pink monkey.
Networked Air Quality MeterDownload and display the latest report for your city.
XBee Toxic Sensor Use ZigBee, sensors, and a cymbal monkey to warn of toxic vapors.
Bluetooth GPSBuild a battery-powered GPS that reports its location over Bluetooth.
RFID Reader BowlTurn your lights off when you leave the home or offi ce.
Building electronic projects that interact with the physical world is good fun. But when devices that you’ve built start to talk to each other, things really start to get interesting. Making Things Talk demonstrates that once you fi gure out how objects communicate — whether they’re microcontroller-powered devices, email programs, or networked databases — you can get them to interact.
www.oreilly.com
Making Things TalkMake: PROJECTS M
ake: PRO
JECTS
Tom Igoe
Making Things Talk
This excerpt is protected by copyright law. It is your
responsibility to obtain permissions necessary for any
Determining DistanceElectronic locating systems like GPS, mobile phone location, and sonar seem magical at first, because there’s no visible evidence as to how they work. When you break the job down into its components, it becomes relatively straightforward. Most physical location systems are based on the same principle. They determine distance from several known and fixed locations by measuring the energy of an electromagnetic or acoustic wave coming from the object to be located. Then they combine those measurements to determine a position in two or three dimensions.
For example, a GPS receiver determines its position on the surface of the planet by measuring the strength of received radio signals from several geosynchronous satel-lites. Similarly, mobile phone location systems measure the signal strength of the phone at several cell towers. Sonar and infrared ranging sensors work by sending out an acoustic signal (sonar) or an infrared signal (IR rangers) and measuring the strength of that signal when it’s reflected off the target.
Distance ranging techniques can be classified as active or passive. In active systems, the target has a radio, light, or acoustic source on it, and the receiver just listens for the signal from the target. In passive systems, the
target doesn’t have to have any technology on board. The receiver emits a signal, and the signal bounces off the target. Mobile phone location is active, because it relies on the phone sending out a radio signal. Sonar and infrared ranging are passive, because the sensor has to emit a signal in order to measure the reflection. GPS is an active locating technology, because although the receiver doesn’t emit a signal, it has an electronic receiver onboard to receive satellites’ signals.
Sometimes distance ranging is used for acquiring a position, and other times it’s used for refining it. In the following examples, the passive distance rangers deliver a measurement of physical distance, but the radio ranging tell you only when another radio is in transmission range of your radio, and whether it’s near or far within the range.
Passive Distance RangingUltrasonic rangers like the Devantech SRF02 and infrared rangers like the Sharp GP2D12, shown in Figure 8-1, are examples of distance rangers. The Devantech sensor sends an ultrasonic signal out and listens for an echo; it’s basically a sonar device. The Sharp sensor sends out an infrared light beam, and senses the reflection of that beam. These sensors only work in a short range. The Sharp sensor can read about 10 cm to 80 cm, and the Devantech sensor reads from about 15 cm to 6.4 m; these are useful only for very local measurements. Passive sensors like these are handy, though, when you want to measure the distance of a person in a limited space, and you don’t want to have to put any hardware on the person. They’re also handy when you’re building moving objects that need to know their proximity to other objects in the same space as they move.
Figure 8-1Devantech SRF02 and Sharp GP2D12 sensors. The Devantech sensor can read a range from 15 cm to 6 m. The Sharp sensor can read a range from 10 cm to 80cm.
Figure 8-2The Sharp GP2D12 IR ranger attached to a microcontroller. The capacitor attached to the body of the sensor smoothes out fluctuations due to the sensor’s current load.
The Devantech SRFxx ultrasonic sensors measure distance using a similar method to the Sharp sensors, but have a greater sensing range. They send an ultrasonic signal out and wait for the echo to return, and measure the distance based on the time required for the echo to return. These sensors require 5V power, and return their results via an I2C synchronous serial protocol. The SRF02 sensors and other SRFxx sensors like the SRF08 and SRF10, which use the same protocol, are available from the sites www.acroname.com and robot-electronics.co.uk. The MaxBotix EZ1 and LV-EZ1 (available from www.sparkfun.com) are ultrasonic rangers that are similar to the Devantech ones, but that use TTL serial, pulsewidth output, or analog voltage output instead of I2C.
MATERIALS
1 solderless breadboard such as Digi-Keypart number 438-1045-ND, or Jameco partnumber 206011 Arduino module or other microcontroller1 Devantech SRF02 ultrasonic rangerAcroname Robotics part number R287-SRF021 100µF capacitor SparkFun part numberCOM-00096, or Digi-Key part number P10195-ND
»
»»
»
Ultrasonic Distance Ranger ExampleI2C is comparable to RS-232 or USB, in that it doesn’t define the application — just the way that data is sent. Every I2C device uses two wires to send and receive data: a serial clock pin, called the SCL pin, that the microcon-troller pulses at a regular interval, and a serial data pin, called the SDA pin, over which data is transmitted. For each serial clock pulse, a bit of data is sent or received. When the clock changes from low to high (known as the rising edge of the clock), a bit of data is transferred from the microcontroller to the I2C device. When the clock changes from high to low (known as the falling edge of the clock), a bit of data is transferred from the I2C device to the microcontroller.
The Arduino module uses analog pin 4 as the SDA pin, and analog pin 5 as the SCL pin. Figure 8-3 shows the SRF02 sensor connected to an Arduino.
Distance rangers have a limited conical field of sensitiv-ity, so they’re not great for determining location over a large two-dimensional area. The Devantech SRF02 sensor, for example, has a cone-shaped field of sensitivity that’s about 55 degrees wide and 6 meters from the sensor to the edge of the range. In order to use it to cover a room, you’d need to use several of them and get creative about how you arrange them. Figure 8-4 shows one way to cover a 4m x 4m space using five of the SRF02 rangers. In this case, you’d need to make sure that no two of the sensors were operating at the same instant, because their signals would interfere with each other. The sensors would have to be activated one after another in sequence. Because each one takes up to 36 milliseconds to return a result, you’d need up to 180 milliseconds to make a complete scan of the space.
Figure 8-3SRF02 ultrasonic sensor connected to an an Arduino Mini 04 module. Female headers have been soldered to the Arduino Mini’s analog 4-7 holes to make them easier to use.
Sensor
» Bottom right
Figure 8-4Measuring distance in two dimen-sions using ultrasonic distance rangers. The square in each drawing is a 4m ! 4m floor plan of a room. In order to cover the whole of a rectangular space, you need several sensors placed around the side of the room.
Active Distance RangingThe ultrasonic and infrared rangers in the
preceding sections are passive distance sensing systems. Mobile phones and the Global Positioning System measure longer distances by using ranging as well. These systems include a radio beacon (the cell tower or GPS satellite) and a radio receiver (the phone or GPS receiver). The receiver determines its distance from the beacon based on the received signal from the beacon. These systems can measure much greater distances, on an urban or global scale. The disadvantage of active distance ranging is that you must have both a sending device and receiving device. You can’t measure a person’s distance from somewhere using active distance ranging unless you attach a receiver to the person.
GPS and cellular location systems don’t actually give you the distance from their radio beacons, just the relative signal strength of the radio signal. Bluetooth, 802.15.4,
ZigBee, and Wi-Fi radios all provide data about signal strength as well. In order to relate this to distance, you need to be able to calculate that distance as a function of signal strength. The main function of a GPS receiver is to calculate distances to the GPS satellites based on signal strength and determine a position using those distances. The other radio systems mentioned here don’t do those calculations for you.
In many applications, though, you don’t need to know the distance — you just need to know how relatively near or far one person or object is to another. For example, if you’re making a pet door lock that opens in response to the pet, you could imagine a Bluetooth beacon on the pet’s collar, and a receiver on the door lock. When the signal strength from the pet’s collar is strong enough, the door lock opens. In this case, and in others like it, there’s no need to know the actual distance.X
Active distance ranging
Initial signal generated by base unit(e.g. cell tower)
Response signal generated by mobile unit (e.g. cell phone).
Passive distance ranging
Base unit (sensor) sends outsignal, reads reflection from