Get some super powers and detect open WiFi networks around you!
Sometimes, it’s nice to feel like a Hollywood hacker and flex your superpowers! With this project, we will see how to detect if there’s a non-secure wifi around us. This is also handy when you travel and don’t have your usual places to connect to the Internet. You could be walking down the street until the GrovePi+ finds a coffee place or a restaurant that offers free WiFi. This is often referred to as ‘wardriving‘
With Great Powers Comes Great Responsibility
Knowing where there are open wifi networks is fine. Using those open networks for your own needs is most likely NOT fine, and may even be illegal. Better safe than sorry. Gain the knowledge but don’t use it unless given explicit permission by the wifi owner.
Go through the first four points at the very least.
Connect the GrovePi to the Raspberry Pi
Setup the Software
Connect your computer to the GrovePi
Update & Test the GrovePi
You may want to go through the basic examples available on the same page, just to make yourself familiar with the GrovePi+.
Step 1: Hardware Assembly
With the Raspberry Pi and GrovePi+ already assembled, the SD card and WiFi dongle in place:
plug the LED into port D3
plug the buzzer into port D2
plug the LCD screen into port I2C-1
plug the WiFi dongle into one of the USB ports (not seen in the picture)
if you have a GrovePi+ protective case, please use it, as this project is meant to be taken outside.
Step 3: Software Side of Things
If you’re running the latest Raspbian for Robots, the code for this project should already be on your SD card. You will find it in the GrovePi folder on the Desktop, then Projects, then Open_Wifi_Finder. The full path is as follows:
Note that you do not need to navigate to the Open_Wifi_Folder via the desktop interface, as the program needs to be launched from a command prompt anyway. This step is only to see if you have the code already, or if you wish to see what the code does.
Step 5: Getting WiFi Powers
Wifi detection needs another library that is not currently on your SD card. A library is a file that contains a lot of functionality, and we need one that can handle some wifi detection for us.
Start up a terminal window, and let’s get those new powers by typing the following
sudo pip install wifi
Raspbian will then pull in the appropriate piece of software for us.
Step 6: Launching our New Powers
First we need to launch a terminal. If you’re using SSH to control your Pi, you’re already using the equivalent of a terminal. If you’re using the Desktop, or VNC, then you have to double click the Terminal icon.
You then have to go to where the code is kept, by using the cd command (for change directory, the old way of saying change folder) followed by the path to the code
Capital letters are important. Pro tip: after each ‘/’, you can type the first two letters then the TAB key. Raspbian will autocomplete the name for you, if there’s no conflict.
Then launch the code by entering
sudo python wifi_finder.py
If there’s an open wifi nearby, you will be alerted promptly!
Step 7: Taking our project on the road
If we want to take our project outside where we can get the info from stores or neighbors, we have one extra step to do. After all, we don’t want to bring a screen and a keyboard to launch the software! So let’s make it that it runs right away when the Pi boots up. This way, we only need to power up the Pi/GrovePi with a cell phone charger, and everything will work on its own.
There are many approaches to making something start at boot time, but here’s one of them.
Copy the files into your home directory. That way, we will save the original files, and will simplify our paths.cp /home/pi/Desktop/GrovePi/Projects/Open_Wifi_Finder/wifi_finder.py ~/.
let’s create a start file nano start.sh
The contents of start.sh will be#!/bin/bash
sudo python /home/pi/wifi_finder.pyType Ctrl-X to exit, followed by ‘y’ and the enter key
Now we need to edit rc.local which Raspbian Wheezy uses to know which programs need to start at boot.sudo nano /etc/rc.localScroll down to the end of the file, and add the following lines right at the bottomsudo sh /home/pi/start.sh
exit 0If the exit 0 line is already there, do not add another one.
That’s it! Reboot and test!
To reboot, you can type the following in a terminal window: sudo reboot
How to get the code for this project:
The easiest way to get the code is to update your Dexter Industries software through the “DI Software Update”. When you do this, all of the code files for new projects like this will show up!
When you run the DI Software Update, this project will be automatically downloaded onto your SD card and can be found in this location:
Starting from the Desktop, navigate to GrovePi/Projects/Open_Wifi_Finder
From a command line, navigate to /home/pi/Desktop/GrovePi/Projects/Open_Wifi_Finder
You can get the file from Github, by entering the following in a Terminal window