Activate an easy Automated WiFi AccessPoint or connect to a local WiFi Network for Raspberry Pi OS Bookworm. The AP is automatically created when you are not in range of a known WiFi network. Useful for both headerless or desktop setups. 

With the Raspberry Pi being so portable it is always useful to have a wifi connection. When the wifi signal has been lost due to a weak signal, it can be a bit of a nightmare trying to get access to the Pi without a screen.

The script in this Article will monitor the wifi connection and make sure you are connected to a known Wifi network when the signal is good or it will create a WiFi access point, so you will always have a wifi connection available.  It will also allow you to flip to an Access Point with a simple command and back to a WiFi network on demand.


The Access Point will allow a direct Wifi connection to the Pi from a Phone, Tablet, Laptop for use with ssh, VNC desktop sharing, a local web server, etc.

Every 2 minutes the AccessPopup script will check the local wifi network signals. If a known one comes back into range, then a connection is made to the wifi network and the Access Point is stopped.

This is useful for Devices that may be running sensors, cameras or other monitoring software in your Garden, Greenhouse, Shed or Garage that may be where the WiFi signal is weak. You will always be able to get a connection over wifi and is ideal for headerless setups. 

This is also useful for any setups where the Pi is required to go in and out of wifi range. 

Compatibility:

Requires any Raspberry Pi computer. Tested with PiOS 12 Bookworm, Ubuntu 23.10 Raspberry Pi Image and Arch Linux Arm for Pi4 32bit.
This will NOT work on PiOS 11 Bullseye or 10 Buster or older as they do not use Network Manager.

A similar script is available for PiOS 11 Bullseye and older called AutoHotspot.
This is available at raspberry-pi-automatic-hotspot-and-static-hotspot-installer

Installation and Use:

Latest versions:
accesspopup 0.8-4 3rd Feb 2024
installconfig.sh 0.8-6 12th Mar 2024

Installation:
download the archive file with curl "https://www.raspberryconnect.com/images/scripts/AccessPopup.tar.gz" -o AccessPopup.tar.gzunarchive with tar -xvf ./AccessPopup.tar.gz change to the AccessPopup folder cd AccessPopup Run the Installer script
sudo ./installconfig.sh

The menu options below will be presented. Use option 1 to install the AccessPopup scripts.
This will automatically start monitoring the wifi connection every 2 minutes. It will also check the wifi at startup and then at every 2 minute intervals.

Setting a Constant Access Point:

Sometimes it is useful to be able to use the AccessPoint even though the Pi is in range of a known WiFi network.
This can be done by opening a terminal window and entering the command:
sudo accesspopup -a

to go back to normal use, just run the script without the -a argument.
sudo accesspopup

alternately use option 4 "Live Switch..." on this installer script.

Menu Options:

1 = Install AccessPopup Script
Installs the AccessPopup script and starts the 2 minute checks

2 = Change the Access Points SSID or Password
The access points wifi name (ssid) is AccessPopup and the password is 1234567890.
Use this option to change either or both. At least change the terrible password.

3 = Change the Access Points IP Address
The Access Points IP address is 192.168.50.5. Use this option to choose a new IP address, based on 10.0.#.# or 192.168.#.#

4 = Live Switch between: Network WiFi <> Access Point
Switch on demand. Set the Pi to an Access Point until the next reboot or switch back to a known WiFi Network in range.

5 = Setup a New WiFi Network or change the password to an existing Wifi Network
Scan for local WiFi networks and connect to a new one or change the password to an existing profile.

6 = Change Hostname
Change the system Hostname, so a connection can be made by name instead of an IP address.

7 = Uninstall AccessPopup
Uninstall the AccessPopup script and return the RPi to its default wifi setup.

8 = Run AccessPopup now. It will decide between a suitable WiFi network or AP

9 = Exit

 

Using the Access Point:

When the Access Point has been activated, the SSID AccessPopup will be broadcast. Using a wifi device, scan for new wifi devices in the area, and select AccessPopup.

You will be prompted to enter the password.

