Archive for the ‘hardware’ Category
The past few weeks while installing my Raspberry Pi and Gertboard, configuring and testing other people’s software…I have been sitting on an idea for my first project. On one of my run’s to Radio Shack, I found a Parallax Passive Infrared (PIR) Sensor for only $5. Unknown if it would even work with my system (voltage and sensor type), I picked it up with this single idea in mind.
The idea was to have the PIR sensor detect me as I come into the room and turn off the Raspberry Pi’s Energy Saving Screen Blanking. Well I dived right in and taught myself enough Python to get the sensor up and working (yes, the Parallax Rev. B PIR Sensor will work at 3.3v. (or 5 off the board as well)). I even managed to get the HDMI to engage and Disengage the power saving Screen Blanking. But it is a hardware issue that requires the screen to be redrawn to put the desktop back on the monitor. Something that most people think isn’t possible right now on the RPi (I have a few ideas on that though…). But even if I did get it working through TVService calls, it would not be feasible for the average user to try it out because it would have to be configured to each and every HDMI’s individual settings.
Well, my solution for now, is to run the xscreensaver service and let the PIR handle shutting down the screen-saver when I approach the computer. Not exactly what I was looking for, but still a fun and useful first project. I am going to share it with anyone who would like to try it. Shouldn’t need a Gertboard. It only needs one GPIO pin for the PIR’s signal line. I chose 25, but it can be any unused gpio io pin. Then a 3v3 or 5v pin for the PIR “+” lead, and a ground for the PIR’s “-”
lead. Real simple, that’s the hardware except for the placement of the sensor, but that will be a personal choice for each person. Last thing about this hardware, the Parallax PIR sensor has a high and low setting. This is to adjust the range to between 15 to 30 feet. The sensor is ideal for the PI/Gertboard since it can run on 3-6 volts. It runs great on 3.3v.Now onto the code. Written in python. My first attempt after just learning about it a couple weeks ago. So please be kind in your critiques. It should run on everyone’s Raspbian system the way it is. One thing that will be required to run it “as is” is the xscreensaver configured and running on your X desktop. If you haven’t installed it yet, you can get it with the simple shell command:
sudo apt-get install xscreensaver
(or use the synaptic or aptitude package installers…). After configured and tested. Then all you need to do is run code from a terminal using the command:
sudo python pir_test.py
It will give you a notice that you have 30 seconds to leave the PIR sensor area and then your screen will turn on your selected screen-saver. Walk into the area and as soon as the PIR sensor detects you, the program deactivates your screensaver, resets the gpio port and exits back to your desktop. Sweet, simple and all done in a few lines of code.
I really urge you to enter the code by hand and try to understand what each line is doing. The downloaded Python Code is FILLED with comments. My comments aren’t at all necessary. They are just to help you understand what is going on in the code. It is also not the only way to do the exact same thing. I have found a couple different ways to do each thing in the code, This is just the way I put it together. It is usable as it is, but not practical if you have to activate it every time you leave your computer. It would take a few more line to make it check to see if anyone is at the computer and have it activate if no one is around for 10 minutes. Not too hard to get it running when you desktop starts and have it loop so it runs continuously and resets itself when turning off the screen saver. These are a few of the next steps I am going to take with it. I would love to see others take this tutorial and make something useful out of it. If you do, please let me know!
Here’s The Code: pir_test.py
First I would like to mention a site for anyone new to linux. http://cli.learncodethehardway.org/book/
I consider myself a newbie although I ran a multi-line Dial-up BBS (1200Bps!) on DOS back in the late 80’s early 90’s and used a linux shell account to import Internet e-mail and Usenet newsgroups for my users. Now that I am starting with the Pi, I have to learn the basics all over again. Anyhow this site is a really quick read, just over an hour and I think I am up to speed with the basic shell commands again. Someone with no experience with CLI might take a bit longer, but it is a free site and very informative. I Absolutely recommend it to the beginner. (I am now using the sister site for Python learnpythonthehardway.org/book/..looks like it will take a bit longer to complete, but just as “easy going”!)
Now for what I have been doing the past few days with the Raspberry Pi. I have fully installed the Gertboard and all of the related software. It has taken a lot of research and hunting since the software and details of the complete setup are in several different sites. I read and did ALL of the sample projects in the user manual. (Python Samples, not the “C”. I also got both the RPi.GPIO and the WiringPi for Python versions working so I could try all the examples!)
Not knowing Unix very well, was quite a learning experience. The hardest part was actually getting the ATmega up and running properly with the Arduino IDE. Not at all like installing an arduino ATMega (USB) or Read the rest of this entry »
Just received my new Raspberry Pi and the Gertboard! So here’s a picture of the new case with both installed. Works way better than I could ever imagine!
One thing that makes me nervous is working on the RPI and Arduino with all the circuits exposed. Well I had some acrylic plastic sitting around for the past few year and I had a spare 30 minutes this afternoon, so I cranked out a protyping platform/protective case. The boards will mount inside so they are secure. All 4 sides are open so I can run wires in and out with no problems. On the very top I think I am going to mount the solderless breadboard. The top cover comes off by removing the 4 top nuts. Maybe make it even easier by using wing-nuts or even barrel-nuts if I can find them. The whole thing measures 8×9 inches and the opening is a generous 2″ inches. Enough room for the raspberry pi, an Arduino mega 2560 and a relay board or motor controller.. Can even stack my pi face or Gert board. If there is any interest, I took a lot of photos and could make an instructable with all the details. Really easy and a quick afternoon project that looks great. So if you would like to learn more, leave me a comment and let me know! Pi Hard With a Vengeance using WordPress for Android
When it rains, it poors! For the first week, I have been chasing a bug on the Raspberry Pi. Where keystrokes from the USB keyboard are missing or are duplicated continouesly. This bug is caused by low or no power on your USB hub. Since I have a 2 amp powered hub, I have tried changing devices looking for something that was shorted or power hungry that could be causing it. The problem was intermittent, so I would have to wait for it to occur to try and solve it. Today it happened, so I replaced the keyboard (yet again) and started wiggling wires. I pulled too hard and yanked it from its case while the sd card was installed. The Raspberry Pi came out of the case ripping the Sd card mounts clips off. It will no longer hold an sd card. Without an sd card it would not boot!
Found a quick fix. Took a micro sd to sd card adapter, a little bit of epoxy and permanently mounted it in place. Put my sd card image on a new micro sd card, inserted it and it booted right up! Wonderful, but nothing attached to the hub would start. No keyboard, no mouse or wifi.. Nothing! Checked the power and it was fine, but even the LED would not come on. Tried it on a other computer. Nothing. Ended up buying another one. Started right up!
Used it for a couple hours and not a single problem, not even the low USB power bug! My Raspberry Pi is working better than it did before, bug is gone, sd card works the same as it did before. True it is a smaller card (same 16 gigs), but it plugs into an adapter that is that used to hold the actual sd card.
Well that is part of the good news… Before I found the solution for both hardware problems, I had a moment of pure frustration and had given up for that split second. I feared it lost and ordered a second one. So in a few days it will be double the ‘fun’ when I receive a second raspberry pi.
I really am enjoying this little wonder !
Pi Hard With a Vengeance using WordPress for Android