Raspberry Pi Based Robot: Network Configuration

This is how we configure the networking in our PiWars robots. I thought I’d put this here because others might find it useful, but also because it’ll help me to remember too. Sorry if it’s a bit obvious!

The Problem

When you’re building your PiWars robot at home, it’s convenient to use the Pi’s WiFi to communicate with the robot. That’s fine. You install the OS, then set up the WiFi to communicate with your home network. This is basic, out-of-the-box stuff.

However, when you take your robot somewhere else, it can’t see your home network. This can be a problem because now you may not be able to access the RPi readily to reconfigure the networking. You might not even be able to access the Pi to close it down correctly, which can lead to all sorts of problems.

Under these circumstances it is really useful to be able to control the Pi via an ethernet cable and laptop. This is also really useful during the PiWars competition when everyone and their robot is trying to connect to the WiFi.

The Solution

The main task is to configure the RPi ethernet port with a fixed IP address ( I tend to use 10.0.0.2), before leaving home. This is done by appending the following lines to /etc/dhcpcd.conf:

interface eth0
static ip_address=10.0.0.2
nogateway

The Pi appears to use the ethernet port as the primary internet connection, then reports no internet even if the WiFi is connected to the internet. The “nogateway” command prevents this; so when at home the WiFi works as expected.

I then connect an Ethernet USB dongle to my laptop which I’ve configured with fixed IP address of 10.0.0.1 I use PuTTY and/or WinSCP, connecting to IP address 10.0.0.2 to control the Pi across the wire.

To set an IP address on a Windows (10) machine, right click the Windows logo, select “Network Connections”, select “Change adapter options”, double click the ethernet adapter, select “Properties”, select “Internet Protocol Version 4 (TCP/IPv4)”, press “Properties”, select “Use the following IP address:”. Set the “IP address” to “10.0.0.1” (or whatever you would like to use), and the “Subnet mask” to “255.0.0.0”. The other fields can be left as they are.