If you have not already changed it, the password will be 1234567890. Don't use the password that is used to log into the Raspberry Pi.

The connection to the Access Point will be made.

SSH, VNC, Web Server

Now that a connection to the Access Point has been made, If you are using SSH, VNC or accessing a web server of the RPi then use:

ssh: This email address is being protected from spambots. You need JavaScript enabled to view it..5   so if your user is called  pi, then use ssh This email address is being protected from spambots. You need JavaScript enabled to view it..5

VNC remote desktop: enter the server as 192.168.50.5 

Web server: if there is a web server running on the PI, it can be used by entering http://192.168.50.5/ into a web browser.

The Hostname of the device can also be used in place of the IP address for any of the above options.

 

Using AccessPopup in a terminal window: 

 AccessPopup is set to run automatically every 2 minutes but it can be run manually to switch to the Access Point.

In a terminal window enter: sudo accesspopup -a

The access point will be activated and the timer will be stopped so it doesn't try to connect to a Wifi network again.

To re-connect to a nearby known wifi network, either reboot or run the script without -a

sudo accesspopup

This will attempt to connect to a known local wifi network and re-activate the 2 minute timer.

If a wifi network connection can't be made, it will activate the Access Point again and continue to monitor the connections.

 

Using Network Manager from The Desktop:

Alternately to using the AccesPopup script, the Network Manager interface can be used to make your own Access Point. This will be used if no know wifi network is found when the Pi is started. If a known Wifi Network is then in range, Network Manager will keep the Access Point going until it is manually stopped in the WiFi menu or the Pi rebooted. If this suits your needs and you are always using the desktop environment then the standard setup may be useful. 

To create an Access Point in Network Manager use the "Create Wireles Hotspot" menu option

RPi NetworkManager CreateHotspot
RPi NetworkManager Hotspot Details

As standard Network Manager will use a previously setup Access Point if no known Wifi network is in range. Then when a known Wifi network comes into range you will need to manually stop the Access Point and select the desired Network. 

So the AccessPopup script is not required if you are only using a Desktop environment.

AccessPopup is most useful for setups without a desktop (headerless) or where the wifi signal is inconsistent as the wifi connection will be remade every time it is strong again. 
If you are using the AccessPopup script and Network Manager desktop menu, then AccessPopup will switch from any Access Point back to a known Wifi network every 2 minutes unless the following command is used in a terminal screen window.
sudo accesspopup -a

This will also stop the timer and the script from running.

Using the "Advanced Options" and "Edit Connections" the AccessPoint settings for the profile AccessPopup can be changed, by selcting the profile and then the cog icon.

RPI NetworkManager EditConnectionRPi NetworkManager edit profile

The AccessPopup profile will be removed from the Network Manager menu if option "7 Uninstall" of this script is used. Unless the profile name has been changed.

On re-installing AccessPopup the default options will be setup. Any other AccessPoint that has been setup, will be ignored in favour of the AccessPopup one.

If you find this guide useful and wish to show your appreciation then you are welcome to make a donation or share a link to this article. There is no obligation to do so, this guide is free for use and support is available to everybody as long as I know the answer :)

I am the single developer of this script and website. Any support towards the costs are welcome.

RaspberryConnect.com

 

  

Considerations:

The Access Point disconnects every 2 minutes.

If a WiFi network is setup but the password is not correct, then the connection will fail. Once there is an attempt to connect to a WiFi network, it is added to the list of known networks by Network Manager.
When an Access Point is active, every 2 minutes it will be deactivated to connect to the bad WiFi network when it is in range. This will disrupt any connections to the Access Point.
The Access Point will be re-enabled once the connection to the Wifi network has failed.
If you experience this, then correct the password with option 5 or the Desktop interface. Otherwise delete the bad Wifi network entry.

Ethernet connection to the Pi

