Raspberry Pi GPS tracker – Connecting Without a Network

All articles to date have been about getting the GPS working with the Raspberry Pi and converting the original Python code to PHP. All of this works well (for me) but what if you want to make changes to the settings or download the log file while you are out and about and away from your home network?

Normally what happens is that you configure your device to connect to a known network but as you are going to be using the GPS/Pi combination away from known networks you need a way to access anywhere without having to connect a screen and keyboard to the Pi. To do this you need to configure peer-to-peer networking. What this means is that you are creating a machine to machine connection without the router that would traditionally be required. This allows you to connect in any way you would over a normal network, so over http or ssh, for example.

To setup peer-to-peer networking you need to be able to connect your Pi to the internet to install the software that you will need. The rest of this post assumes that you have already done this but if not see here to connect a wireless dongle or hook up a USB Ethernet dongle.

NOTE: If you complete these steps your Pi won’t have internet access at the end over wifi. If you want to connect again you will have to change the interface back or connect over ethernet.

Install a DHCP Server

So first we have to install a DHCP server which will be used to allocate an ip address in the same range as the Pi to any device that connects to it. To do this you first need to update apt and then do the install itself:

sudo apt-get update
sudo apt-get install isc-dhcp-server

The last few lines of the DHCP install should look as follows:

Generating /etc/default/isc-dhcp-server...
Job for isc-dhcp-server.service failed. See 'systemctl status isc-dhcp-server.service' and 'journalctl -xn' for details.
invoke-rc.d: initscript isc-dhcp-server, action "start" failed.
Processing triggers for systemd (215-17+deb8u2) ...

The service has failed to start as you need to setup the config file as follows. Edit the dhcp.conf file that has been created:

sudo nano /etc/dhcp/dhcpd.conf

The file will have a lot in it already, mostly commented out, but we are going to replace it all with the following which will allocate addresses in the range .10 – .100 and .150 – .200:

default-lease-time 600;
max-lease-time 7200;
option subnet-mask;
option broadcast-address;
option routers;
option domain-name-servers,;
option domain-name "mydomain.example";

subnet netmask {

Once you save the file you should now be able to start the DHCP service successfully:

sudo service isc-dhcp-server start

Change the wifi interface

Now we need to change the interfaces file to give the Pi a static IP address in the same range as the DHCP service is serving:

sudo nano /etc/network/interfaces

If you have already setup wireless networking then you will have already made changes to this file. We are going to replace the contents of this file so it’s a good idea to take a backup first. Then replace the content with the following:

auto lo
iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet static
  wireless-channel 1
  wireless-essid RPiAdHocNetwork2
  wireless-mode ad-hoc

The value you give wireless-essid will be what is shown when you search for the network so you can change it to something more memorable if you wish.

For the changes to take effect you need to restart the network service but the easiest way to achieve this is to restart the Pi itself:

sudo reboot now

Now when you search for wireless networks you should see your Pi network appear similar to as shown below on an iPhone:

2016-02-24 19.52.21

You can select and use this exactly as you would any other network so, for example, here I have connected over SSH to my Pi and, if you have installed it, you could also access a web browser.


If you complete all the above you will be able to access your Pi no matter where you are and make changes on the fly without having to change connection details for each wifi network you want to connect to. In a later post I will show how you can use of this alongside the GPS.

Leave a Reply

Your email address will not be published. Required fields are marked *