In The Beginning…
Ever since the Raspberry Pi came out, I was entranced by the
coolness factor of having a small pocket sized computer that cost just north of
thirty bucks. Hats off to those devoted for making this project a reality and
launching it to the world. The only problem for me at the time of Pi launch, was
the fact that I lived in a Windows world, and to an extent, still am. I had no
rad Linux skills. No formal or informal training. I got my hands on an
installation disc of Mandrake way back in the day when I did call center tech
support. The only way to get that geek cred in that place was to show you knew
your stuff. I took that disc, spun it up in my 32x CD-ROM drive, wiped my
Windows partition (you know, cause this open source stuff comes at a college
student budget), and stepped through the install. After it was all said and
done, Windows was back as soon as it had gone. FAIL. I had similar experiences
with Red Hat and Ubuntu, but I did manage to get wireless working on the former,
but it was too much of a pain to deal with when it was so easy to make it all
work in Windows.
Flash forward to today. I’m still in my Windows world due to
the place I work, but much more comfortable with Linux and even got my LPIC-1
certification. I’ve had my Raspberry Pi which was used to study for the
aforementioned cert and has since been sitting in a lonely dark drawer next to
a twice used wicked looking webcam I got from WGU. This dark and dreary future
was not what I had envisioned for the poor Pi. There are so many cool projects
out there and one that caught my eye was from a guy who had a web server
running off a Raspberry Pi that was powered by the sun and 4AA rechargeable
batteries. How cool does that sound?! I put this on my list of things I must
do. After about a year or so I finally decided to shed some light on this
project (did you see what did there?).
Let’s Get To Work
To kick this thing off, I went back to that old project page
and got some information on power consumption of the Pi. Knowing I’m going to
run this headless, that would save on the load drawing from the battery if I
had attached some sort of touch screen. I tried to figure out the math behind
how long it would run on a full charge before shutting down and going to bed
which lead me to ask, what battery pack should I use? The original idea had AA
batteries which fit the project scope, but I wandered over to my favorite
maker’s page, adafruit.com. Searching the shop, I was happily greeted with my
power answer and a plethora of parts and/or kits for everything Raspberry Pi.
The parts I finally opted for are as follows:
· Medium Solar Panel (6V, 2W) https://www.adafruit.com/products/200
· USB / DC / Solar Lithium Ion/Polymer charger https://www.adafruit.com/products/390
· Lithium Ion Battery Pack - 3.7V 4400mAh https://www.adafruit.com/products/354
· Male DC Power adapter - 2.1mm plug to screw terminal block https://www.adafruit.com/products/369
· PowerBoost 500 Basic - 5V USB Boost @ 500mA from 1.8V+ https://www.adafruit.com/products/1903
· 2 x JST 2-pin cable http://www.adafruit.com/products/261
· Large Plastic Project Enclosure - Weatherproof with Clear Top http://www.adafruit.com/products/905
· Waterproof Metal On/Off Switch with Red LED Ring http://www.adafruit.com/products/916
PowerBoost 500 Basic with USB connector soldered on. |
USB/DC/Solar LiIon/LiPo charger with capacitor soldered on. |
Next, the battery had to have the JST cable soldered on. I left them long just in case I needed the extra length when fitting this all inside the enclosure. The last soldering to be done was to solder the two remaining JST cables together for the link between the charger and the PowerBoost. I did not show the soldering steps because if I can do it, you can too. Believe me. Finally the solar panel came with a plug that would not fit the USB charger. Easy fix was to nip the tip and add the 2.1mm plug.
That’s Great, But Does It Work?
Testing the PowerBoost 500 with the battery. |
Ok, so that’s one part down. What about the solar panel and
charger? Taking the solar panel, battery, and charger outside, I connected it
all together. Again the LEDs that indicate charging came to life! Success x 2!
It may seem pretty basic to a lot of you out there, but it’s small things like
this that amaze me. Also, keep in mind I am the son of someone who has taken
electrical engineering classes, yet still stuck his finger in a light socket to
see if the power was still on.
Putting it all together with all components working should
yield a working solar powered Raspberry Pi, right? I’m usually cynical when it
comes to situations like these and usually expect the worst, so I won’t be
disappointed when that outcomes happens. But today, things just clicked.
Moments like this put a big smile on my face. The Cynicism Demon was slayed.
Now to the next part of this project. Getting the Pi to run headless.
Prep the Pi
Since I used this Raspberry Pi to use as study for the
LPIC-1 exam, a lot of the work was already done. But that was so long ago and
it needed an update. More requirements popped up such as static IP address on
the wlan0 interface and remote desktop. I also ran into the problem of having
forgotten my user pi password since it was setup so long ago and so quickly
neglected, thrown into a locked drawer, and forgotten about. But times change, things
are brought out back into the light. Used for new purposes. First thing’s
first, get wireless working.
For the wifi adapter, I had a very tiny Wi-Fi USB adapter
from Edimax (EW-7811Un) being used in a security lab I setup earlier this year.
When I got this adapter, I envisioned using it for the Pi, so the lab will
suffer a little bit but these are so cheap on Amazon, I’ll be grabbing another
soon. Setting up Wi-Fi was a little more difficult since I didn’t have a mouse
to click on things (one USB for the Edimax and the other for a keyboard).
These are the steps I took to get Wi-Fi working on my
network:
1)
Plug in the Edimax
2)
Power on the Raspberry Pi
3)
Ctrl+Esc and run wpa-gui.
4)
Tab through to the Manage Networks tab and fill
in the blanks for SSID, Authentication, Encryption, and PSK.
5)
Tab to the Current Status tab and try to
Connect. I had to reboot my Pi before it would connect to my access point.
6)
Upon connection, you’ll see the IP address
populate on the Current Status tab.
Once I got connected to the access point and was able to
successfully ping outside of the network it was time for updates. A quick
apt-get command and everything was all set. So static IP shouldn’t be too hard,
right? I spent about thirty minutes to an hour fighting with having the wlan0
interface retaining a static IP. Here are the steps I took to resolve this:
1)
Bring up LXTerminal
2)
Type: sudo nano /etc/network/interfaces
3)
Change the line “iface wlan0 inet dhcp” to read
“iface wlan0 inet manual”
4)
Change the line “iface default inet dhcp” to
read “iface default inet static”
5)
Add these lines after the above line: “address
192.168.xxx.xxx” “netmask 255.255.255.0” and “gateway 192.168.xxx.xxx” where
xxx is your subnet and host octets.
I also checked wpa_supplicant.conf to make sure it all
looked fine (and it did) by using the following command:
Sudo
nano /etc/wpa_supplicant/wpa_supplicant.conf
This shows SSID, PSK, encryption type, etc. Basically
everything you see in wpa_gui. I changed nothing in here. Now, the above
solution is a little weird. Why not just set wlan0 to static? At first I did
and got nowhere fast. The only thing I could ping was the loopback interface
and my static IP address. Couldn’t ping the gateway IP although I did specify
it. The above solution was the only thing I could come up with and make work
after rebooting a few times to make sure it auto connects.
At this point, static IP and wireless are working. Just need
to make remote desktop work. For this project, I do not need to access the
Raspberry Pi desktop from outside of my network. For this feature you may press
your luck with Google. Also, this is for connecting from a Windows based laptop to
the Pi. I’m using xrdp for my remote desktop solution. I had already installed
this feature when studying for the LPIC-1 exam, but here are the steps to
install it:
1) Bring up LXTerminal.
2) Type: “sudo apt-get install xrdp”
3) If it asks for your password, please feed the pi the password.
4) This should begin installing your software for remote deskop, xrdp.
5) Restart the Pi. This should get the Remote Desktop Protocol server running.
6) You can verify this when the Pi boots up by finding the line: [OK] Starting Remote Desktop Protocol server : xrdp sesman. My Pi boots directly to the desktop so I have to be quick to find this line when it boots. If yours boots to command line, you’ll be able to easily find this line.
1) Bring up LXTerminal.
2) Type: “sudo apt-get install xrdp”
3) If it asks for your password, please feed the pi the password.
4) This should begin installing your software for remote deskop, xrdp.
5) Restart the Pi. This should get the Remote Desktop Protocol server running.
6) You can verify this when the Pi boots up by finding the line: [OK] Starting Remote Desktop Protocol server : xrdp sesman. My Pi boots directly to the desktop so I have to be quick to find this line when it boots. If yours boots to command line, you’ll be able to easily find this line.
Great! RDP is up and running on the Raspberry Pi! Let’s jump back to the Windows world for a second.
1) On the Windows laptop, bring up Remote Desktop Connection and enter in the static IP address we gave the Pi and hit Connect. You may get a security warning, hit OK since we know you got a nice safe Pi.
2) You’ll be presented an XRDP login prompt showing Module, Username, and Password. Leave the module defaulted to sesman-Xvnc and type in your username and password (the default username is “pi” and the default password is “raspberry”).
3) Click OK and peer through the Windows to the world of Pi.
Now, I had trouble on this part of the process because I didn’t remember the password I set for the user “pi” so long ago. There are a couple options to fix this:
1) From an LXTerminal window, use the “sudo raspi-config” command to run the starting config and change the password that way.
2) From an LXTerminal window, use the “sudo passwd” command.
I used option 1 which was quick and simple.
That’s about it for prepping the Pi. I haven’t really come up with what I want to do with the Pi. Should it be a web server, ftp server, etc.? or should it be used for a surveillance machine, like Ike created. Or should it be used for weather reports? Time will answer that question. But to finish out the build, we need to look at fitting all this stuff in a box.
What’s In the Box?!
So many drawn diagrams. So much planning. |
Next order of business was obtaining the material for the
shelves. I went to the local hardware store and got a sheet of Lexan cut to the
above dimensions. Fit perfectly in the box. Next was to place the PowerBoost
and the LiPo charger to know where to drill holes. All the places were marked
on the Lexan and the drilling began. This was my first time drilling into
polycarbonate. I read a lot on how to drill this stuff so it would not crack.
Everyone agreed to clamp the Lexan to wood and drill with a drill press. I was
not able to get my hands on a drill press, so I was careful to be as vertical
as possible with my trusty drill. Lessons learned on the test pieces of Lexan
showed that slow and steady wins the race here. On to the actual pieces. They
turned out perfect. The circuit boards were screwed in place with the nylon
screws, spacers, and nuts. As they say, measure twice, cut once. This was very
true here. So the first shelf is done, on to the second shelf. Only three holes
needed to be cut for this one: two for the bolts to hold up the shelf and one for
the capacitor on the charger.
If that last hole was not made, the Pi would not
be able to fit inside the box. Taking measurements of the capacitor, I marked
the location where that hole would be drilled. However, something occurred to
me. The capacitor is not perfectly vertical. So I made the hole, but used a
dremel to widen the area where the Lexan and the capacitor kept touching. Easy
fix, but that made the top shelf look a little janky. No one will see it since
the piece will be covered anyway.
PowerBoost, Charger, and Battery all layed out in the enclosure. |
Another step that doesn’t really need to be documented but
you’ll notice in the photos, I used a dremel to cut off the top of the bolts
that are used for supporting the Lexan shelves. This was done so I could work
with the shelves a little easier and just set them into the box instead of
putting the shelves on the bolts and screwing everything into place. I’m going
to cap them with locking nuts to prevent any sharp edges and make it look a
little more finished.
Everything at this point was looking great, but another
thing popped into my head. If I continue on with the plan I had in mind, I
would have to take the box apart to turn off the Pi. I need a power switch I
can easily have access to. Back to my layout drawing. I saw the space I needed
for a switch. Again, Adafruit.com to the rescue. I ordered the on/off switch
listed above in the parts list. This switch did not come pre-wired. This was a
good thing for me. That means I get a bonus for learning how to wire up the
switch. Again, I took measurements to get the vertical and horizontal placement
correct on the side of the box. I required a 16mm hole drilled into the side of
this box, but living in an imperial world, I wasn’t able to source a 16mm drill
bit, so I went with a 5/8” bit and milled out the extra .1mm. No big deal, and
the hole looked pretty clean.
Testing the external power button. The LED makes it look good! |
Quickly, I hooked up all the cables to the appropriate
jacks, screwed the shelves in place, and used some double sided tape to keep
the battery in place and also to keep the Pi case from being knocked around on
the top shelf. Screwed the top cover in place and voila, a solar powered
Raspberry Pi computer!
Praise the Sun!
At this point, I am feeling really good about this project. How amazing is it when you learn new skills and overcome challenges. I learned a lot in regards to planning for a project of this scale, making a soldering job look nice, how a switch is wired up, and more. I haven’t done any long term testing as to how long the Pi will run into the night when only running on battery. However, I find it amazing that this pocket computer can inspire so many people to come up with bright ideas and make them a tangible item. Some of the notable pages that helped me complete this project are as follows:
· How to make a Raspberry Pi solar-powered FTP server
· Adafruit.com
· Ike the Network Guy
· Raspberry Pi Forums
Finally, for all you Sun Bro’s out there, Praise the Sun!
No comments:
Post a Comment