If an Ethernet cable is connected to the Pi and the Access Point is available, any device on the Access Point can ssh/vnc/ping etc the other devices also connected to the access point and the network the Ethernet is connected to. This includes the internet, if it is available.
No device on the Ethernet's network can connect ssh/vnc/ping etc to the devices connected to the access point. The Ethernet network can access the Pi, as it is on both networks.

 Using a Second WiFi Device

 When a second Wifi device is setup such as a USB Wifi dongle, no device connected to the access point can ssh/vnc/ping etc the network that the second Wifi device is connected to. Devices connected to the Access Point can only access the internet or other networks through a connected Ethernet cable.
To do this through a second wifi device requires additional configuration.

 Loss of Connection when a Switch Happens

 Any connection to the Rpi from another device will be lost when the RPi switches from a Wifi Network connection to an Access Point and back. 

If you are using ssh then programs such as tmux will keep your session running while you connect back to your RPi on the new wifi connection. 

VNC will reconnect if you are using a Hostname as the server connection. If you have connected with an IP address then you will need the new IP adress from the network you have connected through. 

 


Add comment

Comments  
Ing
Hello, thank you for this great utility. I have just installed it on a CM4 Raspi using Bookworm. The Issue i am having is the following: My home network has 3 SSID's The Raspi with Autohotspot is setup to connect to a Access Point with the SSID "C" Raspi connects nicely after start to SSID "C" If I power down the AP with SSID C, the Raspi comes up with its own SSID "D" I can connect to it. If I power up the AP with SSID C the raspi does not reconnect back to C. It is still broadcasting his SSID D. I can connect to it. Q: how can I debug this problem?
Ing
Hi Jakob

The script is triggered by a systemd timer. Check the status of that with "sudo systemctl status AccessPopup.timer"
This should be active with the time left until it triggers again.
You can also check the service for any error messages. "sudo systemctrl status AccessPopup.service"

Otherwise you can run the script manually with
"sudo accesspopup" and you will get feedback on what it is doing while it is trying to connect to your network again.
then use "sudo accesspopup -a" to switch back to the Pi's access point.

If that doesn't give any clues the let me know what details you see and I will take a closer look.
reply to Roboberry2024-03-22 13:09
Did you got my answer about the interface created by zerotier which blocks switching back to WLAN
reply to Roboberry2024-03-22 13:09
Hi Jakob No haven't received any new comments. You can email me if it is easier admin @ this site, and I will take a look.
Ing
Hi, thank you for this great work. I just installed it on Bookworm and a CM4 Module. I am faced with the following issue. The Raspberry hooks up nicely on the Home WLAN Access point. If I switch this AP off, the Raspi with the autohotspot comes up correctly as a Hotspot. If I switch the Home WLAN AP on again, autohotspot is not changing back to the Home AP. Its still showing up and i can connect to it. I have to say, there are other two other SSID on the Home Network. How can I debug this problem? Thanks Jakob
Armbian bookworm install
Good morning,
First of all, again a wonderful job done, thanks for that.
I have an Banana Pi M2 Zero, with OS Armbian 24.2.1 bookworm Linux 6.6.16
The installation of your program accesspopup 0.8-3 went without errors.
I could change the IP address to 192.168.50.10 without a problem and the my SSID "clearview" get broadcasted too.
On the BPi side, ip addr is showing the broadcasted ip address 192.168.50.10
I can connect to the access point with my windows 10 laptop (with ExpressVPN) but when trying to run PUTTY, Putty cannot connect. Not with hostname and not with pi@192.168.50.10, or hostname "clearview.local"
I also switched off ExpressVPN but that didn't help.
Is there anything I can check/change to make your program to work.
I understand fully the fact that original your software in not build for the exotics of BPi and Armbian bookworm :-)
Kind regards
Ed
Armbian bookworm install
Hi Ed

Thank for the feedback. I do plan on testing it with various OS's including Armbian but only got as far as Ubuntu and Arch so far. In theory it should work with any system with Network Manager but other factors may need configuration depending on the OS.
Going by my previous scripts, if you can get a connection and your laptop has been issued an ip address then the issue will be with other setup.
When the Hostname is changed, it will need rebooting for it to take full effect.

