1

My Pi Zero has a USB WiFi Adapter attached.

I want it to automatically connect to my home wifi network using a static IP. When I take it out and about... for walks, or whatever... I want to have it automatically connect to my iPhone hotspot.

At the moment, the Pi Zero automatically connects to my hotspot, so that's good. But, when I bring it home, it is given a random IP, rather than the Static IP I assigned it.

This is what I have so far:

In /etc/network/interfaces I have:

auto lo
iface lo inet loopback

allow-hotplug wlan0

iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface phone inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface home inet static
address 192.168.1.123
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254

and in /etc/wpa_supplicant/wpa_supplicant.conf I have:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="MY SSID"
        scan_ssid=1
        psk="MY PSK"
        id_str="home"
        priority=15
}

network={
        ssid="MY HOTSPOT NAME"
        psk="HOTSPOT PSK"
        id_str="phone"
}
  • what version of Raspbian are you running – Steve Robillard Jan 13 '16 at 20:09
  • Latest Jessica 8.0 – RPi user Jan 13 '16 at 20:11
  • 1
    Jessie (dyac!)... – RPi user Jan 13 '16 at 20:12
  • 2
  • the network settings and files have changed for Raspbian recently the short version only the ssid and psk go in the wpa_supplicant.conf file and the static details go in /rtc/dhcpcd.conf file more info can be found in my answer here. Especially the link for further info at the bottom. If that solution works let me know and I will mark this question as a dupe. – Steve Robillard Jan 13 '16 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.