Jan 01

Bored? Stats!

Every year that you are signed up with Jetpack (with WordPress), you get a report at the end of the year with several interesting (to me) statistics about your site. Because of the various server hackings that went on in the year 2012, the last report didn’t go so well, this one however worked great! Anyway, if you are really bored and looking for something to do, check it out below! It’s all pretty and everything.

Jetpack Annual Report – 2013

Anyway, happy new year!

Dec 21

Electronics Projects: VFD Informatron 2000

After looking at various very cool and vary old display technologies on eBay, I ran across a 4 line dot matrix VFD display. It was one of 4 left, so I decided to order it and build a project similar to this one that an IRC friend linked me to: http://www.pyrofersprojects.com/blog/vfd-clock-with-snmp-and-ntp/. I originally was going to go down the similar route of a Arduino or Arduino clone and an Ethernet shield, but after looking at what the cost would be, the Raspberry Pi made a lot more sense. The Raspberry Pi itself is only $25 or $35 for the B model, and wifi module for $10. Since I didn’t have any of this equipment, I ended up getting a really nice kit from Adafruit (Click here to see it) to get started. I also purchased some discreet electronics and other parts from Newark (Element 14) to build a RasPi UART to TTL converter (You can also do this with a MAX232 chip, which I haven’t tried yet) as I thought I would need it, which turned out not to be the case with the particular VFD module I got. Keep in mind however that the RasPi is 3.3v UART, not +5 TTL. That circuit will convert the two with 4 1k resistors and 2 2N222 transistors.

Here is most of the kit after I took everything out of the box and set some of it up:


After plugging it in, it was simple enough to download the NOOBS software kit from Raspberri’s site and unzip the contents onto the microSD card through the microSD card reader that both came in the kit (tiny USB connector as seen in the picture). Sliding the card into the adapter and into the pi and turning it on brought it right up to a really nice and simple installation interface where you got to choose your OS to install. Since it seems to be the most popular and most supported, I went with the default, Raspbian.


The install took a while, but completed without any issues (sorry about the flash glare and quality of picture).

Unfortunately I totally didn’t take ANY pictures during the build. Not much was missed though. First I went straight to building the TTL conversion circuit, which promptly didn’t work. I took the “big risk” and plugged the display directly into the pi and it came to life! It was actually pretty simple. The 3 pin connector on the VFD module has +5 volt, Serial Data, and GND. All 3 pins went straight to the pi. The Serial Data pin is connected to pin 8 of the pi header which is the UART transmit, 5v got connected to pin 2, and GND to pin 6. You can probably picture it in your head, there’s no components inbetween.

After that initial success, it was just down to software; so I decided to build a case. Since I had never done this before, I was hoping to make just a simple, easy to put together case with a couple pieces of Lexan (plexiglass, etc). Thankfully my local hardware store had smaller pieces but thick enough for just under $4 each, so I got 3. Two extras just in case (and I needed them). I spent hours trying to cut and drill holes correctly. Wasted many a piece of Lexan. I ended up with this!

vfdcase_1st_attempt_front vfdcase_1st_attempt_back

As you can see I used 3 molex connectors and a piece of old ribbon cable to go between the pi and the VFD module. There was barely enough room for it all. It’s actually a little more tight than I really would want it to be. That is the “B” version of the PI, and will eventually be replaced with the cheaper and less powerful “A” version, since it’s not doing much. Then I can use the “B” for other projects.

I’m still developing the script, but here is what I have as of at the time of this writing. Before you look at it, remember that this project was the first time I had ever touched Python, so the writing is going to be laughable to you experts.

This script has a few bugs and problems. If there is no working internet connection, it hangs when updating the weather, so you have to kill it and restart the script when an internet connection is available again. This particular display module is a little strange in that it is set up as 19200 8E1, instead of the normal 9600 7N1. The script sets up the serial connection to the display, initializes a couple variables, then goes into an infinite loop. Every minute it cycles through the loop, first clearing the display, then repositioning the cursor to the top left. It then calls the function to display the time and date, and the weather. The weather function is programmed to only actually grab the current weather every hour, as to not needlessly load up the site and get the IP address banned from it requesting every minute. The script will be a continual work in progress while I continue to learn Python and add features.
This is the end result of the script in action:


The display is very blue and looks a lot better in this picture than in real life. This display is very tired as the “pixels” in real life are mostly dim, and very uneven in brightness. I believe it’s the camera flash that makes it look blue, but in reality, it’s green. See my other posts about the other parts of programming for this project for more info.



