himkiet
Posts: 30
Joined: Sat May 14, 2016 9:14 am

Automatic switching between wifi network

Thu Dec 29, 2016 10:32 am

I am using a raspberry pi.I want to automatically switch between two wifi networks if one network got unavailable But in my raspberry pi i have to enter wifi key again to connect to another network.Is there any way my pi remembers wifi key and switch automatically between different wifi network when one is unavailable

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Automatic switching between wifi network

Thu Dec 29, 2016 10:40 am

They go in /etc/wpa_supplicant/wpa_supplicant.conf and are remembered so automatic connection to a network in range is possible.

Code: Select all

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

network={
        ssid="WiFiSSIDforNetworkNumber1goeshere"
        priority=60
        psk="passwordforonehere"
}
network={
        ssid="WiFiSSIDforNetworkNumber2goeshere"
        priority=80 
        psk="otherpasswordgoeshere"
}
the priority works that higher number connects first if both are in range.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

himkiet
Posts: 30
Joined: Sat May 14, 2016 9:14 am

Re: Automatic switching between wifi network

Fri Dec 30, 2016 3:39 pm

this works fine.. but I want to switch my wifi network to another network if one network doesn't receive data, I current case pi switch to the different network if one network is unavailable. I am working on a vehicle tracking system, my network doesn't receive data in certain areas, so i want my pi to switch to the different network and start transmitting data(whether another network present or not).

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Automatic switching between wifi network

Fri Dec 30, 2016 10:48 pm

Do a ping, when the ping fails rewrite the supplicant file and restart the wpa_supplicant task.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

AGID
Posts: 36
Joined: Tue Mar 17, 2020 1:02 pm

Re: Automatic switching between wifi network

Sat Jun 27, 2020 6:22 pm

DougieLawson wrote:
Fri Dec 30, 2016 10:48 pm
Do a ping, when the ping fails rewrite the supplicant file and restart the wpa_supplicant task.
@DougieLawson is this still the best way to get connected to wifi with internet connection until now (Buster release)?

Also, Does priority works with buster as well?


epoch1970
Posts: 5022
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Automatic switching between wifi network

Sun Jun 28, 2020 1:07 pm

Try "man wpa_supplicant" and see what "wpa_cli -a myscript" can do for you.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

AGID
Posts: 36
Joined: Tue Mar 17, 2020 1:02 pm

Re: Automatic switching between wifi network

Sun Jun 28, 2020 2:10 pm

epoch1970 wrote:
Sun Jun 28, 2020 1:07 pm
Try "man wpa_supplicant" and see what "wpa_cli -a myscript" can do for you.
can you give me more details about wpa_cli?

Thanks

epoch1970
Posts: 5022
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Automatic switching between wifi network

Sun Jun 28, 2020 2:47 pm

Considering the wpa_cli action script mechanism is 14 years old, I'm fairly convinced enough information is available already.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

AGID
Posts: 36
Joined: Tue Mar 17, 2020 1:02 pm

Re: Automatic switching between wifi network

Sun Jun 28, 2020 5:40 pm

epoch1970 wrote:
Sun Jun 28, 2020 2:47 pm
Considering the wpa_cli action script mechanism is 14 years old, I'm fairly convinced enough information is available already.
Ok thanks

AGID
Posts: 36
Joined: Tue Mar 17, 2020 1:02 pm

Re: Automatic switching between wifi network

Sun Jun 28, 2020 8:11 pm

epoch1970 wrote:
Sun Jun 28, 2020 2:47 pm
Considering the wpa_cli action script mechanism is 14 years old, I'm fairly convinced enough information is available already.
It just provide limited access through Actionscript which wont be so much useful but thanks for the idea :)

Return to “General discussion”