After spending hours and hours getting Ubuntu to install on a Windows 8-optimized laptop (more on that later) I was having incredible problems getting the wireless to work. Honestly, I haven’t had problems with Linux and wireless since Ubuntu 8, but my 12.04 install just refused to recognize the Ralink RT5390R wireless card installed in my HP laptop. It’s an HP2000 laptop with a Ralink RT539B card.

Finally, after some serious searching, particularly in the Ubuntu forums, I got it working, with the help of some posts by users chili555 and ironv. If anyone else is having problems, here’s what solved it for me.

1. Download the driver from Ralink’s website. Assuming you also have the 539B card, download the RT539x PCIe package from

2. Unpack:

tar xvjf -filename

3. Here’s where things change. Edit ./os/linux/ file to reflect the following:


4. Now search for NIC5392_PCIe_DEVICE_ID in all directories.

grep -r -n NIC5392_PCIe_DEVICE_ID .
./include/chip/chip_id.h:60:#define NIC5392_PCIe_DEVICE_ID 0x5392
./include/chip/rt5390.h:67:#define NIC5392_PCIe_DEVICE_ID 0x5392
./os/linux/pci_main_dev.c:75: {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC5392_PCIe_DEVICE_ID)}
./os/linux/rt_rbus_pci_drv.c:1380: (device_id == NIC5392_PCIe_DEVICE_ID)
./os/linux/rt_rbus_pci_drv.c:1669: case NIC5392_PCIe_DEVICE_ID:

Now, everywhere that turns up (see the above example) you must add an additional line, directly after it and formatted exactly the same, with NIC539B in place of NIC5392. So if you do another

grep -r -n NIC539B_PCIe_DEVICE_ID .

you’ll get:

./include/chip/chip_id.h:61:#define NIC539B_PCIe_DEVICE_ID 0x539B
./include/chip/rt5390.h:68:#define NIC539B_PCIe_DEVICE_ID 0x539B
./os/linux/pci_main_dev.c:76: {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC539B_PCIe_DEVICE_ID)}
./os/linux/rt_rbus_pci_drv.c:1381: (device_id == NIC539B_PCIe_DEVICE_ID)
./os/linux/rt_rbus_pci_drv.c:1670: case NIC539B_PCIe_DEVICE_ID:

5. Once that’s done,

sudo make
sudo make install
sudo modprobe -r rt5390sta
sudo modprobe rt5390sta

Then reboot. Your wireless should now be working.

REMEMBER: this fix only works if you have the 539B device!! If you’re not sure, run

lspci -nn | grep 0280

That line should finish with “Device [1814:539b]”.

Good luck!

It’s a nifty little trick that can come in handy. In my case, I use it to notify me if my webserver suddenly becomes unavailable for some reason. It uses the fact that most cell phones can be texted via email by using a certain adress, such as The code I use:

def send_text(str):

HOST = ""

SUBJECT = "Server offline!"
TO = ""

FROM = ""

text = str
BODY = string.join(("From: %s" % FROM, "To: %s" % TO, "Subject: %s" % SUBJECT, "", text), "\r\n")

s = smtplib.SMTP('',587)




s.login("", "mypassword")

s.sendmail(FROM, [TO], BODY)


Just a quick bit of helpful info for anybody that’s looking, as I lost hours of time until I figured it out:

When you compile OpenCV code, assuming you’ve got all of the links correctly set and your $PATH configured correctly, you have to use flags, and you have to use the correct syntax, like so:

g++ `pkg-config opencv --cflags` myprog.cpp -o myprog `pkg-config opencv --libs`

Note: That’s a ` mark (above the TAB key), not an apostrophe! Apparently, that makes all the difference.