Several weeks later the project failed, and it was an important lesson type of failure. The raspberry pi ran pretty warm the whole time, but not knowing what was “normal” I didn’t think much of it, other than thinking that I should get some heatsinks on it. Well, by then it was too late. One day the display was blank. Both the pi and the display were toast. Looking at it then revealed that I was probably pulling too much amperage through the poor little pi. The lesson? Watch the power draw! In the future anything eternal outside of an LED in my projects will have it’s own power supply. Unfortunately I couldn’t breathe any life into the pi or the display. Lots to the beginners lessons of time forever.

Dec 21

Raspbian: Run a Program at Startup

There are many directions out there that don’t work on Raspbian. Specifically the “upstart” scripts, as Raspbian doesn’t come with upstart, and will mess things up greatly if you install it. Raspbian uses init.d. It’s fairly simple to get things going since a nice script was provided at the link below, mirrored here.

Create script in /etc/init.d

The following is an example based on starting up the no-ip service [/usr/local/bin/noip], but change the name of the script and the command to start and stop it and it would work for any command.

Warning – Its important you test your script first and make sure it doesn’t need a user to provide a response, press “y” or similar, because you may find it hangs the raspberry pi on boot waiting for a user (who’s not there) to do something!

Make script executable

Test starting the program

Test stopping the program

Register script to be run at start-up
To register your script to be run at start-up and shutdown, run the following command:

Note – The header at the start is to make the script LSB compliant and provides details about the start up script and you should only need to change the name. If you want to know more about creating LSB scripts for managing services, see http://wiki.debian.org/LSBInitScripts

If you ever want to remove the script from start-up, run the following command:

Credit: Big huge thanks to: http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html. The words above are his.

Big note from me:
In my case I needed my script to wait for the network to become available, so I modified the script to say:

For more variables you could use, see: https://wiki.debian.org/LSBInitScripts

Dec 21

Raspbian: Wifi Going to Sleep

It seemed like I couldn’t contact my Pi after a while (and my SSH session would end seemingly for no reason). I would start a ping and it would time out for the first few times before it would start responding. At first I thought the Pi itself was, or the USB ports were going to sleep, but the Pi has no power saving functions. I finally came across the answer. In my case it was the USB wifi adapter itself that was going to “sleep” or low power mode. This works with Realtek 8192cu chipset (very common).

First, see if this is the cause:

If it can’t find the file, you aren’t using the module, and your wifi probably uses a different chip.
If it’s 0, power management is disabled.
If it’s 1, power management is enabled.

To disable power management, create a new file:

Put the following in:

Save, exit, and then reboot. All done.
Credit: http://raspberrypi.stackexchange.com/questions/1384/how-do-i-disable-suspend-mode

Dec 21

Python: Parsing Online XML The Easy Way

On my Raspberry Pi VFD project, I needed a way to download the XML feed from weather.gov to display the weather. After hours of searching Google and trying different things, I finally came across a way that actually works, using lxml and urllib2. I am still very new at Python, so I don’t completely understand it yet. Here is the code I used that works for me, hopefully will work for you too:

Of course, this just returns the temperature in Fahrenheit. If you look at the xml itself you can see that the section I was interested in was “temp_f” under “current_observation”. Another interesting Python trick is “temp[:-2]“. This removes the right 2 characters from the string, changing 37.6 to 37. I also later made a variable for weather which returns things like “overcast”. That line looks like weather = doc.xpath("//current_observation/weather")[0].text. Hopefully this much simpler example than what I could find on Google will make things a little clearer for everyone.

To use this, make sure you install lxml:

Note: I lost the URL to the code I ended up using, so I can’t give proper credit, sorry!

Oct 12

Ubuntu Server 13: Nagios 4

Installing Nagios on Ubuntu (or any Debian) isn’t smooth or easy; and the instructions that are on Nagios’s site don’t work. Through much trial and error and Googling I have finally managed to get a good installation working. I had the same issues with Nagios 3.5, and while there are older packages you can install from apt-get, they seem to be broken, or set up in some weird way I can’t fathom. I prefer to install from scratch as much as possible, both for compiling to my environment and for learning. This should probably still work on Ubuntu Server 12.x and Nagios 3.5 also.

Note: As usual I use vim (vi type editor, but easier to use), and in this case we are going to make ourselves root since there are so many commands, using sudo over and over again will be too much work. I also recommend starting from a fresh but completely updated box.

Here we go! Do the following commands:

If everything goes ok and there are no config errors, continue on:

Now, the init script that comes with Nagios does not work in Debian. It was made for RedHat/CentOS. Someone kindly uploaded an older script for Nagios that does work for Debian. Do the following to replace the broken script easily:

First, delete the old file:

Then, make a new file:

and paste the contents below:

