In this lesson, you will learn how to use the digital inputs on the GPIO connector with a door sensor and a PIR motion detector.
In this lesson, we will concentrate on sensing movement and activation of the door switch. In Lesson 13 we will build on this security sensing to have the Pi use a digital output to control the power to an electrical appliance when movement is detected.
PIR (motion) sensor – PIR sensors are used to detect motion from pets/humanoids from about 20 feet away (possibly works on zombies, not guaranteed). This one has an adjustable delay before firing (approx 0.3-18 seconds), adjustable sensitivity and we include a 1 foot (30 cm) cable with a socket so you can easily reposition the sensor or mount it using the two drills on either side. (read more)
The HR-USB-EZ sensor line provides high accuracy and high resolution ultrasonic proximity detection and ranging in air, in a package less than one cubic inch. This sensor line features 1mm resolution, target-size and operating-voltage compensation for improved accuracy, superior rejection of outside noise sources, internal speed-of-sound temperature compensation and optional external speed-of-sound temperature compensation. This ultrasonic sensor detects objects from 1mm to 5meters, senses range to objects from 30cm to 5meters, with large objects closer than 30cm typically reported as 30cm.
Resolution of 1 mm
~250mS between range readings
Maximum Range of 5000 mm (196 inches)
42kHz Ultrasonic sensor measures distance to objects
Virtually no sensor dead zone, objects closer than 30 cm range as 30 cm
Small, light weight module
Designed for easy integration into your project or product
Great starting point for users unsure of which sensor to use
NEW PRODUCT – RGB Color Sensor with IR filter – TCS34725 – Your electronics can now see in dazzling color with this lovely color light sensor. We found the best color sensor on the market, the TCS34725, which has RGB and Clear light sensing elements. An IR blocking filter, integrated on-chip and localized to the color sensing photodiodes, minimizes the IR spectral component of the incoming light and allows color measurements to be made accurately. The filter means you’ll get much truer color than most sensors, since humans don’t see IR. The sensor also has an incredible 3,800,000:1 dynamic range with adjustable integration time and gain so it is suited for use behind darkened glass.
We add supporting circuitry as well, such as a 3.3V regulator so you can power the breakout with 3-5VDC safely and level shifting for the I2C pins so they can be used with 3.3V or 5V logic. Finally, we specified a nice neutral 4150&Deg;K temperature LED with a MOSFET driver onboard to illuminate what you’re trying to sense. The LED can be easily turned on or off by any logic level output.
Connect to any microcontroller with I2C and our example code will quickly get you going with 4 channel readings. We include some example code to detect light lux and temperature that we snagged from the eval board software.
A detailed tutorial is in the works, till then, check out our Arduino library and follow our tutorial to install. Wire up the sensor by connecting VDD to 3-5VDC, Ground to common ground, SCL to I2C Clock and SDA to I2C Data on your Arduino. Restart the IDE and select the example sketch and start putting all your favorite fruit next to the sensor element!
Picture a tiny drone that arises from your vegetable garden to shoo away hungry deer. Or maybe a houseplant that, when you’re away, meanders through your rooms like a cat following a sunbeam. Or one that posts a request for water on Twitter.
The future is knocking at the door of home gardening. And, if some do-it-yourselfers have their way, there is no aspect of nature that can’t be improved with a rechargeable motor and a sensor or two.
NEW PRODUCT – Membrane 1×4 Keypad + Extras – Punch in your secret key into this numeric membrane keypad. This keypad has 4 buttons, and since every key has its own wire line, no matrix code is required – just treat these like every day switches. The membrane is soft and has a removable paper backing to expose a strong adhesive so you can stick this on an enclosure and feed the cable through a slot. It’s a simple keypad but that’s why we like it.
We include a 5-pin extra-long header strip so you can plug this into a breadboard with ease.
Keypad dimensions: 69.14mm / 2.72″ x 20.07mm / 0.79″
Length of cable + connector: 87.31mm / 3.43″ x 14.28mm / 0.56″
NEW PRODUCT – Membrane LED Keypad + extras – This membrane keypad has a single key, but it does have an embedded surface-mount red LED installed. The flex cable is also extra-long, so we can think of a lot of wearable and portable projects that would use this sort of switch and have an LED as feedback (say, to indicate that an action is occuring or the power is on). Since the keypad is soft plastic, it can be sewn with needle and thread.
The back of the pad has a removable paper cover that protects an adhesive backing. You can see how the pins correspond to the LED anode/cathode and button by looking at the photos above.
We include a 3-pin extra-long header strip so you can plug this into a breadboard with ease.
Keypad dimensions: 19.05mm / .75″ x 34.92mm / 1.37″
Length of cable + connector: 350mm / 13.77″ x 8.24mm / 0.32″
NEW PRODUCT – AM2315 – Encased I2C Temperature/Humidity Sensor. Finally we have an I2C-interface temperature & humidity sensor in a nice enclosed style. This sensor contains a DS18B20 temperature sensor and a capacitive humidity sensor. A small microcontroller inside does the readings and provides a simple I2C interface for reading the finished & calibrated output data. Especially nice is that this sensor is in a rugged case with mounting bracket, which makes it way superior to a normal PCB-mounted sensor.
While it is not rated as ‘weatherproof’, this sensor would do much better for sensing where there might be wind, rain, zombies, etc. than SHT PCB-breakout sensors, and the i2c interface makes it easier to interface with microcomputers that can’t do the delicate timing of the DHT sensors.
Simply connect the red wire to 5V power, black to ground, yellow wire to your i2c data pin, and the white wire to the i2c clock pin. You cannot change the i2c address so only one sensor per i2c bus. Two ~10Kohm pullup resistors are required for use, connect from the SDA and SCL lines to the power wire, the pullup resistors are not included!
The ADXL345 is a low-power, 3-axis MEMS accelerometer modules with both I2C and SPI interfaces. The Adafruit Breakout boards for these modules feature on-board 3.3v voltage regulation and level shifting which makes them simple to interface with 5v microcontrollers such as the Arduino.
The ADXL345 features 4 sensitivity ranges from +/- 2G to +/- 16G. And it supports output data rates ranging from 10Hz to 3200Hz.
The LSM303 breakout board combines a magnetometer/compass module with a triple-axis accelerometer to make a compact navigation subsystem. The I2C interface is compatible with both 3.3v and 5v processors and the two pins can be shared by other I2C devices. Combined with a 3-axis gyro such as the L3GD20, you have all the sensors you need for a complete IMU (Inertial Measurement Unit) for use in aerial, terrestrial or marine navigation.
In this tutorial we will show you how to connect the LSM303 to an Arduino and use it to measure orientation relative to the earth’s magnetic field, and acceleration in three axis.
Pulse Sensor Amped – Pulse Sensor Amped is a greatly improved version of the original Pulse Sensor, a plug-and-play heart-rate sensor for Arduino and Arduino compatibles. It can be used by students, artists, athletes, makers, and game & mobile developers who want to easily incorporate live heart-rate data into their projects. (read more)
Here’s a helpful video tutorial contribution from Adafruit community member David Nash. Thanks for sending this in!
This is a simple project that builds on several of your Raspberry Pi Lesson projects that I thought you might consider including in a more advanced lesson. All of the components were purchased from Adafruit. The project uses your 8×8 matrix as the display so, when the Python program is automatically invoked from bootup, it requires no monitor or keyboard to run. It uses 12C for input and output to two devices and uses one GPIO analog interface. It’s a neat project for a number of reasons not least of which is it provides a means of verifying that your programmable home thermostat is functioning properly.
NEW PRODUCT – Soil Temperature/Moisture Sensor – SHT10 – Take your gardening project to the next level with a SHT-10 based soil sensor. The sensor includes a temperature/humidity sensor module from Sensiron in a sinter metal mesh encasing. The casing is weatherproof and will keep water from seeping into the body of the sensor and damaging it, but allows air to pass through so that it can measure the humidity (moisture) of the soil. It is designed to be submersible in water, but it’s always best to avoid long-term (over 1 hour at a time) submersion, if you need something that can be submerged for over an hour you may want to find a different sensor. It can also be simply placed outside for exterior weather sensing.
Humidity readings have 4.5% precision, temperature is 0.5% precision. A microcontroller is required to interface. The sensor is not washed after reflow and is rehydrated according to datasheet requirements.
I have a problem. When I look at my brewery I think that if it is working, then it doesn’t have enough features. Certain parts of the brewing process suggest specific liquid flow rates, but without instantaneous feedback, how can anyone ever really judge if they’re doing it right? It seemed that commercial flow meters are complete garbage or are insanely expensive. Luckily, Adafruit had my back with an inexpensive flow sensor.
I slapped a couple quick disconnects on it, and replaced the screws that held it together with 3/4″ #4 brass wood screws to allow it to be mounted to a nice enclosure.
The rest of the parts were maybe $15-20, but I had them sitting around from my other projects. I need to get a 9V battery clip. Soldering wires onto a 9V battery because you’re more excited about getting it working than driving to Radio Shack is surprisingly difficult.
The PCB is custom made from OSH Park and drives the LCD, PWM backlight and contrast, and of course counts the sensor pulses. I went a slightly different way than the example sketch does it, because I found that the resolution at low flow rates was too coarse. I use Timer1 set to 62.5Khz and use the input capture interrupt to store the elapsed ticks between pulses.
The sensor works great, but is quite a bit off spec (450 pulses per liter) at flow rates less than 4 lpm. I calibrated by running hundreds of liters of water through it and creating some calibration points that I can LERP between. Flow rate accuracy now pretty tight, off by a couple percent. Careful calibration can take this sensor down below its minimum spec’ed flow rate, down to about 0.7 lpm, but the pulses-per-liter count at that rate changes dramatically.
Here’s some pictures of the device in action on the brewery, where it just snaps on to the existing pump infrastructure. Using sleep modes between pulses means the current draw is relatively low and the 9V battery should last roughly 30 hours in use….
NEW PRODUCT – Contact-less Infrared Thermopile Sensor Breakout – TMP006. Unlike all the other temperature sensors we have, this breakout has a really cool IR sensor from TI that can measure the temperature of an object without touching it! Simply point the sensor towards what you want to measure and it will detect the temperature by absorbing IR waves emitted. The embedded thermopile sensor generates a very very small voltage depending on how much IR there is, and using some math, that micro voltage can be used to calculate the temperature. It also takes the measurement over an area so it can be handy for determining the average temperature of something.
This sensor comes as a ultra-small 0.5mm pitch BGA, too hard to solder by hand. So we stuck it on an easy-to-work-with breakout board. The sensor works with 3 to 5V logic so it requires no logic level shifting. There are two address pins and using a funky method of connecting the pins you can have up to 8 TMP006′s connected to one i2c bus (see the datasheet table 1 for the connections). We also include a small piece of 0.1″ breakaway header so you can easily solder to and use this sensor on a breadboard. Two mounting holes make it easy to attach to an enclosure.
A great little sensor you can add to your Raspberry Pi projects is a PIR module. These 5V “Passive Infra Red” sensors are available for a few pounds from eBay. They can be powered from 5V and output 3V so can be connected directly to pins on the Pi’s GPIO header without any other components.
The module sets a single output pin high whenever it detects movement within its field of view. It holds this pin High (3.3V) for a minimum period of time. If continuous movement is detected the output pin will stay High. When the time has elapsed and no more movement is detected the output pin returns Low (0V).
I am currently using one in an alarm system and it works great for such a small and cheap device.
PIR (motion) sensor: PIR sensors are used to detect motion from pets/humanoids from about 20 feet away (possibly works on zombies, not guaranteed). This one has an adjustable delay before firing (approx 0.3-18 seconds), adjustable sensitivity and we include a 1 foot (30 cm) cable with a socket so you can easily reposition the sensor or mount it using the two drills on either side. (read more)