- Outputs have negligible software overhead.
- Input device overhead is directly related to how often each one needs to be checked. A door-open sensor has to be tested every few seconds; temperature readings could be 100th as often. The photocell (below) has the highest software overhead of the devices listed: many tests .1 second apart.
Wednesday, June 26, 2013
Raspberry Pi GPIO Devices
Disclaimer: I'm a programmer, not an engineer. I've been playing with a Raspberry Pi for the last few months and have learned some things and formed opinions. What I've written below may sound like “information” but it's really just my observations and opinions. Dick Haight, 6/26/13
GPIO devices can be mostly separated as inputs (sensors) or outputs (switches). But first, a few remarks about the practical limits of the Rpi. Here's a picture for Rpi B, rev 2.
The left-most diagram shows the physical pin numbers in the center two columns and what the pins might be used for in the outer columns. The pins (3 and 5) labeled “I2C” can be used to control an I2C add-on bus which can control up to 16(?) more devices. The “SP10” pins are still a mystery, but probably work somewhat like the I2Cs. Pins 8 and 10 can be used for old-fashioned serial I/O (but why not just use USB?). “DNC” simply means “do not connect.”
The middle diagram shows using as many pins for GPIO as possible. 17 is probably enough.
The right-edge Rpi photo shows the 26-pin header plus 8 more possible GPIOs (blue loop). The green line circles the socket for the digital camera ribbon cable.
Basically, a normal mix of a dozen input sensors should be no problem for an Rpi.
Here are some Rpi input sensors that I find interesting:
Temperature/Humidity DHT22, $10
This simple device appears to provide reliable temperature/humidity readings. I also tested the more expensive waterproof thermometer (DS18B20, temp-only); $16. I need to check how long the connecting wires can be and still get accurate readings.
Rpi CPU temperature
According to Asimov's third law of robotics, “A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws.” (which involve protecting people). Therefore, each Rpi has a CPU temperature sensor built in. I read on the Internet that the Rpi can tolerate operating temperatures up to 80C. The testing software should warn (by text message?) at 70C and halt the processor at 75C.
Motion sensor $10
This sensor needs to be tested about every 4 seconds (motion detection seems to stay “hi” for 5-6 seconds. It is supposed to measure out to 25' or so. My device seems to notice movement over about a 90 degree arc. The two adjustment “pots” (green arrows, above) probably change those values.
There is a large variety of these devices. Some ultrasonic, some IR. They cost $25 and up. They typically have a narrow angle of view and a restricted maximum reading.
Digital Camera $30
I haven't looked into this yet, but it could be used as a combo motion-sensor/rangefinder. Or webcam.
Open door/window switch $4
Photocell (power fail) sensor $1
These things are intrinsically analog devices. So the software requires many timed probes (.1 second apart) to get a reading. I hope to use one of these a a cheap way of detecting power failure. Most backup UPSs have a light that goes on when the battery kicks in. Stick a photocell over that lamp and you have a power-fail sensor.
Soil moisture $10
Prices of these things are all over the place. Since the info is analog (voltage leak between the tines of the fork), programming is likely to be like the photocell.
Water level $40
Probably meant for swimming pools. different models can detect up to 12" changes. No code yet for the Rpi. It's another analog thing.
What every traveling Rpi needs. But I don't, for now.
Internet and Text-message inputs
If your Rpi is wifi to a cellphone modem (e.g., Verizon “Mifi”) then it has a phone number and can send and receive text messages – which means that you can control the Rpi from any old smartphone, etc.
Cheap, but uses a lot of GPIO pins. Why not use a USB device?
Rpi output devices:
LED character displays
Switch 110V AC devices $25
The device shown can handle up to 500W. E.g., operate a fan, etc.
Irrigation control: 8 – 16 valves $150 – 200 (rayshobby.net)
This is an ambitious device for handling up to 16 water valves. Timing can be controlled by a Google Calendar file in the “Cloud.” Such an irrigation schedule can be modified by the file's owner from anywhere. The 24V power supply ($40) and the actual valves are extra. I believe that this takes 6 of the Rpi's GPIO pins and uses the I2C extension.
Friday, June 7, 2013
My RaspBerry Pi adventures
I had yet another wifi failure with the Frontier DSL modem -- again
ethernet-connected devices continued to get Internet (including my iMac and the Pi)
iPhones and iPad indicated the wifi was available but it didn't work.
So, it looks like a Frontier problem -- not the Pi.
I need my Pi application to have Internet access. The cheapest option seems to be
by using a cellular modem (e.g.: Verizon Mifi). The best deal at the moment seems
to be a company called Karma (is it bad karma to mess with that name?). It's a
no-contract deal: buy the modem/wifi device and buy megabytes as needed.
However, its coverage doesn't work for me. Not as cheap but Datajack or Virgin no-contract
plans show good 3G where I need it. Down side: I had Verizon Mifi for a while; it wasn't
I got my motion sensor working (PIR device from Adafruit). Like some of the other
devices, it has odd personality quirks.
What I learned:
* You only have to poll the device about every 5 seconds -- the device keeps returning
"true" for 6 or more seconds after the briefest movement.
* The angle of detection seems to be a bit over 90 degrees.
* The room I'm testing in isn't big enough to tell what the maximum sensing distance
BTW: In case my text formatting looks strange on this page -- well, today blogger.com
doesn't do automatic text wrap -- so I've typed my own line returns. Strange!
Tuesday, June 4, 2013
Sunday, June 2, 2013
A possible Raspberry Pi-induced WIFI problem:
Since I started playing with my RasPi I've noticed that wifi for the whole house seems to stop working some hours after the Pi has been connected. My wifi comes from (with) a DSL modem with Frontier branded on the box. My iMac is two feet from the modem and is wired to it by ethernet cable. Everything else, iPhones, iPad and of course, the Pi used wifi. After the tenth (or so) time I had to power cycle the DSL to get wifi working again I decided to pull the USB wifi dongle out of the Pi and replace it with ethernet wire to that same modem. Guess what? 'Haven't had a wifi failure since. BTW: I had tried two different wifi dongles with the Pi.
Anyway, this is irritating. Especially since I'm planning a Pi application that depends on reliable wifi. I had two dongles to try but I lack an alternate wifi access point to experiment on. There is a lot of noise on the Web about dongle configuration problems (I had none) but nothing I've found about the Pi locking things up.