Every time you reboot your Raspberry Pi it contends on the WiFi network for a new IP ("internet protocol") address. It may get the same address as last time, it may not. There is a way to have it always get the same address, called a static IP address.
You don't need to use a static IP address (the router automatically assigns addresses when asked to, and this all works fine) but it's handy if you want to remotely connect to your robot using ssh so that you won't have to somehow find out which IP address the robot is currently using.
The idea here is to find out what address your robot is currently using, assume that address is generally available, and then set it so the robot always asks for the same address. The only downside is that if another device shows up on your network and dynamically obtains that address, your robot won't be able to connect to the network because the address is in use — every device on a network must use a unique address.
Add the following to the end of the single line of text in the file /boot/cmdline.txt:
ipv6.disable=1
This also has the advantage that you can add it from Windows/OSX before you boot the Pi, since the boot partition is readable under those operating systems. (source)
First, let's see what address it currently has. Type the ifconfig command and then hit Enter:
% ifconfigThe result will be a lot of stuff, most of which you can avoid. It comes in sections, one of which will be named wlan0 or something similar (with "wlan" meaning "wireless local area network").
In that section there's one string of characters you're looking for, what follows "inet" on the second line of that section:
The "192.168.1.74" above (four numbers separated by dots) is the IP address of the robot. Yours will likely start with the same first three "192.168.1" (this is common on local area networks at home but not always true), with the last number "74" being unique to your robot.
NOTE: this currently doesn't seem to work on a Raspberry Pi 4 due to ipv6 (?), but has worked reliably for the Raspberry Pi 3 B+.
The DHCP service must be running on your Pi. To check, try this:
sudo service dhcpcd status
If it's not running you can start it (and with the second line, set it to always start) with:
sudo service dhcpcd start sudo systemctl enable dhcpcd
Then, edit the DHCP configuration file located at /etc/dhcpcd.conf. You'll need to do this as a superuser (because you need special permissions to edit system configuration files), so use "sudo" and the "nano" editor like this:
% sudo nano /etc/dhcpcd.conf
...and add these lines at the bottom of the file (subsituting your chosen IP address for the "192.168.1.74"):
This information is derived from from pages like:
...where there's a lot more detail than here if you get stuck. If you mess things up just comment out the lines you added by putting a "#" at the beginning of those lines.