Wifi Strength Monitoring Robot
I was convinced the Wifi dropped off around my workspace—here’s how I built deadspottr, a robot to find those deadspots.
BUILD PROCESS
Deadspottr was built on the TurtleBot 3 Platform with custom Robotic Open Source (ROS) nodes allowing for constant signal monitoring.
Building the platform was very straight-forward and went quickly.
INSTALLATION
However, when it came time to bootload onto the OpenCR1.0 and to install the Ubuntu software onto the Raspberry Pi, some deconstruction had to be done to fully access all of the necessary ports.
After installing the necessary ROS Kinetic libraries, in your catkin workspace use the terminal to create a new package. The dependencies for this package are std_msgs for wifi-signal strength that will be published, and rospy for running python in the node.
deadspottr$ cd ~/catkin_ws/src
deadspottr$ catkin_create_pkg single_sig_test std_msgs rospy
If you’ve used ROS before, you can configure the single_sig_test on your own, by updating the Package.xml, CMAKElist.txt, and setup.py as appropriate, or you can replace the contents directly with the code I’ve written:
CODE
Let’s dive further into how this code works. The full script is on my Github for this project, and I’ll break down the important chunks below—
ROS publisher portion
In this part of the code it is important to note a few things:
- Because of the parsing that’s done in the middle of the code (omitted), you need to fill in the variable called network with the wifi-network you’re testing.
- The sigStrength() method is called when the python script is initialized. It creates a ROS node signal_strength and publishes to the signal_strength topic at a rate of .2 Hz.
Signal test portion
Using iwlist to get more detailed wireless information from a wireless interface. The signal strength data is retrieved by making a call of iwlist scan on our current network interface and wifi network and then parsing the data (omitted).
We must run this command as sudo to force a rescan each instance, otherwise the signal strength returned is from the irregularly updated cache. The 8192cu driver, does not initiate a scan if it deems itself to be “busy” with traffic, which it turns out, it always does.
To make sure that this program can continually run without needing a sudo password each rescan, we open the sudoers file to allow this command to run without needing a password:
deadspottr$ sudo visudo
Add this line to the end:
myuser ALL=(root) NOPASSWD: /sbin/iwlist wlp3s0 scan
Save the Sudoers file and the changes made to the signal_strength.py to add the current network.
DEPLOYING
To deploy our new node, we make our signal_strength.py executable, and then catkin_make (think CMake) this package:
deadspottr$ sudo chmod +x single_sig_test/src/signal_strength.py
deadspottr$ cd ~/catkin_ws
deadspottr$ catkin_make
deadspottr$ rospack profile
We now start ROS on our main host computer with:
host$ roscore
And run our single_sig_test package on deadspottr:
deadspottr$ rosrun single_sig_test signal_strength.py
RESULTS
Now that deadspottr is up and running, we simply echo the signal_strength topic that our node is publishing on our host computer to see signal strength changes as we drive deadspottr around.
host$ ros echo /signal_strength
In the test below, I drove deadspottr closer to the central router, which corresponds with the lowering negative signal strength values.
This metric, dBm may be confusing, but it stands for decibel-milliwatt. As this number gets higher (closer to zero), the signal strength improves. The typical range of values is (-30,-80), where -30 would be in a place of very fast wifi, and -80 very slow. It’s an abbreviation for the power ratio in decibels (dB) of the measured power referenced to one milliwatt (mW). It is used in radio, microwave and fiber-optical networks as a convenient measure of absolute power because of its capability to express both very large and very small values in a short form. Compare dBW, which is referenced to one watt (1000 mW).
Driving deadspottr around, I realize how much signal strength varies spatially. My work spot indeed had lower dBm numbers than many other areas, and this bot gave me concrete evidence for the location of the best signal strength.
Armed with new knowledge, I set out to write a program that maps the spatial variance of signal strength of the local area. You can follow this project as it unfolds:
Update Dec 31, 2017:
The final part of the project, the mapping is now live with a project overview available on youtube: