Raspberry Pi 3B (2) - configure multiple wifi, automatically find available networks

1. Background

In the previous article " Raspberry Pi 3B Installation System and Networking ", the Raspberry Pi uses wifi to connect, but when the Raspberry Pi is brought to the company, the Raspberry Pi cannot connect to the company's wifi. It would be nice if it supports multiple wifi connections. Here to organize and share with you.

2. Steps

1. Turn on the hotspot on the mobile phone and connect the Raspberry Pi to the Internet

2. Log in with the root account and edit wpa_supplicant.conf

wpa_supplicant.conf is the configuration file of the linux wireless network management software wpa_supplicant, which records the configuration of the wireless network.

vim /etc/wpa_supplicant/wpa_supplicant.conf

The content of the file is as follows:

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    ssid="Honor 10"
    psk="zyj123#.."
} 

Where ssid is the wifi name and psk is the wifi password

3. Increase the wifi configuration

Add the network node, and the content of the file after adding is as follows:

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    ssid="Honor 10"
    psk="zyj123#.."
    priority=5
}
network={
    ssid="company"
    psk="companyPwd"
    priority=4
}

The priority is the priority, and the larger the value, the higher the priority.

4. Test

1) Test the Raspberry Pi to connect to the available wifi. Turn off the hotspot, unplug it, plug it back in, and the test is successful.

2) Test disconnection and reconnection. Simulate the company's wifi, change the mobile hotspot name and password to the same as the company's, and the Raspberry Pi is disconnected from the network and reconnected, and the test is successful.

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324860665&siteId=291194637