Archive for the ‘Raspberry Pi’ Category
Our main blog is now hosted at Pihard.blogspot.com Read the rest of this entry »
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
Ok, for 3 nights I stayed up till 3am trying to figure out the insane wiring on this thing and trying to get everything correct. Finally completed it today, typed in some sample code and get ready to test it. I flip the switch, The lights come on, a good sign… Then they all go out. A couple seconds to see if anything is going to happen and…. Nothing. Damn, now I have to trouble-shoot and do more research. But wait, what is that I smell? Plastic burning? Yep I smell plastic! Now I see smoke coming from the wiring/mounting holes. The power is off so what the heck? I see more and more smoke coming from the motor compartment and can’t get to it because I tightened all the cover screws! A race to get the cover off and remove the batteries before the whole thing goes up.
The damage was limited to melting both the battery leads coating completely off and slightly melting the wires near them. The battery leads were a very thing stranded wire, so when it shorted they acted as a heating element or even a fuse and burned up, maybe saving the rest of the project!
Immediately checked the boards and they seemed to operate correctly. Then spent about 3 hours chasing the short. Everything kept coming back alright but I finally managed to trace it to the 5 mm power plug that attached directly to the arduino. Yes, it is something I Soldered and looked great. Even tested perfect when the cap was off… But when you screw the protective cap back on, the voltage meter went crazy… The short was in the plug!
Swapped it out for a new one, replaced damaged wiring and even a new battery case.
Moment of truth…. The darn thing fired right up and had even retained the test code we had programmed it with! Works as it should, runs the simple driving/avoidance software. Hopefully there will not be any future damage to the chips because of the short. But for now, it looks great.
Next step… Take a 5 hour nap! Tomorrow I. Plan to start figuring out how to connect the Raspberry Pi directly. Not so it downloads the scripts from the IDE, that’s already done.. No, we want to use the raspberry pi to run programs in Python and use the arduino to handle the physical part of the interface. The ardueno will run all the motors and sensors and the Raspberry Pi will not interrupt the sensor data and issue commands. Hopefully!
Here’s a couple photos of the charred battery box and wiring… What NOT to do. I’m going to take a nap… Enjoy!
Pi Hard With a Vengeance using WordPress for Android
First experiment with a mobile platform using the Raspberry Pi and the Arduino mega 2560. The kit comes from Sainsmart.com and is a very basic starter kit with the mega 2560, motor driver board and the sensor shield as well as most of the car parts themselves. I purchased them from Amazon.com for about $80 each. Not bad when the Mega alone sells for $60+ bucks.
We purchased 2 of them so my son and I can build them together. They have been very educational, but even more aggravating. The paperwork has to be searched out on the internet, and has been written by running another language through some translation software. Needless to say, the documents in English do not say what is intended and is very hard to decrypt. Same for the support site. The forums are updated, but it looks like the replies to customers are run through translation software. Plus user photos are missing from the forums. The last avenue of support…. They say there is a support wiki, but when I try to log from multiple links, I get the dreaded ‘forbidden access’ error message.
I am not alone here, everyone has problems with the wiring and getting help solving it… Almost nothing in Google searches as well. 4 paragraphs in the instructions does not help wire it… It really needs photos to show the connections the instructions can’t express.
The vehicle is pretty straight forward and can be done from the instructions. I have worked in hobby electronics and know that I will figure it out soon, mostly because I own test equipment and know what to look for. But for the average person entering into Arduino and robots? I would really research this kit first and understand what needs to be plugged into where, before purchasing it. Their instructions are on the web (check amazon’s product description for the link.) be sure to read the ‘coding’ section, since that has the few paragraphs on the wiring.
Overall, I am impressed with it and think it is well worth the money. Very configurable and can be expanded forever. If Sainsmart would develop their documents a little better, this could be the ideal entry level system at an incredible price! The way it is?…. I am going to learn more about computer hardware and electronics than I had planned too.
Stay tuned…. PI Hard!
Pi Hard With a Vengeance using WordPress for Android