The first article in this series, Intro to Common Sensors You’ll Use in Your Projects introduces temperature sensors and some common mechanical sensors.
It also promises that the next article will cover acoustic sensors and optical sensors.
I like to keep my word, so that is exactly what we’re going to do in this post.
Let’s jump right in…
More Common Types of Sensors
When we think of sensors, many of us forget about the good old microphone. Perhaps it’s because they’ve been around forever. Or maybe its because they’re so pervasive in everyday life.
Who among us hasn’t used some sort of microphone?
When you talk into a phone — be it landline or cellular — you’re using a microphone. When you give a speech, you’re using a microphone. If you’re able to receive calls through your vehicle’s audio system, you’re using a microphone. You get the idea. They’re everywhere.
A microphone converts variations in sound pressure into an electrical signal. The amplitude of this signal is proportional to the intensity, or volume, of the sound and the frequency is proportional to the frequency of the sound.
If your project involves detecting and/or reacting to any sounds, you’ll need a microphone, so they’re important sensors.
There are three common types of mics.
If you’ve ever given a speech or had to talk to a group of people in a large room, you probably used a dynamic microphone. They’re the big ones you hold in your hand or perhaps place on a stand. In most cases, you likely won’t be using this type of microphone in your projects unless your project has something to do with hi-fi music/voice recording or public address systems, so we won’t say anything more about them here.
Condenser microphones consist of a pair of plates with a charge on them, like a capacitor. In fact, the word condenser is an old, archaic term for capacitor.
One of the plates is free to move as sound pressure varies making it vibrate back and forth. If you use one of these, you’ll likely need some way to amplify the signal. On the upside, condenser mics offer crisp, low-noise sound and often find their way into high quality recording applications.
The third and final microphone we’ll touch on is the one you’ll probably use in your projects. The electret microphone is kind of like the condenser mic. This type of microphone uses a piece of plastic with a permanent charge (this is the electret) in parallel with a metal back plate. Many of them have some amplification built into them. Their performance isn’t as great as condenser mics, but for most projects involving sound detection they’ll suffice.
On a final note, you’ll often find electret mics on breakout boards for use with Arduino, RPi, and other boards.
Figure 1: a typical electret microphone.
Figure 2: electret mic on a breakout board.
Ultrasonic Distance Sensors
What hobby-level robot builder doesn’t love the ultrasonic (a.k.a. ping) sensor?
I sure don’t know of any.
In fact, these sensors are so pervasive in hobby robotics that the robot kit I recently reviewed came with only 2 sensors, and one of them was an ultrasonic sensor.
Ultrasonic sensors also find use in medical equipment, cameras, and other applications. However, the ones on the machine providing you with pictures of your unborn baby are a little different (and higher quality) than the ones most hobbyists use. Figure 3 depicts the robot from my review with the ubiquitous sensor on the front.
Figure 3: the ultrasonic sensor sits at the front of the ‘bot, peering at you like two eyes that only see sound.
First, let’s talk about what ultrasonic actually means.
The official frequency range of human hearing spans only from 20 Hz to 20 kHz, though most of us are more like 50 Hz to about 14 kHz. The definition of ultrasonic is quite loose and anything above 20 kHz is an ultrasonic “sound,” even “sounds” with frequencies in the gigahertz range. I put the word “sound” in quotes because even though ultrasonic waves are pressure waves just like sound waves, humans can’t hear any frequencies above 20 kHz. So, if a tree falls in the woods and no one is there does it make a sound or is it ultrasonic…?
Cheap humor aside, these devices send out a pulse of ultrasonic waves and time how long it takes for the reflection of the sound to come back. A calculation involving the speed of sound determines the distance to the object. But there are some caveats to this which we’ll touch on in a sec.
Most of the ultrasonic sensors you’ll use have a range of about 15 ft (5 m), but this range depends on the size and the sound reflecting properties of the object in the path of the waves. Figure 4 shows the basic concept of how these sensors work.
Figure 4: basic working principle of an ultrasonic sensor.
The speed of sound also varies according to temperature, humidity and other factors. For example, the speed of sound in dry air at 32 degrees F (0 degrees C) is about 740 mph (331 m/sec), but if we raise the temperature to 77 degrees F (25 C) this increases to 774 mph (346 m/sec). It may not sound like a lot but depending on your application it may make a difference. And if you’re building any kind of watercraft, beware – sound travels a lot faster in water than air.
Finally, some ultrasonic sensors come as one sensor rather than two – they are able to both send and receive the reflections. Figure 5 depicts the SparkFun SEN-00639 which is such a sensor.
Figure 5: the SparkFun SEN-00639 ultrasonic sensor.
There are two modes of operation through which optical sensors work. These are thermal effects and quantum effects. Thus, optical sensors usually belong to one of two classes: quantum sensors or thermal sensors.
Light is a type of radiation and its interaction with matter results in energy absorption. This energy makes the motion of atoms increase which causes things to heat up. It is possible to measure this heat and translate it into a measurement of radiation, like the amount of light hitting the sensor. Also, by raising the temperature of a material its electrons gain energy and can be released.
The other mode of operation relies on the quantum effects of radiation.
One cannot talk about photons without talking about quantum physics.
The term quantum physics strikes fear in the hearts of most mortals, bringing thoughts of teleportation, aliens (remember the original Men in Black movie where Will Smith shoots the girl with the quantum physics book during training?), Einstein, Stephen Hawking and super-complex theories and math.
Although quantum physics is a fascinating subject that I wish I knew more about, you can relax as the stuff we’re going to talk about is pretty basic and easy to understand.
So, we can leave the teleportation stuff to the aliens and super-smart physicists…
Often, when a semiconductor is exposed to photons of light, the electrons absorb the photons which increases their energy. This increase in energy can cause the electrons to become mobile and start moving. This causes an increase in the conductivity of the material and an increase in current through it. We can then use this current and/or its effects to measure the intensity of the light (and also other types of radiation).
Light Dependent Resistors (a.k.a. Photoresistors)
Like all electromagnetic radiation, light has a dual nature. In other words, there are two ways to look at it. We can treat light as an electromagnetic wave or as a particle or photon. There seems to be a time and a place for both views.
Photoresistors are quite common and cheap. If you’re making something involving the detection of light, a photoresistor (or light dependent resistor) may be useful to you.
They’re based on the photoconductive effect which basically means that electrons absorb photons of light, gain energy, and start moving, as one of the previous paragraphs explains.
Photoresistors are light-controlled variable resistors. Their resistance in the dark is usually very high, but when light shines upon them it drops. The more intense the light, the more the resistance drops.
Most of the photoresistors you’ll encounter are cadmium sulfide (CdS) resistors though cadmium selenide (CdSe) resistors may also cross your workbench. Those used for detecting infrared (IR) are usually made from lead sulfide (PbS). And yes, I know you can’t see infrared radiation, but for this purpose we’re going to lump it in with visible light.
Figure 6 depicts a typical photoresistor. Some things to note are that they may require a few milliseconds to fully respond to changes in light intensity and also a few milliseconds to return to their dark resistance.
Figure 6: a typical light dependent resistor or LDR, also known as a photoresistor.
Also, the sensitivity and range of resistance may vary widely from one device to the next.
Finally, certain photoresistors may respond better to photons of a certain wavelength than other photons. For example, CdS light dependent resistors respond better to shorter wavelengths like violet whereas the CdSe version responds best to longer wavelengths like red. However, both will have some response to visible light. For your reference, figure 7 shows the visible portion of the electromagnetic spectrum.
Figure 7: the electromagnetic spectrum with a close up of the visible light portion. Longer wavelengths are on the right while shorter ones are on the left.
Passive Infrared Sensors
Passive infrared sensors are also called PIR sensors for short.
They contain two basic parts: an absorption section which converts radiation into heat and a temperature sensor that converts the heat into an electrical signal.
A metal with good heat conductivity usually makes up the absorber, and, on higher quality sensors, gold is often the metal of choice. The metal is usually blackened to increase absorption. The absorber itself is small, so it can heat and cool faster.
A metal can with a hermetic seal houses the sensor which improves immunity to noise, humidity, etc.
Most of the PIR sensors you’ll use are of the pyroelectric type. The pyroelectric effect is heat flow through the body of a crystal generating electric charge. This charge is proportional to the change in temperature.
Figure 8 shows a typical PIR sensor you might use with an Arduino.
Figure 8: a PIR sensor on a breakout board. The plastic dome on top is a special type of lens (actually, an array of Fresnel lenses) that helps focus the IR radiation on the sensor.
Figure 9 shows the sensor without the plastic lens.
Figure 9: this is what the PIR sensor itself looks like without the lens cover.
One common application of these sensors is motion detection and indeed they find a home in many alarm systems and motion detector lights.
The basic gist of how this works follows.
For detecting motion of people (and sometimes animals) the change in temperature of infrared radiation causes a change in the voltage across the sensor. This can then activate a switch or alarm.
Many sensors are dual – that is they are like two sensors in one. One serves as a reference so that when there is no motion from any warm bodied creature they both see the same amount of IR radiation. This prevents false triggering. So, the two halves cancel each other out until one half sees more or less IR radiation than the other.
To illustrate, pretend an intruder comes along. The first sensor “sees” the IR radiation from the warm body triggering a voltage difference across the pair as the intruder moves, creating a pulse. This is used to activate whatever mechanism we choose. For clarification, feast your eyes upon figure 10.
Figure 10: Sensors A and B are dual sensors built into the complete PIR motion sensor package. When a person approaches, sensor A picks up the IR heat and pulses while B remains idle (it’s serves as a reference to increase accuracy, if one half sees more or less IR radiation than the other, the output will swing. If they both see the same amount nothing happens). As the intruder moves away from sensor A the pulse goes negative. This is what creates the pulse you see at the bottom which can trigger a light, alarm, etc.
So now we know some basics about optical and acoustic sensors. From the first article in this series, we also know about temperature sensors and mechanical sensors. There are many other more obscure sensors of these types that find their way into commercial, industrial, and military applications but the purpose here is to cover the most common ones hobbyists are likely to use.
One type of sensor that you may use which we haven’t covered yet is the gas sensor. These can and do show up in projects, so I may get into them in another post.
Meanwhile, leave a comment and tell me what sensors you’d like to see me write about. Or just say hi and tell me about your latest project involving sensors.