Save and exit.
Note: If you are in VIM through ssh/putty, you can just right-click and it pastes in perfectly.

Next, make the file executable:

Finally, start the Nagios service and restart Apache2:

At this point you will have seen another error when apache2 restarts. See this post to fix the Apache2 Fully Qualified Name Error.

Now, you should be able to go to your machine in a web browser. Go to http://yourmachineipornamehere/nagios.

Optional but recommended:
If you would like the service to start up automatically on boot (which is recommended), just add it to rc.d:

Sep 21

Ubuntu Server 12+: Changing to Static IP

Whenever you make an Ubuntu Server box, it’s standard to make it a static IP. There are many other pages out there that say different things on how to do this, but most of them miss the whole DNS part of it, or they have you go through extra steps that aren’t necessary anymore.

First, edit /etc/network/interfaces:



Then, add the following lines:

Here is an example of a completed static entry:

Save and exit. Finally, restart the interface:

That’s it! You can test by pinging Google/Yahoo/etc. The command ifconfig will show you the current configuration of network interfaces.

Jul 28

SLAYRadio Widget

I decided to make a SLAYRadio widget on my site a while back, because well, the station is awesome and more people should listen! Anyway, I finally got around to making it. I was originally going to go with a custom WordPress widget, but I couldn’t quite put 2 and 2 together to make it work, so I got lazy and used a PHP plugin and just made some PHP code instead. Simples!

So, to make the widget:
1. Install a plug-in that lets you use PHP code in a custom text widget. I used: PHP Text Widget
2. Copy and paste the code I came up with for the actual stuffs: Code can be had here!
There are a couple “YOUR_PATH_HERE”‘s to change to where the images are stored on your server (Don’t hot link me bro!).
3. Download the 2 images I totally stole from slayradio.org (Sorry Slaygon!) and bozretro.com (Sorry Boz!). I will probably use different ones soon since they don’t fit this theme well. Anyway:
SLAYRadio Logo
Live Animation
Stick the images up on the server, fix the path to them in the code, put the code in the text widget, and enjoy!

Jun 30

Linux Mint 15: Software Manager (mintinstall) Hangs

I have run across an issue where Software Manager hangs at the spash screen after asking for a password. This seems to only happen if it had been previously closed abnormally. The fix that seems to work for me was:

Open a terminal and run:

There should be a line that lists “splash.py” like below:

The first number is the process ID (PID). Use the “kill” command to end it:

This should close the spash screen. Now we will need to clean up the program a little bit. Run the following commands:

I ran the clean option just as an opportunity to clean up the cache while I was at it, it is purely optional. Now, re-run it as you normally would through the menu and it should start up. There still will be a little bit of a pause at the splash screen.

Jun 30

Linux Mint 15: Installing Virtual Box 4.2

This is pretty similar to my other post, Linux Mint 14: Installing Virtual Box 4.2, but with a slightly updated version of Virtual Box. It also stands to reason that this process should also work in Mint 14 if you haven’t upgraded.

1. First head to virtualbox.org Downloads and download the latest copy. Make sure you choose “Ubuntu 13.04 (“Raring Ringtail”)”. Download the i386 version if you are not running the x64 version of Linux (which unless you have 8 year old hardware I would strongly recommend converting to 64bit to utilize the full capabilities of your machine, especially when it comes to running virtual machines). Otherwise get the AMD64 version (yes, even if you have an Intel machine like I do). Then go back one page to the main downloads and find the line that says “VirtualBox 4.2.14 Oracle VM VirtualBox Extension Pack” and click the “All supported platforms” link.

2. I personally like to install software in terminal so I can see what is going on if there are any issues. Open a terminal window and change directories to where you downloaded both files. Usually in your Downloads directory. cd ~/Downloads will get you there quickly.

3. It seems Linux Mint 15 comes with DKMS already installed so this can be skipped, otherwise you should run:

4. Run the following to install it:

Don’t forget, the TAB key auto-completes the file name!

Note: I had previously updated my kernel and headers, so if you get errors during the install and it complains about kernel modules, run sudo apt-get dist-upgrade to get you to the latest and greatest kernel and kernel headers. Reboot and try the install again.

5. VirtualBox needs your user added to the virtualbox group that the installer created for certain functions like USB to work correctly. Use the following command:

6. Log out of all sessions and log back in for the the group addition to take effect on your user.

7. There should be a new icon in the menu under System Tools if you are running Cinnamon (I don’t know about the other flavors). Open it from there and it should start. Go to File, Preferences, Extensions. Click the “Add Package” button and browse to where the second file was saved.
That’s it! Assuming there were no errors you should be ready for virtual machine heaven.

Older posts «