The Remote Debugginator (2015)

The Remote Debugginator is a device created for the Acacia Irrigation Project to enable remote access to a LAN network over 3g.

We have three irrigation sites serving about 20 farmers’ fields. Each of these sites has a Raspberry Pi collecting data on sunlight, temperature, power consumption, and pump usage.

While working on the the project we encountered a lot of difficulty debugging and collecting data from our irrigation sites remotely.

Collecting data takes a lot of effort. Typically we drive to our sites from Louga (where we are staying) which takes about 45 minutes each way. It’s not an easy drive, especially after the rainy season in Senegal.

The road is extremely sandy and frequently littered with deep potholes where the asphalt has collapsed into the soil.

This is where the Remote Debugginator becomes useful. All we need is to have a farmer turn the device on near the irrigation system and we’re good to go.

Setting up 3g

To connect to 3g, we’ll need to install Sakis3g. I’ve left out the steps because getting Sakis working really depends on your modem and cell provider. It’s a good idea to try Sakis3g first in interactive mode.

After that, install UMTSKeeper to automatically reconnect in the event of a connection failure.

Create a file named 3g.sh in your home folder. You’ll need to modify the sakisoperators to fit your configuration.

Reverse tunnel setup (server)

First, you’ll need to set up a linux server. I used a $5 / month instance at Digital Ocean.

On your server, add this to /etc/ssh/sshd_config so that the connection times out after 3 x 60 seconds of unresponsiveness.

ClientAliveInterval 60

Next, generate an SSH key on the Pi by following the guide here. Then copy the Pi’s public key to ~/.ssh/authorized_keys on the DigitalOcean server. This will let the Pi login to the server without a password.

Reverse tunnel setup (Pi)

Back to the Pi. Add the follow to ~/.ssh/config so that the client exits after error (usually it will hang) and disconnects after 3 x 60 seconds of unresponsiveness.

ExitOnForwardFailure yes
ServerAliveInterval 60

Test out the reverse tunnel by running this command on the Pi. You’ll want to replace the IP address with the address of your own server.

ssh -R 22222:localhost:22 ubuntu@159.203.95.60

If this works, you can log into your server (using a separate terminal) and connect to the Pi via this command:

Create a file named tunnel.sh in your home folder. This script waits for the 3g interface to go live before starting the reverse tunnel. It’ll also restart the tunnel in the case of an unclean disconnect.