1

I have 2 raspberry, one 4 and one Zero W. The second one is headless and I use it via ssh from my laptop using my home wifi network.

My goal is to emit the wifi via hotspot on my laptop (ubuntu 18.04) and the Zero will connect to this hotspot in priority when it is present.

To do so I have messed up with the wpa_supplicant.conf file and added priority for both my home network and my laptop wifi. This was done on both of my pi, so I can see what happen in the screen of the pi4.

When I set the laptop wifi up (using this tuto), the pi4 change it's network accordingly to the wpa.conf file. I can ssh to it from my laptop because they share the wifi connection. But I can't ping my headless piZero from both devices.

If I force my pi4 on the home network, it can ssh to the piZero, so it's still on the home network...

I don't understand why the pi Zero won't change the wifi network...did I miss something ?

The wpa_supplicant.conf file in question.

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

network={
        ssid="laptop"
        scan_ssid=1
        psk="pass123"
        priority=100
        key_mgmt=WPA-PSK
}

network={
        ssid="Gowa"
        psk="pass123"
        priority=99
        key_mgmt=WPA-PSK

}

Both devices where rebooted after modification of this file. They also work smoothly on my home network.

EDIT : When I boot the raspberry pi zero while the laptop wifi is up, it connect to it. When I close the laptop wifi, the pi-zero connect to the home network. But when I open the laptop wifi a second time, only the pi-4 reconnect to it, while the pi-zero stay on the home wifi...

Second EDIT : runned on my pi-4

pi@Gowapi:~ $ sudo iwlist wlan0 scan
wlan0     Scan completed :
          Cell 01 - Address: mac address
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=70/70  Signal level=-29 dBm  
                    Encryption key:on
                    ESSID:"Gowa"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s
                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
                              36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000000000000000
                    Extra: Last beacon: 10ms ago
                    IE: Unknown: 0004476F7761
                    IE: Unknown: 010482848B96
                    IE: Unknown: 030101
                    IE: Unknown: 0509000200000000000000
                    IE: Unknown: 2A0100
                    IE: Unknown: 32080C1218243048606C
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: 2D1A2C0103FF00000000000000000000000000000000000000000000
                    IE: Unknown: 3D1601000000000200000000000000000000000000000000
                    IE: Unknown: DD180050F2020101810003A4000027A4000042435E0062322F00
          Cell 02 - Address: mac adress
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=70/70  Signal level=-24 dBm  
                    Encryption key:on
                    ESSID:"laptop"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=0000000000000000
                    Extra: Last beacon: 10ms ago
                    IE: Unknown: 00084E617574696C7573
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 030101
                    IE: Unknown: 2A0104
                    IE: Unknown: 32043048606C
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : CCMP TKIP
                        Authentication Suites (1) : PSK
                    IE: WPA Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : CCMP TKIP
                        Authentication Suites (1) : PSK
                    IE: Unknown: 3B025100
                    IE: Unknown: 2D1AEC091BFFFF000000000000000000000100000000000000000000
                    IE: Unknown: 3D1601000400000000000000000000000000000000000000
                    IE: Unknown: 7F080400000000000040
                    IE: Unknown: DD180050F2020101000003A4000027A4000042435D0062322E00
                    IE: Unknown: DD5C0050F204104A0001101044000102103B00010310470010172F5E43BF825C38936C268A78A8014D102100012010230001201024000120104200012010540008000000000000000010110001201008000231481049000600372A000120
  • You have provided virtually no detail - what does sudo iwlist wlan0 scan show? – Milliways Apr 6 at 0:09
  • is the wifi access point in the laptop 2.4GHz? See, the pi4 can do 2.4GHz or 5GHz - any pi other than the 4 or 3+ can only do 2.4GHz – Jaromanda X Apr 6 at 3:50
  • The wifi access point in 2.412GHz...There is no differences between doing sudo iwlist wlan0 scan on both pi. – Gowachin Apr 6 at 9:52
  • I have found a sort of solution with this link raspberrypi.stackexchange.com/questions/81812/… where I can ssh to my pi zero with my pi 4, and connect it to the laptop with wpa_cli -i wlan0 select_network #. But I thought there was a solution where the pi connect automatically to the prioritised and strongest network...does this exist ? (It doesn't seem to work anymore with the pi 4...don't understand why) – Gowachin Apr 6 at 9:57
  • The 'auto selection' of network only work for the pi-4 when I add scan_ssid=1...which won't work with the pi-zero... – Gowachin Apr 6 at 10:12
1

Try adding an id_str to each network section.

ctrl_interface=DIR=/var/run/wpa_supplicant 

GROUP=netdev
    update_config=1
    country=UK

network={
        ssid="laptop"
        id_str="laptopwifi"
        psk="pass123"
        priority=100
        key_mgmt=WPA-PSK
    }

network={
        ssid="home"
        id_str="home WiFi"
        psk="pass123"
        priority=99
        key_mgmt=WPA-PSK

}

Details of the file can be found here BUT it’s basically a text file.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.