Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Intel Galileo Essentials

You're reading from  Intel Galileo Essentials

Product type Book
Published in Feb 2015
Publisher
ISBN-13 9781784398903
Pages 162 pages
Edition 1st Edition
Languages

Table of Contents (15) Chapters

Intel Galileo Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Getting Started with the Galileo Accessing the GPIO Pins Adding Display Functionality Controlling DC Motors Adding Sensors Remote Control Going Further with Galileo Speech Output Index

Chapter 5. Adding Sensors

In Chapter 4, Controlling DC Motors, you learned how to use the Galileo to control DC motors. In this chapter, you'll learn how to add sensors to your projects. Sensors are important because you can use them to find, or avoid, objects. You can use them to sense your direction and speed, and also temperature. You can also use them to sense acoustic and electromagnetic waves, pressure, and many other physical phenomena. One of the challenges of using the Galileo is that it uses the Linux operating system at its core, so there are challenges if a sensor needs to do real— time processing of signals with tight timing. Linux is not a real-time operating system, and might be doing other things when you need to make something specific happen. This will limit some of the sensors you can use on your project. For a complete list of sensors and other hardware that are currently supported by the Galileo, see https://communities.intel.com/docs/DOC-23423. The goal of this chapter...

Sensing distance


There are two basic sensors that will return information on the distance to an object: sonar and infrared. In the case of sonar, the sensor uses ultrasonic sound to calculate the distance to an object. The sensor consists of a transmitter and receiver, the transmitter creates a sound wave that travels out from the sensor, as illustrated here:

The device is triggered by an electronic signal to send out a sound wave. If an object is in the path of these waves, then the waves reflect off the object, sending waves that return to the sensor, as shown here:

The basic sensor then measures the received sound wave and sends out an electronic signal. The user can then calculate the time difference between when the sound wave was sent out and when it returns to measure the distance to the object. Unfortunately, the return time must be measured with precision for this type of sensor to work. This is challenging for a processor such as the Galileo, that runs Linux as the base operating...

The Infrared sensor


Now, a little tutorial on IR sensors. The sensor you are using has both a transmitter and a sensor. The transmitter transmits a narrow beam of light, and the sensor receives this beam of light. The difference in transit ends up as an angle measurement at the sensor, as shown here:

The different angles give you an indication of the distance to the object. Unfortunately, the relationship between the output of the sensor and the distance is not linear, so you'll need to do some calibration to predict the actual distance and its relationship to the output of the sensor.

The voltage to distance chart for the device looks like this:

This kind of chart will come from the sensor's date sheet. There are really two parts to the curve; the first is the distance up to about 15 centimeters, then the distance from 15 centimeters out to 150 centimeters. You can simplify the code if you ignore distances closer than 15 centimeters, and model the distance from 15 centimeters and out as a...

Connecting an IR sensor to the Galileo


The first step in connecting an IR sensor to your Galileo is to obtain a sensor. One popular choice is the Sharp series of IR sensors. The following image shows one of the models, the Sharp 2Y0A02, a unit that provides sensing to a distance of 150 cm:

To connect this unit, you'll connect the three pins that are available on the bottom of the sensor. Here is the connection list:

Galileo Pin

Sensor Pin

5V

Vcc

GND

Gnd

A3

Vo

Unfortunately, there are no labels on the unit, but here are the pins you'll connect:

One of the challenges of making this connection is that the female-to-male connection jumpers are too big to connect directly to the sensor. You'll want to order a three-wire cable with connectors with the sensor. Many versions come with this cable. You can make the connections between this cable and the Galileo using the male-to-male jumper wires. Here is the diagram:

Once the pins are connected, you are ready to access the sensor via the IDE...

Connecting a digital compass to the Galileo


One of the important pieces of information that might be useful for your project is its direction of travel. This could be given by a GPS unit, but a GPS unit can be expensive, and it often doesn't work well inside buildings. You can also just "keep track" of the direction associated with your hardware, but you'll need to carefully update this whenever your project might move. Using a compass frees you from always having to keep track, and will also allow you to avoid inaccuracies that can accumulate from inaccuracies in your control system. So, let's learn how to hook up a digital compass to the Galileo.

There are several chips that provide digital compass capability; one of the most common is the HMC5883L 3-Axis Digital Compass chip. This chip is packaged onto a module by several companies, but almost all of them result in a similar interface. Here is an image of one by a company called SainSmart, that is available at a number of online retailers...

Connecting an accelerometer or gyro to the Galileo


The ability to measure speed and tilt is important in many robotics applications. This can tell you how fast your robot is traveling, and in what direction. Fortunately, there are chips that can do this for you. One of those is the MPU-6050, which provides a complete set of information on movement, including acceleration and tilt. For more information on this type of device, see https://www.sparkfun.com/pages/accel_gyro_guide. There are several different manufacturers who place this chip on a small board accessible to the Galileo. One of these is the SparkFun version, the Sparkfun SEN-11028, available at www.sparkfun.com. It is pictured here:

The interface to the board is quite simple, with only one issue. This particular chip will require you to solder header pins to the board to connect the jumper wires to the Galileo. You can purchase these at www.sparkfun.com as well, just search for the Arduino stackable header, the 10-pin version. Or...

Connecting an altimeter/pressure sensor to the Galileo


The final sensor you'll learn about in this chapter is the altimeter/pressure sensor. The altimeter is useful when you want to know the altitude of your project. This is particularly useful when you want to build a robot that can fly. For more on pressure sensors and how they work, see http://www.sensorsmag.com/sensors/pressure/fundamentals-pressure-sensor-technology-846. First, you'll need to select a device. One device that can provide this information is the SainSmart BMP085 Module, Digital Barometric Pressure Sensor, available at many online retailers, including www.amazon.com. This device uses piezo-resistive technology to measure altitude. The following image shows this:

It looks very similar to the digital compass; just like the two previous devices, it connects via the I2C interface. You can even use the same libraries you just downloaded for the accelerometer/gyro for I2C support.

The connections between the Galileo and the device...

Summary


There are many more sensors we could have covered in this chapter, but hopefully you have a feel for how you might be able to add them after following the instructions for these sensors. Your project now has lots of possible capabilities, but you are still tethered to the computer. In the next chapter, you'll learn how to communicate with your project wirelessly so it won't need a cable to accept commands.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Intel Galileo Essentials
Published in: Feb 2015 Publisher: ISBN-13: 9781784398903
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}