I've followed this guide on how to create a Wireless Access Point. Now I want to modify the behaviour as follows:

  1. If the home network is available, don't create a new network and connect to it.
  2. If the home network isn't avaiable, create a new network. Thanks

2 Answers 2


You can find an example how to Switch between WiFi client and access point without reboot. But it is only for manual switching. It does not detect a hotspot to automatically connect to it and switch off the access point. To make it possible, the wpa_supplicant client service must always run so it can detect an available hotspot nearby. You can only switch on/off the access point in addition to the client service. So you have first to setup a Access point as WiFi repeater, optional with bridge or Access point as WiFi repeater with additional WiFi-dongle. Then you could use wpa_cli running as daemon with option -a to detect a connection to a hotspot and switch on/off the access point on the RasPi. A generic example of doing this you can find at Run a script when WiFi is connected to a particular wifi network.

If you use only the built-in WiFi device and not an additional USB/WiFi dongle, you should take note that switching the access point will also interrupt the client connection to the remote hotspot for a short time. This is due to a hardware/firmware limitation of the WiFi device. It shouldn't bother very much because you just connect to the hotspot. But if it isn't acceptable, you have to use an additional USB/WiFi dongle.


I did develop a solution which did this, BUT while it did work with the onboard WiFi interfaces it is a kludge, so I can not recommend it as a reliable solution.

Raspberry Pi to configure automatically as an Access Point OR WiFi client.

It is far simpler to change modes using systemd-networkd.
This requires a total change to networking and more manual configuration, and I am not sure if there is a solution which automatically switches. You should study Ingo's many posts to see if one of these meets your needs.

If you did want to explore this, I suggest you first migrate to systemd-networkd. https://raspberrypi.stackexchange.com/a/117843/8697 describes a relatively simple setup which works as well as dhcpcd.

  • Thanks for your response. So it seems like there isn't a easy way to achieve this. I'm just developing on a Pi3 connected to the home network via Ethernet instead of a Pi Zero Dec 8, 2020 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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