Check that dnsmasq-base is installed. If that is not available as a package then just dnsmasq as the accesspoint won't work properly without that.

If you have a desktop available and can check if VNC desktop sharing is working then the issue will be with the ssh server rather than the accesspoint. Are you able to ssh from a different device/software.

If you have no luck I am happy to check out Armbian soon as the next OS to look at.
Add a wi-fi adapter selection menu.
I have a raspberry pi4b, and the raspbian bookworm OS is currently installed. I am using an external dual band wifi adapter RT3572 ( https://www.ebay.com/itm/293129730857 ). How do I set up your script so that I can use both the built-in and external wifi adapter? That is, so that I can choose which wifi adapter (wlan0 or wlan1) was used to access the Internet, and the other was used as an access point? Scenario number 1: The RPI is relatively close to the WiFi router, and the clients are far away. In this mode, it is better to use wlan1 as an access point. Scenario number 2: The RPI is far from the WiFi router, and the clients are nearby. In this mode, wlan0 is better as an access point. Thanks!
Add a wi-fi adapter selection menu
Hi Lopen

The the device that is used for the AccessPoint can be edited at line 11 of the accesspopup script.
The best way to do this is to edit the accesspopup script in the downloaded and un-archived folder.
Then uninstall the currently active script and then install the new one.

You can only have one device set for the AccessPoint with this script though. You can't easily swap the device as the AccessPoint profile is set to use the same device. The script expects only one profile with the name AccessPopup and if it detects another AccessPoint setup on the default wifi device (in line 11) it will deactivate it and re-enable the AccessPopup profile.

If you are using the desktop then you can manually create a "Hotspot" for wlan1 with a different name and then manually select it from the list of networks. Using the wifi GUI by the clock. You would have to manually change the selected network that wlan0 is set to. So unfortunately it's not that straight forward.

Also when you have both wlan0 and wlan1 setup. The devices on the AccesPoint won't be able to use the internet unless nftables are setup to route the data between wifi devices, which is not part of the current setup.

So unfortunately that is not possible with the setup.
Thanks for the detailed answer!
I will do as you wrote. To access the Internet for external devices, I will use a proxy server installed on raspbian (3proxy). Perhaps in the future, if you have time, if it doesn't bother you, you can refine the script for a more flexible application. Thanks again for the response in particular and for your helpful website in general.
Add a wi-fi adapter selection menu
Thanks, You are welcome.
This current script is the basic version to replicate my previous wifi script for Bookworm.
I am currently developing a more featured script, so I will take you comments into consideration. Thanks.
Adjust Wifi AP Transmission Power using Network Manager
Hey therer, I have an adjacent question on how to reduce the transmission power of the Wifi AP/hotspot using the Network Manager. Basically I want to reduce the radius of my hotspot, so you can only connect to the Pi when you are very close by. Within the NM GUI, you can edit the settings for the wireless hotspot and I see that it includes Transmission Power as an editable setting but it is set to 0mW by default. Changing and saving to a new mV value also doesn't actually update the setting either (ie. when you reopen the settings for the hotspot its back at 0mW). Maybe its just a place holder and yet to be implemented? Is there another way to do this?
Adjust Wifi AP Trans
Hi I have had a look at the NM Gui on my Pi and I can't see an option for transmission power and I can't see anything in the docs to change that setting. The only other place I know of a power setting is with IW dev set txpower [] phy set txpower [] to see your current setting use sudo iw dev Then to make the change there is a fixed option, but you have to bring the interface down to make the change. sudo ip link set wlan0 down sudo iw dev wlan0 set txpower fixed 15000 sudo ip link set wlan0 up Not sure if this helps as it will limit the wifi all the time. Other than putting a physical barrier round the Pi to reduce the signal I don't know what else to suggest.
Unable to connect to network
Hey,

this script is perfect for me, but it doesn't reconnect to my wifi at home. The accesspoint at the works perfectly, but when i want to switch back with (4), or (8) to my home wifi it always shows me the message:

Checking: *ssid name*
unable to confirm connection status
a network connection has not been made with any known ssid. activating acceess point

But, if i go back to nmtui and reconnect to my home wifi, it works. I have tried several ways to create the connection, with nmtui, with the script, but i won't reconnect.

Need help, thanks!
Pascal
Unable to connect to network
Hi Pascal

That's a bit odd, I will have a look into what is causing that. It will be detecting the SSID from your home network. After it activates the connection it waits for a response from NM. If it doesn't get the a valid response you get the message you see.
Could you activate your connection with the command 'nmcli con up Your-Network-Profile-Name'
and send me the feedback text please. Just to check it's not anything I haven't seen yet.

Does your NM profile name have any special characters or spaces in the name?
Unable to connect to network
Hi,
thanks for the reply. With sudo, the connection works. Output ist German, connection established, no errors occured.
Verbindung wurde erfolgreich aktiviert (aktiver D-Bus-Pfad: /org/freedesktop/NetworkManager/ActiveConnection/3)

My ssid is RaumschiffEnterprise, no spaces, nothing special there. It seems the Accesspopupscript doens't wait until NM has answered. It shows the message "unable to confirm" pretty quickly.

Another odd thing is, at the network list i always get all entries twice. Maybe it is confused about the doubled entries.

Add or Edit a Wifi Network
Add a new WiFi network or change the password for an existing one that is in range
1 FRITZ!Box 7530 AL
2 RaumschiffEnterprise Gastzugang
3 RaumschiffEnterprise
4 RaumschiffEnterprise
5 RaumschiffEnterprise Gastzugang
6 FRITZ!Box 7530 AL
7 FRITZ!Box 7530 AL
8 To Cancel

2 until 5 are mine, i have also 5GHz Wifi, but Rpi Zero W can only connect to 2.4GHz, so this is not the reason.
Unable to connect to network
Hi Pascal

Thank you for the information.
I think I have found the issue and tested it using a WiFi repeater and your SSID's.
I have updated the script and done some other updates as well
If you download the latest version. Then use option 7 to uninstall the old script and then option 1 to install the new script.
it should start using the changes.

The repeating SSIDs is because it picks up each antenna on the router. If you run the command

sudo iw dev wlan0 scan ap-force | grep -E "^BSS|SSID:"

you will see each Mac ID (BSS) is different for each entry.
It doesn't matter which one is selected though as the right one will be used when the connection is made.

Please let me know if this solves the problem, if not I will look into it further.
Thank you & Question
Hi Wolfgang,
Thanks for the feedback and how you have use the script. That is always interesting to know.
For the issue; the AP should be getting generated. It is on a 2 minute timer so it will check if a known SSID is in range and try to connect to it. As your Network is in range the AP will be stopped, the connection to your router will fail due to the wrong password and the the AP will be setup again. about 1 min 30 seconds later it will do it all over again.
To check if the script will switch when your router ssid is not available you need to change the SSID rather than the password.
nmcli con mod "Profilename" ssid "newssid"

Then the script won't find any known ssids and create the AP.

If you just want an AP while at home you can use
sudo accesspopup -a
as well, and
sudo accesspopup
to go back to normal use.

I hope that helps, let me know if you have any issues
Happy New Year
Forgot to add my question
So, here is a little test I made: I entered
sudo nmcli radio wifi on
sudo nmcli dev wifi connect password ""
with a fake password for my network, which subsequently interrupted the valid wifi connection.

In this case, it should default to the access point, right? Because it doesn't. The wifi network is not shown on my Mac or iPhone.
Am I missing something?
Thank you & Question
Great update, thanks much! I find the menu also clearer than the previous version. I am working to include this in a picture frame application. When you give family members a homebrewed picture frame (www.thedigitalpictureframe.com), the first problem is always the Wifi. Your app would make it easy to access the frame.
Install Bug: RPI 4, Bookworm
Error on the installconfig.sh

./installconfig.sh: line 563: -3: substring expression < 0
Install Bug: RPI 4, Bookworm
Thank you for that.

It is trying to display the ip address, so just info and not an issue to the function.
I will fix that.