Saturday, 28 May 2016 11:47

Raspberry PI 3 Auto WiFi Hotspot if no Internet

Written by 
  • Author Type: Individual
  • Operating System: Raspbian
  • Country: UK

I'm using a Raspberry Pi 3 which i want to connect to via SSH from my Android tablet or phone when i am not in range of my home router.

My requirements are for when the pi is at home it connects to my home router or other known routers so it is available on the local network. If no router is found when it is started up then it will create a wifi hotspot, which is not rooted to the Internet, so i can SSH to the RPi from another device and control the camera and run other custom scripts.

Previously i could do this by creating an adhoc hotspot on my Android Nexus tablet and set the Raspberry Pi to connect to the Tablet if the home network was not in range. In google's infinite wisdom they dropped this feature for my Nexus tablet in the Android Marshmallow update, meaning i could no longer connect to my pi when i was out and about.

The other solution is for the RPi to create a wifi hotspot and connect my tablet to that. Most tutorials for hotspot setup on the pi are for creating an access point to the internet via the Raspberry pi which is not what I require.
I use my pi for photography amongst other things when im out and about, so i don't need internet access just a direct connection to control the Raspberry Pi via SSH from my tablet.


This article has been updated as some commands became depreciated, it also uses the more recent systemd start-up process rather than rc.local.

The original script is available here for reference purposes.

If you are using the rc.local script and wish to use this article then just restore the original rc.local file, shown in the original article, and then follow on from "Start-up Script"


 This tutorial is the solution I used based on parts of other tutorials i have found online.


Raspberry Pi searches for known router's (SSID)

If the router is not found then it creates a hotspot so tablets, phones and computers can connect to the Raspberry Pi's WiFi hotspot, which is not routed to the internet but allows a connection via SSH, VNC etc.

(Internet will not be available via Ethernet either while the hotspot is active but will be restored after a reboot and a known router is in range.)


Raspberry Pi 3, Raspberry Pi ZeroW or other Raspberry Pi with WiFi dongle*

Internet Connection

WiFi connection already set-up to your local router or any routers you are using with this script

*some WiFi dongles don't work in adhoc mode or don't work with with the nl80211 driver used in this guide, so you may want to check this first before starting.



To start with hostapd hotspot client and dnsmasq lightweight dns server need to be installed.

Open a Terminal session.

Update Raspbian with the latest updates by entering the commands:

sudo apt-get update

sudo apt-get upgrade

 To install hostapd enter the command:

sudo apt-get install hostapd

enter Y when prompted.

To install dnsmasq enter the command:

sudo apt-get install dnsmasq

enter Y when prompted

The installers will have set up the programme so they run when the pi is started. For this setup they only need to be started if the home router is not found. So automatic startup needs to be disabled. This is done with the following commands:

sudo systemctl disable hostapd

sudo systemctl disable dnsmasq

Now the hostspot configuration file can be setup. This contains the name of the WiFi signal you will need to connect to (SSID) and the security password.

To edit the configuration files I will be using the nano text editor but if you prefer an editor with an point and click interface then replace nano with leafpad in the following instructions.

Hostapd Configuration

Using a text editor edit the hostapd configuration file. This file won't exist at this stage so will be blank.

sudo nano /etc/hostapd/hostapd.conf

enter or paste the settings:


  • The interface will be wlan0
  • The driver nl80211 works with the Raspberry Pi 3 onboard WiFi but you will need to check that your wifi dongle is compatable and can use Access Point mode.

For more information on wifi dongles see

  • The SSID is the name of the WiFi signal broadcast from the RPi, which you will connect to with your Tablet or phones WiFi settings.
  • Channel can be set between 1 and 13. If you are having trouble connection because of to many wifi signals in your area are using channel 6 then try another channel.
  • Wpa_passphrase is the password you will need to enter when you first connect a device to your Raspberry Pi's hotspot. This should be at least 8 characters and a bit more difficult to guess than my example.

To save the config file press ctrl & o and to exit nano press Ctrl & x

Now the defaults file needs to be updated to point to where the config file is stored.
In terminal enter the command
sudo nano /etc/default/hostapd


And save.

dnsmasq configuration

Next dnsmasq need to be configured to allow the PI to act as a router and issue IP addresses.

sudo nano /etc/dnsmasq.conf

Go to the bottom of the file and add the following lines

#Pi3Hotspot Config
#stop DNSmasq from using resolv.conf
#Interface to use

And then save (ctrl & o) and exit (ctrl & x)


Now that hostapd and dnsmasq are configured we now need to make some changes to the interfaces file and then add a script that will detect if you are at home or not.

Next we need to edit the interfaces file. There will be several entries already in the file. Look for references to Wlan0 and alter them as below.
Any reference to wpa_conf for wlan0 should be disabled by putting a # at the start of the line.

Open the interfaces file with the command

sudo nano /etc/network/interfaces

edit the following lines as below

auto lo wlan0
iface lo inet loopback

allow-hotplug wlan0
iface wlan0 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

now save (ctrl & o) and exit (ctrl & x)


Required only if:

if your home routers SSID and password was listed in this file then the hotspot will probably not get generated.


You will need to put a # infront of each line

#iface wlan0 inet dhcp
#       wpa-ssid "mySSID"
#       wpa-psk "Router Pasword"

These details need to be in the wpa_supplicant.conf file to work with this setup.

Add your router details to the wpa_supplicant.conf file with 

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

and add the following commands to the bottom of the file.

        psk="Router Password"

If in the future you change your router connection details with the WiFi icon by the clock then check that the changes have been made to the wpa_supplicant.conf file and not the /etc/network/interfaces file.

Note: Change "mySSID" to the ssid of your router and "Router Password" to the password of your router.

Start-up Script

The final stage is to setup the startup-scripts using the systemd process.

if you have been updating Raspbian Jessie and not used a recent image you may not have some wifi tools installed.

just chek you have iw installed with

dpkg -s iw

If it is not found then install it with

sudo apt-get install iw


This script will check what routers are available when the RPi. The first router found in the wifi settings will be connected to using existing configured WiFi settings. If no know routers are in range then a WiFi hotspot is created.

Create the start-up script in a new file in /usr/bin/

sudo nano /usr/bin/autohotspot


Enter this script. (last modified 30th May 2017)

#Wifi config - if no prefered Wifi generate a hotspot
#This two lines check for any SSIDs in your RPi's wifi settings
wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g')
#or check a restricted list of SSID,s that are setup. 
#Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid)
#Enter one or more ssids that are already setup in the wifi settings
#Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2')
#Main script
    ip link set dev wlan0 down
    ip a add dev wlan0
    ip link set dev wlan0 up
    systemctl start dnsmasq
    systemctl start hostapd
for ssid in "${ssids[@]}"
    if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null
        wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1
        if dhclient -1 wlan0
            wpa_cli terminate
        echo "Not in range, WiFi with SSID:" $ssid
    if ! $connected; then

One of the lines of the script may go off the right side of the webpage alternately this script is available to download here

The line reads:

ssids=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g')

Thanks to Tino for this code


The line starting with ssids=$(awk.... lists all routers in the Raspberry Pi's wifi settings. If you need to restrict this to only certain SSID's currently setup then put a # infront of the ssid=$(awk... line to deactivate it and also the line ssids=($wpassid). Then remove the # infront of #ssids=('myssid1')

then in the line ssids=('myssid1')
replace 'myssid1' with the SSID of your router.

in the UK common SSIDs are in the format of SKY12345, BTHub-1234, TalkTalk12345, VM123456, plusnet1234 etc

If you access other routers then enter them, with single quotes and a space between each entry. The script will try each one and make a connection to the first one that is available.

Then save (ctrl & o) and exit (ctrl & x)


make the autohotspot script executable with the command

sudo chmod +x /usr/bin/autohotspot

Next add a service file to systemd.
Create a file in /etc/systemd/system and add the service file

sudo nano /etc/systemd/system/autohotspot.service


Enter the script

Description=Generates a non-internet Hotspot for ssh when a listed ssid is not in range.


Then save (ctrl & o) and exit (ctrl & x)

This service file can be downloaded here

now enable the Hotspot service with the command

sudo systemctl enable autohotspot.service

 If you use a Hidden SSID...

If your router does not broadcast the ssid the /usr/bin/autohotspot script will not find your router and always go to a hotspot. By scanning for your MAC address instead of your SSID the script will work.

Your mac address will be printed on your router somewhere in the format XX:XX:XX:XX:XX:XX using letters and numbers.

It can alternately by found using the command

sudo iw wlan0 scan | egrep "BSS|SSID"

Which will return all the routers in range, the top one should be your router.

(My routers ssid is not hidden so you won't see the ssid but my results were as follows)

BSS XX:XX:XX:XX:XX:XX(on wlan0) -- associated
    BSS Load:

where X is the address results.

Once your know your MAC address the following changes can be made to the /usr/bin/autohotspot script.


#enter required ssids: ssids=('ssid1' 'ssid2')
ssids=('mySSID1' 'mySSID2')


#enter required MAC Addr: macAdresses=('XX:XX:XX:XX:XX:XX' 'YY:YY:YY:YY:YY:YY')



for ssid in "${ssids[@]}"
    if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null


for macAdress in "${macAdresses[@]}"
if iw dev wlan0 scan ap-force | grep "$macAdress" > /dev/null

and change

echo "Not in range, WiFi with SSID:" $ssid


echo "Not in range, WiFi with MAC:" $macAdress


The Router detection should now work for you.

Thanks to Willem Me for supplying these modifications.


Testing the Hostspot

To test if the hotspot is being created edit the /usr/bin/autohotspot file again and change your SSID to something else such as mySSID1off

ssids=( 'mySSID1' 'mySSID2' ) to ssids=( 'mySSID1off' 'mySSID2off' )

Save the /usr/bin/autohotspot file and then reboot.

When the desktop loads the WiFi network icon in the top right corner will be two screens instead of the usual WiFi icon.


When the mouse is placed over the icon is should show a popup displaying the RPI3hot access point.



Check the WiFi signals in range with the wifi settings on a Laptop, tablet or Phone and you should see that one of them is RPI3hot



Select RPI3hot as the WiFi signal to connect to. The security password will be the one you set in the hostapd.conf file.

From my example that would be 1234567890.

Now you are connected to the Raspberry Pi's hotspot and you can now open a SSH connection as usual using the IP address

Once your happy it is all working, reset the SSID entry back to your routers SSID and your ready to go.


This setup has been tested on a Raspberry Pi 2 and PiZero with a WiFi dongle and with a Raspberry Pi 3 and PiZero W all running Raspbian Jessie. 

Wifi and Hotspot Auto Switch Script

I have an alternative script that can switch between wifi and a hotspot without rebooting using a timer or manually.

Details are in this article Raspberry Pi - Auto WiFi Hotspot Switch


If you no longer require this script then it can easily be disabled without affecting your set-up.

Restore your wifi startup by editing the /etc/network/interfaces file and removing the # from the line # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Then disable the startup script with the command

sudo systemctl disable autohotspot

After a reboot your RPI will connect to your router.



Dnsmasq bug: in versions below 2.77 there is a recent bug that may cause the hotspot not to start. This can be resolved by removing the dns-root-data.

check your version with : dpkg -s dnsmasq

versions 2.77 and above are ok. If not then try the command:

sudo apt-get purge dns-root-data

thanks to danny for highlighting this.




Find the latest and greatest embedded system development kits and boards at!




Last modified on Monday, 05 June 2017 20:47
roboberry SuperUser.  Contactable via the site admin e-mail in the Contact Us link.


Leave a comment

Comments for Guest and account owners. Account owners will need to login to use registered e-mail address.


  • Comment Link RobM Friday, 23 June 2017 02:38 posted by RobM

    Thank you for the tutorial.I'm using it with the RPi-Cam-Web-Interface. Is it possible to configure so a gateway/router ip is issued with the dhcp? I can connect via Android, but not my IOS 10.x devices("No Internet Connection" error). IOS device gets IP Address (169.254.132.x) and Subnet Mask, but no router address. I believe IOS has to get an router address to finish the connection to the RPi. I am able to successfully connect to Wi-Fi enabled action camera with the same IOS devices. only difference is that action cameraa connection shows a router address (that is being issued by the action cam. Thank you in advance!

  • Comment Link Edwin M Sunday, 18 June 2017 19:09 posted by Edwin M

    Alright thank you for the speedy response I will try it

  • Comment Link Graeme Sunday, 18 June 2017 15:05 posted by Graeme

    Hi Edwin M if you are trying to remove the script then all you need to do is follow the removal section. To get it working try redoing the command sudo chmod +x /usr/bin/autohotspot as the script may not be running. Also enter sudo systemctl status autohotspot it will say it is dead but show the time it run. If it doesn't show it run try to re-enable it. Your welcome to email me with more details to find the issue.

  • Comment Link Edwin M Sunday, 18 June 2017 11:12 posted by Edwin M

    Okay so I need to get my wifi back and I followed the directions yet my wifi isn't working anymore nor will my pi 3 want to see any network connection

  • Comment Link Graeme Wednesday, 07 June 2017 20:03 posted by Graeme

    Hi Berk, I do intend on do that one, not something I currently need but appreciate there is a interest in that set-up. I will bump that one up the list and put something together soon.

    Thanks for your interest.
    UPDATE: I now have a working version that does route to the net. I will need to test it for a bit before I share it.

  • Comment Link Berk Wednesday, 07 June 2017 15:05 posted by Berk


    Thank you for this usefull tutorial work perfectly fine. I've read it's already asked but i would like to connect my action camera to raspberry with hotspot(which is working) and my raspberry to internet via ethernet or usign usb 3g router i guess it's(wwan0). As you already said you have other projects to do just asking have you got the chance to look this up?

  • Comment Link Graeme Friday, 02 June 2017 20:50 posted by Graeme

    Hi Kevin, have a check that the script has been saved. In a terminal window enter; ls /usr/bin/auto*
    you should see the autohotspot file listed. if not save the autohotspot script again. If it is there try the chmod command again. otherwise navigate to the folder with
    cd /usr/bin then try sudo chmod +x autohotspot
    The script wont be able to run unless this is done. just to check that chmod worked you can enter the command;
    ls -g autoh* or ls -g /usr/bin/autoh*
    you should get a result like this -rwxr-xr-x 1 root 2477 Jun 2 20:27 autohotspot
    the X's in the results means it worked.

  • Comment Link Kevin Friday, 02 June 2017 00:20 posted by Kevin

    when I typed in the "sudo chmod +x /usr/bin/autohotspot" command, it said it could find the file in the directory. Nothing else after it worked.

  • Comment Link Graeme Wednesday, 31 May 2017 21:21 posted by Graeme

    Hi David G, Yes this setup will allow you to access your RPi from your laptop. On the Laptop select RPI3Hot as the wifi network to connect to. Then you can use ssh with pi@ to connect to the pi. You can also enter in your laptops webbrowser to access the webserver website. If the PI is setup to be able to connect to your router it will always connect to that if it is in range rather than generate a hotspot.

    If you do connect the RPi to a router at times that will always be in range and want to force a AP then it can be done with other scripts I have. Let me know if that’s the case.

  • Comment Link David Goadby Wednesday, 31 May 2017 15:55 posted by David Goadby

    Can I set-up an AP for a laptop to connect to the RPi only?
    I have a LAMP stack running on the RPi which has a simple LCD display ie no X or GUI. I would like to use a wifi connected laptop to access the web server on the RPi for configuration purposes. That is to say no LAN access or Internet access is required - just localhost really.

  • Comment Link Graeme Tuesday, 23 May 2017 23:10 posted by Graeme

    hi ScottSammarco, I hope you can get your years back, i had similar issues creating the script so I know how you feel. The red X's will appear if hostapd is down or the wifi is down. If you hover over them is should say Disassociated from RPi3Hot. As you have checked this all to death it may not be something simple but I just need to know some things to see where we are at. What is the status of hostapd sudo systemctl status -l hostapd. and is iw installed ok dpkg -s iw should say status installed ok.
    if you get no clues from this or you have already covered this your welcome to e-mail me your config files and scripts and I will try them on my pi3. Or email me more details and I will look into it.

  • Comment Link Graeme Tuesday, 23 May 2017 20:30 posted by Graeme

    Hi Dan, sound like the issue is with dnsmasq. if it's not working you will get the hostpot but no ip address. check it's status when the hotspot is running. sudo systemctl status -l dnsmasq
    hopefully that will show an error or that it is not working,inactive(dead). Try manually starting it with sudo systemctl start dnsmasq. If the pi issues an IP after that then check the autohotspot script in the CreateAdHocNetwork() section. if no luck email me more details and i will see what I can do.

  • Comment Link ScottSammarco Tuesday, 23 May 2017 20:07 posted by ScottSammarco


    I found your tutorial helpful but I have ran into an issue.

    After double and triple checking for typos like hostapad and other silly mistakes, I am sure I lost a few years off of my lifespan. I have combed through the comments thinking that somebody else has a similar problem and other people did but the given solutions never helped me fix mine.

    I have the correct SSID of my router and I know because as I change it, I lose connectivity. However, when I reboot my rpi I do NOT see you screens but I do see two lines with a red X. I am using a RPi3 and followed your directions explicitly.

    I have also tried omitting the type of driver to you but this has made no difference.

    Is anybody else having this problem? or found a fix for it?

  • Comment Link Dan Monday, 22 May 2017 13:50 posted by Dan

    Hi Graeme, i think u misunderstood my question ( When i connect with my Laptop (win7) or Android-Tablet or iPhone to my RaspberryPi-Hotspot, my connecting devices (laptop/Tablet/iPhone) don't automatically get an IP-adress from the Pi!

    I always have to set the IP-adress myself manually within the range - 10.0.0.x

  • Comment Link Graeme Saturday, 20 May 2017 09:42 posted by Graeme

    Hi Stan92, I would hope it is not getting confused with similar ssids. I haven't tested that setup but to force a hotspot I add a random letter to the SSID and it goes to a hotspot fine. So based on that I would expect that it would see them as different SSIDS. I have made a change to the script so it automatically scans your wifi settings rather than you needing to enter the SSID into the script. Though that option is still available if needed.
    Try these changes and see if that helps.

  • Comment Link Stan92 Friday, 19 May 2017 18:49 posted by Stan92

    Hi Graeme,
    I thank you for your support..
    I'll make a try..
    Probably I m wrong, but I notice that happens when the SSID starts with the same letters..
    At home, I have several SSIDs (SSR, SSR2) and during my tests, I turned off the SSR routers.. I suspect the script tried to connect to SSR2.. But as I said, I'm probably wrong...
    I thank you once again

  • Comment Link Graeme Friday, 19 May 2017 09:43 posted by Graeme

    Hi Stan92, if the AP mode works then the config is fine. What i think is happening is when you switch the router off, the Pi is not clearing some background wifi files. So when the pi is rebooted it can't set off the AP mode which is why hostapd is inactive(dead). My other script "autohotspot-switch" can do that without a reboot but it has to flush the IP address assigned to wlan0 and make sure the wpa supplicant background files are removed. Hopefully you can use a screen as you will have no network connection to do this once your router is off;
    try sudo ip addr flush wlan0 and sudo rm -r /var/run/wpa_supplicant

    also, if you haven't already, shutdown the PI then switch off the router it should clear things down first.

  • Comment Link Stan92 Thursday, 18 May 2017 23:51 posted by Stan92

    Just some additional info.
    In fact, the AP works and I can ssh the PI.
    When I set the the Wifi, everything is also ok.

    But my trouble comes when I shutdown the router (leaving the /usr/bin/autohotspot without updates), and reboot the PI, I don't switch to AP mode.

    To get the AP mode, it seems that I need to change the declared SSID within the autohotspot file.

    As I run my PI in Kiosk Mode, I can only connect thru ssh.

  • Comment Link Stan92 Thursday, 18 May 2017 23:14 posted by Stan92

    I ran sudo systemctl status -l hostapd
    I get Loaded: loaded (/etc/init.d/hostapd)
    Active : inactive (dead).

    I will check again the procedure.

  • Comment Link Graeme Thursday, 18 May 2017 22:41 posted by Graeme

    Hi stan92, I would presume there is a config error somewhere. As your ssid is not being broadcast the only alternative is to go to AP mode. Is the wifi icon by the clock saying RPI3Hot and you can see RPI3Hot being broadcast with a wifi device? If not there is an issue and the Hotspot hasn't started.
    check hostapd with 'sudo systemctl status -l hostapd' it should let you know if there are any errors.
    Put false ssids in the autohotspot script if that fails just check the script and configs are correct.
    Email me details of whats happening if you have no luck and I will look into it further for you.

  • Comment Link stan92 Thursday, 18 May 2017 21:50 posted by stan92

    I thank you for sharing.. very useful...
    However I have a question :-)
    Let's say my wpa_supplicant.conf contains an entry that I've set to the autohotspot file.
    I notice if I shutdown my router and reboot the PI, it doesn't set into AP mode.
    Is there a way to prevent that? (I would like to go back in AP mode).. I probably miss something..

  • Comment Link Graeme Wednesday, 17 May 2017 19:27 posted by Graeme

    Hi Dan, The IP address to connect with is only set in the script in the line,ip a add dev wlan0 so I would check that there are no errors.

    Some users connecting with an android phones have found that they can connect the wifi to the hotspot but when they try with ssh the phone uses online service instead of connecting to the IP until they deactivate data.

    Are you using a phone, tablet or laptop to connect and does it do the same with all devices?

    If when it is in hotspot mode you enter the command ip addr can you see wlan0 and the ip

    if this doesn’t help email me more details about your setup and how the steps you do and I will look into it.

  • Comment Link Dan Wednesday, 17 May 2017 12:16 posted by Dan

    Hi,somehow i am not getting an ip adress from the RPi when i connect to its hotspot!? I always have to set it myself :/ Any suggestions?

  • Comment Link Graeme Sunday, 14 May 2017 12:22 posted by Graeme

    Hi Reven
    I have mailed you some scripts, from a cut down version of my Switch script, that will give you normal pi wifi activity but allow you to create a hotspot on demand from the desktop rather than at startup. These should do what you need.

    If anybody else would like this setup then you can e-mail for the scripts. admin@ this site.

  • Comment Link Reven Saturday, 13 May 2017 23:10 posted by Reven

    yes that sounds to be perfect, to have the pi work as normal but then be able to turn on the hotspot on demand. would it be difficult to alter the Hotspot Switch script to get this

    thanks again for all the help

  • Comment Link Graeme Saturday, 13 May 2017 09:57 posted by Graeme

    Hi Scott, it should work with multiple ssids. I know it has worked for others.
    just check each of the ssids are separated by spaces in the line ssids=('mySSID1' 'mySSID2')
    I think ther may be an error in your script as it should always generate a hotspot if the network can't be found. If it is not doing either then the script has failed somewhere. Check the status with: sudo systemctl status -l autohotspot it should tell you what this issue is. You can also try running it manually to see whats happening with sudo /usr/bin/autohotspot

  • Comment Link Graeme Saturday, 13 May 2017 09:34 posted by Graeme

    Hi Reven, The wifioff script just disables wifi so you need to reboot to get it back and the autohotspot script to work.
    I think the issue is if it is in hotspot mode you will have to manually add new SSIDs and passwords to the wpa_supplicant.conf file as you can't use the wifi config options. But once they are setup, a reboot will change it to the friends/coffee shop wifi.
    I think what you are looking for is normal wifi but activate the hotspot on demand which is possible but needs a new script for that, basically a cut down version of my Hotspot Switch script.

  • Comment Link Scott Frey Saturday, 13 May 2017 01:26 posted by Scott Frey

    Has anyone gotten this to work with more than one Wifi network configured in wpa_supplicant? I have not gotten it to work after adding 2 or 2 network configurations, only the first one.

    If I configure a second entry (and add the corresponding ssid to the autohotspots script) it fials to either connect to a network or generate a hotspot.

    Not sure if I am doing something wrong or it just can't work.

    Thanks for creating this!

  • Comment Link Reven Friday, 12 May 2017 09:25 posted by Reven

    hey Graeme, this seems to be a pretty ideal solution for me, thats basically exactly what i want,

    Except? when i disable the hotspot with ur solution, can i still connect the Pi to wifi maybe if im at a coffee shop or friends house?

  • Comment Link Graeme Thursday, 11 May 2017 23:07 posted by Graeme

    Hi Reven, as the script manages the wifi to a router or a hotspot it's best not to disable it altogether unless you want it to act as normal all the time. I take it you want to be able to use it as a hotspot but don't want the wifi active every time you use it. As there is no option to disable the wifi with the wifi icon in hotspot mode, I would create a script that you run when you get to the desktop that disables the wifi.
    Create a blank text file and enter these two lines:
    sudo ip link set dev wlan0 down

    save this to your desktop and call it
    then in terminal enter the commands:
    cd Desktop
    sudo chmod +x

    now when you click on the icon select the execute button from the requester that shows. This will deactivate the wifi. When you reboot the hotspot will come back.
    Let me know if this is suitable for your use.

  • Comment Link Reven Thursday, 11 May 2017 14:03 posted by Reven

    thank you for the fast response,
    i have just one question, I will only be using the Raspberry Pi as hotspot mode, i will not use the feature to look for my home wifi because i dont have wifi at the moment.

    so the pi will automatically start the hotspot everytime i boot it up,

    my question is, what would be a simple way to deactivate this, so when i boot my pi up next, it will just act normal with no hotspot mode. but then be able to activate it again so next time i boot the pi it will make a hotspot again

    ive tried to look for solutions, but i'm a beginner with this stuff and would rather ask you ?
    thanks for the help!

  • Comment Link Graeme Monday, 08 May 2017 21:48 posted by Graeme

    Hi Reven, yes the hotspot works with VNC. I am using REAL VNC that is installed with the PI and the viewer on an android tablet. Once the hotspot is running you can connect to it with the ip address the same as ssh. This is the only IP the hotspot uses so I expect it to work fine.

  • Comment Link Graeme Monday, 08 May 2017 21:43 posted by Graeme

    Hi Paul, I have just tried my usb wifi dongle while disabling the internal wifi as you have. It connected to my router ok and also the hotspot worked fine. So it possible could be your dongle.
    maybe check it uses the nl80211 driver.

  • Comment Link Reven Monday, 08 May 2017 20:39 posted by Reven

    hey there, im loking into a non-internet travel solution.
    Would it be possible to connect an ipad to the raspberry pi with a VNC viewer app through this access point?
    would I be able to set the IP address and port to always be the same on the access point?

  • Comment Link Paul Atreides Saturday, 06 May 2017 22:06 posted by Paul Atreides


    thanks for the prompt reply. Well I disabled the inboard wifi by modifying the
    /boot/config.txt file with this line: dtoverlay=pi3-disable-wifi. Then when I reboot with the usb tplink usb adapter it becomes wlan0 instead of wlan1 since the onboard wifi is completely down.. Without the script or the changes to the interface files it detects my home network and logins in automatically, it only refuses to connect to my home router when the script is enabled, and then it creates a hotspot but still will not issue itself the correct 10.0.x.x address. I may just leave it unable to detect the home router since this will be a mostly standalone pi anyway. I will check the hostapd status.

  • Comment Link Graeme Saturday, 06 May 2017 21:24 posted by Graeme

    Hi Paul, Does it work if you use the onboard wifi just for testing? If so then it will be the usb wifi. If the USB Wifi is running on wlan1 then that may be an issue as all the script and configs use wlan0. check with the command: ip addr ,You would need to change the refernces to wlan0 in the script and config files to wlan1 but i have not done that so can't say how it will work.
    In hotspot mode check the status hostapd; sudo systemctl status -l hostapd

    It may show and error or that it is not using wlan0.
    Not sure what else it could be.

  • Comment Link Paul Atreides Saturday, 06 May 2017 20:40 posted by Paul Atreides

    One more question, I have a couple Pis setup. The first one is running fine. The second will setup as a hotspot but it will not detect my home router. Also when it sets up as a hotspot, it will not assign itself the ip address, it uses a seemingly random 169.254.x.x address. I'm using a usb wireless adapter for better range and I've disabled the on-board wifi, I wonder if that has anything to do with the issues I'm having Any ideas?

  • Comment Link Paul Atreides Friday, 05 May 2017 20:25 posted by Paul Atreides

    Ok, I found out what I did, I made a couple of typos, once again thanks for the excellent guide.

  • Comment Link Graeme Friday, 05 May 2017 20:10 posted by Graeme

    Hi Paul, It sounds like the script is not being started. This could be permissions so redo the chmod command: sudo chmod +x /usr/bin/autohotspot

    also check the status of the script with; sudo systemctl status -l autohotspot
    this will show if it started (Active) and the messages. If it is not Active try to enable it again with; sudo systemctl enable autohotspot
    If did run and didn't find the ssid then it would have created a hotspot so I think it should be one of these. It can also be run manually using; sudo /usr/bin/autohotspot which will print messages as it runs which may give you a clue.

  • Comment Link Paul Atreides Friday, 05 May 2017 19:46 posted by Paul Atreides

    I've followed this tutorial, ( thanks by the way for this!) But I'm getting an error upon reboot. I have no ability to test because it's showing a network interface error when I hover over where the network icon should be it says: "wlan0: Not associated" , can anyone point me to where I made a mistake. Thanks!

  • Comment Link Graeme Friday, 05 May 2017 12:17 posted by Graeme

    Hi goodguy, I don't think SSL is anything to do with SSH thats more to do with online website security. I would check your Android app settings as it might be trying to go online rather than connect to a device on the RPI3hot network. I use Juice on Android (WiFi only Tablet) which can use a few modes such as telnet, but is ssh by default and I have had no issues. The only times I get a warning, is if I use my SD card in a different pi and connect via ssh, it can cause a warning about "Remote Host Identification has Changed" but if you confirm yes and all is ok again.

    A Comment posted by Neil below, which may be the issue:
    "I think I see the same as Ignoto92 on my Nexus 5X. I can't use Juice SSH to connect to

    However I can connect using my laptop - wonder if android is trying to be too clever as it knows there is no internet...

    I disabled data on my mobile connection and then SSH worked."

  • Comment Link goodguy Thursday, 04 May 2017 17:02 posted by goodguy

    Hi Graeme,

    Great tutorial! I was able to set it up on my pi zero w and when I use my mac I can establish an ssh connection with it no sweat. However when I try to connect to the pi with my android, the android is throwing up errors about SSL Exceptions. Any ideas?

  • Comment Link Graeme Tuesday, 02 May 2017 19:41 posted by Graeme

    Hi Tom, Coincidently you can, In Tino's second comment on the "Hotspot Switch" version of the script he makes a change to just checks for the wifi networks that have been setup by searching WPA_Supplicant.conf. So no need to define the ssid in the script. I haven't tested it on multi wifi networks but it works with my 1 network setup, but will be added to the article once checked out.
    The Link is just above the "Removal" header.
    Have a good trip :)

  • Comment Link Tom Monday, 01 May 2017 23:14 posted by Tom

    Hi Graeme,

    Excellent work here - I was wondering though, is it possible to do achieve this without specifying which networks are 'regular' networks?

    As for my project, I plan to take my raspberry pi on the road with me connecting to new networks each time (where available - if they don't have wifi then I'll run it as a hotspot).



  • Comment Link Graeme Friday, 21 April 2017 21:44 posted by Graeme

    Hi Keith, I know there are issues with hostapd and the realteck chips that don't use the nl80211 driver, but I don't know what issues it causes. There is a version of hostapd that has been modified for the rtl8118 chips, see may be worth giving that a go. Could try dropping the driver line altogether in the hostapd.conf file which some online comments suggest.

    Try putting it in hotspot mode on a screen and seeing if 'sudo systemctl status -l hostapd' and see if there are any clues. Other issues people have had is the laptop had the wrong encryption mode, not wpa. Your phone should have been fine though.

    If the wifi icon near the clock is show "associated with RPI3Hot" (with the mouse on it) and you can connect to the RPI3Hot wifi signal with your laptop/phone but fails at the password prompt then the password is wrong (unlikely) or hostapd has failed. Any hostapd issues I have had while putting the script together just caused the hotspot not to get generated.
    Other than trying it with a different dongle, if possible, just to check its a compatibility problem. Hope you get it sorted, sound like a fun project.

  • Comment Link Keith Friday, 21 April 2017 17:49 posted by Keith

    Hi totally out of depth with 'CODE'but have managed to write a script on raspi for a turning pistol target. Want to run it from ssh via laptop in a barn with no wifi or network. Can see the Hotspot on pc&phone etc but after entering passcode returns not able to connect. Have checked and rechecked your writeup but no joy. Going guiddy circles trying to figure whats wrong! No doubt something simple....any ideas where to check? (Raspi 2b with tontec wifi rtll818cus dongle updated driver & hostapd to suit)

  • Comment Link Graeme Wednesday, 12 April 2017 22:42 posted by Graeme

    Hi Willem Me, Thanks for letting me know about the hidden ssids issue. I will be adding your changes to the guide, very helpful. Thank you.

  • Comment Link Willem Me Wednesday, 12 April 2017 15:03 posted by Willem Me

    I have asked to fast, I fixed it myself by changing inside script the loop to loop through macAdresses instead of SSID and also changed variables to work with macAdress. Maybe add this finding as note to the script part for others with hidden ssids, but still thank you. (my edited code: ...
    for macAdress in "${macAdresses[@]}"
    if iw dev wlan0 scan ap-force | grep "$macAdress" > /dev/null
    echo "Not in range, WiFi with MAC:" $macAdress

  • Comment Link Willem Me Wednesday, 12 April 2017 14:20 posted by Willem Me

    Awesome that you made this easy guide! I only have a "small" problem my home ssid is hidden, and it seems the script can't find it. Do you have any suggentions to get this working? Thanks in advance.

  • Comment Link Graeme Monday, 10 April 2017 12:06 posted by Graeme

    Hi Falko, the driver is nl80211 already, did you mean something different? The set-up has been tested on a PiZero W and worked fine as they are the same as Pi3 :)

  • Comment Link Graeme Monday, 10 April 2017 12:01 posted by Graeme

    Hi Tony, thanks for highlighting that. I really should stop making changes so late at night. :)

  • Comment Link falko Sunday, 09 April 2017 22:28 posted by falko

    Hi roboberry

    Had some problem configuring it for pizero w. Found out that in hostapd.conf you need change driver to nl80211 for it to work.

  • Comment Link Tony Sunday, 09 April 2017 19:34 posted by Tony

    The hostapd defaults configuration still has a typo in it. The A is missing in DAEMON_CONF

    It should say:

    I couldn't see my access point after following these instructions, and that was the problem for me. Once I fixed the typo it all worked.

    Thanks for putting this together. Very handy.

  • Comment Link Graeme Sunday, 09 April 2017 10:09 posted by Graeme

    Hi Chris, thanks for highlighting the space issue. The article has been updated with your change. Thank you.

  • Comment Link Chris Friday, 07 April 2017 03:28 posted by Chris

    Great article. Just one issue - my SSID has spaces in, which causes your grep to break. $ssid needs quotes around it to solve this. ie:
    if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null

  • Comment Link Graeme Wednesday, 05 April 2017 20:10 posted by Graeme

    Hi Neil, thanks for the info, I use Juice on a Nexus 7 which is Wifi only, so I don't come across issues like that.

  • Comment Link Neil Wednesday, 05 April 2017 18:02 posted by Neil

    I think I see the same as Ignoto92 on my Nexus 5X. I cna't use Juice SSH to connect to

    However I can connect using my laptop - wonder if android is trying to be too clever as it knows there is no internet...

    I disabled data on my mobile connection and then SSH worked.

  • Comment Link Graeme Monday, 03 April 2017 20:12 posted by Graeme

    Hi Ignoto92, I have tried a few things but not reproducing your issue exactly. Check dnsmasq is started ok, in AP mode enter sudo systemctl -l status dnsmasq and see if that give an error. Do the same for hostapd just to be sure thats ok.
    If i change the /usr/bin/autohotspot file so dnsmasq doesn’t start I can see RPI3hot and attempt to connect but the ip is never given. So just double check the files. Errors I make at times are using a comma instead of a full stop and general typos.
    If no luck your welcome to send me your config files and I will try it out on my pi's, or if you have further questions. admin@{thiswebsite}

  • Comment Link Ignoto92 Monday, 03 April 2017 12:11 posted by Ignoto92

    Hey, I've just did it but I can't connect to my Pi in AP mode, it don't give me ip addresses and devices give me an error 'ip configuration erro'; I think this is dnsmasq, how can I resolve?

  • Comment Link Graeme Sunday, 02 April 2017 19:29 posted by Graeme

    Hi Justin, thanks for that, it should be capitals in older versions as well. :)

  • Comment Link Justin Sunday, 02 April 2017 04:49 posted by Justin

    Thank you for this.

    There is a typo at the end of the Hostapd Configuration section. The instruction is to change the "demon_conf" line, but that should be "DAEMON_CONF". At least that's how it is in the current version of Raspbian (version March 02 2017).

  • Comment Link Graeme Tuesday, 28 March 2017 21:46 posted by Graeme

    Hi Manu, in terminal just check what ssid is being found, your need it on a display for this if using ssh, enter : sudo iw dev wlan0 scan ap-force | grep "ATTUverse01" it should return "SSID : ATTUverse01. if it doesn’t then it doesn’t think that ssid is being broadcast. If it does find it stop hostapd and dnsmasq with sudo systemctl stop hostapd, sudo systemctl stop dnsmasq. Then start wifi with: sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf your wifi should come back. If it doesn’t then check your /etc/wpa_supplicant/wpa_supplicant.conf file has the correct details. Because if the: sudo dhclient -1 wlan0 line doesn’t return "RTNETLINK answers: file exists" then the wifi connection has failed so a hotspot get generated.
    Your welcome to email me if you need this looking into further, happy to get you up and running.

  • Comment Link Manu Monday, 27 March 2017 23:53 posted by Manu

    Hi, got this to work partially on a pi zero with a dongle. The access point is setup fine and I can connect to it. Problem is, even when I put the valid SSID name in the /usr/bin/autohotspot , reboot always results in the hotspot mode - it never connects to my router like it used to.
    I've already reduced the SSID list to just one router and the syntax is ..

    Any suggestions?


  • Comment Link Graeme Monday, 20 March 2017 21:33 posted by Graeme

    Hi John, glad the script is useful to you. If you have an external script updating the wpa_supplicant.conf file it should still work as the file is not changed. Does wpa_supplicant points to a different config file? if so change the path in the autohotspot "wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf" to that location.
    or (a very unsecure option) if your /boot/octopi-wpa-supplicant.txt is your config file change the path to that. Can you give more details on how this part is working.
    The autohotspot file can be run from the boot folder so you can just add the SSIDs as you please. Though make sure if you are using windows the file is not saved in dos text format, use unix format.
    You then need to change the path in the /etc/systemd/system/autohotspot.service file to ExecStart=/boot/autohotspot

    It should be possible to take a list of ssids from a file and use them in the ssid variable. If you need that I can have a look.

    let me know if this helps or you can email me further details.

  • Comment Link Graeme Monday, 20 March 2017 21:12 posted by Graeme

    Hi Jose, so what is happening is your SSID is being detected but your wifi is failing to start, possible because the details in wpa_supplicant.conf are wrong. If the dhclient dosn't detect the wifi has connected it will goto "else". Check your wpa_supplicant.conf file.
    Open terminal and enter: sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf and see what message you get.
    Also just check the wpa_supplicant line in the autohotspot script ends in "> /dev/null 2>&1" i have managed to chop the end of that of a couple of times copying it in. Let me know if you have further issues.

  • Comment Link John McNerney Monday, 20 March 2017 17:43 posted by John McNerney

    Is there any way to make the list of known WiFi networks get copied automatically from a file in the boot directory into the list in /usr/bin/autohotspot ?

    That, coupled with the method of populating wpa_supplicant.conf with networks from a file in the boot directory (as mentioned in my previous comment or as the ) would make it very simple to add known networks by editing an SD card on a computer. There would be no need to remember what files were where or how to get to them (since the boot directory is easily accessible when an SD card is read in a computer).

  • Comment Link Jose Moffa Monday, 20 March 2017 15:12 posted by Jose Moffa

    Hello, nice work with this script, it helped me a lot. But i am having a issue, when the script reaches here:

    'if dhclient -1 wlan0'

    That command returns nothing a then fall on else statement. I tried this script on a RPI with a fresh installation.

  • Comment Link John McNerney Monday, 20 March 2017 03:38 posted by John McNerney

    Thank you SO much for making this available. I'm volunteering with a local elementary school which is using R-Pi's in various projects. Your set up will greatly simplify things for us.

    I do have a question for you, however. Prior to setting up the "Auto WiFi hotspot..." the system we had set up to use a pi to provide wireless access to a 3D printer used to look at the file /boot/octopi-wpa-supplicant.txt for the WiFi configurations. Since the boot directory is the only one that shows up (easily) when plugging the SD card into a computer, it was simple to edit when the SD card via computer when necessary. The information in that file then "magically" appeared in /etc/wpa_supplicant/wpa_supplicant.conf when the Pi was booted up.

    That no longer happens since I set up the auto wifi hotspot. Is there a way to restore that behavior? It was very convenient to be able to access a file easily from a computer to manually enter a wifi set-up - and, since th efile needed to do so was in the boot directory, I didn't need to remember where the various files were.

  • Comment Link Graeme Sunday, 19 March 2017 20:19 posted by Graeme

    Hi Keith, I’m glad you have found it useful. Will post a version soon that can be swapped between both set-ups without rebooting.

  • Comment Link Keith Sunday, 19 March 2017 18:31 posted by Keith

    This worked perfect and was just what I needed. Thank you. I have added some more commands to your script to run stuff when I am away from home and not when I return.

  • Comment Link Graeme Friday, 17 March 2017 19:40 posted by Graeme

    COMMENT DELETED BY MISTAKE: Someone asked about an issue, script works but keeps going to hotspot. Sorry i deleted it not published your comment. Please post again.
    As for issue, check ssid entered correctly for your router in autohotspot example ('myssid')

  • Comment Link Graeme Monday, 13 March 2017 21:42 posted by Graeme

    Hi Osprey, unfortunately not. Some background files used for wifi have to be cleaned up before the hotspot can be started. I will have another go at it soon. I think it would be useful to save rebooting.
    Update: have it working, script emailed to you

  • Comment Link Osprey Monday, 13 March 2017 15:38 posted by Osprey

    Thanks Graeme. If I were to somehow run the startup script every, say, 2 minutes, would I achieve what I am after? The reason I am asking (as opposed to just try it) is that I still have to find out how to make a script run at regular intervals.

  • Comment Link Aden McCusker Saturday, 11 March 2017 06:58 posted by Aden McCusker

    Outstanding! Thank you very much.

  • Comment Link Graeme Wednesday, 08 March 2017 19:24 posted by Graeme

    Hi Osprey, Maybe possible without a reboot, I will have to look into it further. I have just tried a couple of quick changes to the current setup, but the network wifi takes over the hotspot when the router is back in range and messes about with the connection. If I come up with something I will let you know.

  • Comment Link Osprey Wednesday, 08 March 2017 16:04 posted by Osprey

    Thanks for the thoroughly explained tutorial. Works as advertised. I was wondering if there was a way to periodically do the process of deciding whether to work as a hotspot or as a client. I have a situation where my car is started in my garage where it connects to the home wifi. However, I need it to switch to hotspot mode as soon as the car leaves the vicinity of my home and then switch back to client mode (and connect to my home wifi) when I get back home.

  • Comment Link Fi7i Tuesday, 07 March 2017 11:02 posted by Fi7i

    Nice ! Thanks !

  • Comment Link Graeme Wednesday, 01 March 2017 08:28 posted by Graeme

    Hi burksfamily, I take it the pi still connects to the router when ssid is found, just hotspot not working when ssid not found? Is RPI3Hot being broadcast to wifi devices?
    Set a fake ssid and boot to the desktop. check hostapd is running ok with sudo systemctl -l status hostapd, should get a success message. do the same with autohotspot to see if my script went ok. They should give you a clue if something has gone wrong starting the hotspot. Though strange it not working with a restored os.
    also make sure the autohotspot is executable sudo chmod +x /usr/bin/autohotspot as it won't run if that step is not done.
    If still no luck send me an email with details of your setup and whats happening, can send the config files as well, happy to get you up and running. Hopefully you won't need a late night tonight :)

    Solved: issue due to laptop encryption settings

  • Comment Link burksfamly Tuesday, 28 February 2017 16:53 posted by burksfamly

    Great instructions.
    Using on a project that is two months in the making.
    1) Performed SD image of my entire OS.
    2) Performed your instructions and checked.
    3) Worked great at with Filezilla and VNC Viewer over Windows laptop.
    4) Performed test to see if switching between ssid (changed to bogus name), ad-hoc, and ethernet cable directly to home network.
    5) That test work with one iteration.
    6) Now I cannot get ad-hoc back and I have tried various ways...different channel...different address range...still no joy.
    7) RESTORED my image card to original.
    8) Performed same instructions...could not get ad-hoc to work.
    9) RESTORED my image card to orignal and repeated...still could not get it to work.
    10) This took 8 hours (until 2 am last night.
    11) I liked what I saw and it is exactly what I need for my project, but I for the life of me cannot figure out why I cannot get it to work again. I realize this doesn't make sense, but I have nothing else to offer.

    Any ideas...will be trying again tonight and looking for other solutions.

  • Comment Link Matt Monday, 27 February 2017 11:22 posted by Matt

    Many thanks for your easy to follow instructions!

  • Comment Link Graeme Wednesday, 22 February 2017 20:33 posted by Graeme

    Hi mafkaan, thanks again for your previous heads up, a few other bits needed updating as well. Adding internet/network access is not something I need, but I have had interest in it being able to get eth0 access in hotspot mode. So i have actually got that on my list of projects. Got some other projects on the go at the moment but I will look into that afterwards and update the article if it goes well.

  • Comment Link Graeme Wednesday, 22 February 2017 20:18 posted by Graeme

    Hi Stuart, i haven't been able to reproduce your issue, I have changed some bits on hostapd but generally get disassociated. use the command sudo system status -l hostapd this should give you a clue if hostapd is ok. If you have no luck e-mail me the details of your pi and setup and I will see if i can find the issue. admin@ this site

  • Comment Link mafkaan Wednesday, 22 February 2017 10:03 posted by mafkaan

    Hi again.
    The update looks great. very neat
    I was wondering. could you add a paragraph on how to make this forward the internet to the clients when pi is connected to internet by ethernet. It could become a range extender or hotspot when at a hotel or something.

  • Comment Link Stuart Wednesday, 22 February 2017 00:00 posted by Stuart

    Hey, so I followed the instructions here. However, when I go to test the hotspot I get the icon with two screens, but the information given is wlan0: Associated with and then blank, no name given. No signals visible on any wifi devices. I think I'm creating the hotspot but not broadcasting a discoverable name? I've checked in the hostapd.conf file and there's definitely a ssid name there. Any help would be appreciated.

  • Comment Link Graeme Tuesday, 21 February 2017 19:24 posted by Graeme

    Note: All comments below are for the original rc.local version of this hotspot article not the latest version using systemd

  • Comment Link Graeme Monday, 13 February 2017 10:49 posted by Graeme

    Hi Mateusz, as long as you are using a PI3 or AP capable wifi dongle and there is no typo errors it should work fine.
    If you would like to e-mail me details of your set up, OS and the issue I can help you with the setup. But to reverse the changes you need to restore your rc.local file so it is the same as the first section under "Start-up Script" in the article.
    Then in the /etc/network/interfaces file, reverse the changes there. No need to change anything else. On reboot it will connect to the default WiFi settings.

  • Comment Link Mateusz Sunday, 12 February 2017 17:57 posted by Mateusz

    hi, can someone tell me how go back with all settings, because its not working and also i cant connect to my home wifi

  • Comment Link Graeme Friday, 10 February 2017 19:58 posted by Graeme

    hi rober2ce
    the hotspot will be generating because the ssid entered is not available. make sure there is single quote either side 'ssid1'
    for two ssids try a space in-between rather than a comma
    ssids=('ssid1' 'ssid2')
    It seems some things have changed since the script was written. Let me know if you still have problems.

  • Comment Link rober2ce Wednesday, 08 February 2017 05:37 posted by rober2ce

    You guide was quite helpful. I had everything working well but when I tried to add a second ssid it no longer worked. I tried to go back to one ssid but now that no longer works either. Not sure what is going on but the wifi will no longer connect and the hotspot is always on.

  • Comment Link Graeme Monday, 06 February 2017 19:49 posted by Graeme

    Hi John, if you want two wifi connections you will need a wifi dongle attchaed to a pi3 or 2 wifi dongles connected the Pi 1 & 2. You will then set the second wifi up on wlan1 with this hotspot on wlan0. You will need to activate the IP tables for wlan1 as well to route to the internet.
    I havenen't tried a set up like that so don't know exactly what you need to get it working but this script will not go online once activated as a hotspot via ethernet either.
    Also if you have a new raspian image you may have issues as pointed out by mafkaan below.

  • Comment Link john  hewitt Monday, 06 February 2017 14:56 posted by john hewitt

    this is great, will try it. I have been running my Pi as an access point and realVNC server which works great. Will be great to be able todynamically start up the access point from a script.

    My question is normally I plug in my access point to home router to get internet, but there has to be a way to get internet access wirelessly too right? in other words a hotspot for my hotspot. how would one proceed?
    if anyone with ideas could email me too that would be great,

  • Comment Link Graeme Saturday, 21 January 2017 20:40 posted by Graeme

    Hi Alec, if you have been updating an existing Raspian distro with get-apt you should be fine, my ones are all running Pixel and up to date. From Mafkann's comments there looks to be an issue if you use one of the latest Raspbian images. Try: Edit the SSID so it's not your routers and reboot, then run sudo /etc/rc.local from terminal. You can see any messages that is too fast during bootup. Also run hostapd in debug mode and see if that reports and issue as that is most likely the cause.
    sudo hostapd -d /etc/hostapd/hostapd.conf
    I presume you are using a PI3 or suitable Wifi dongle with AP mode.
    Let me know if this doesn’t help and I will look into it further.

  • Comment Link Alec G Friday, 20 January 2017 04:09 posted by Alec G

    Hi there, I followed the tutorial to the letter, and I cannot seem to get the last part. The Pi can connect to my router when it is active, but when I disconnect it to test the creation of the hotspot, the wifi symbol changes to two lines with an X on either side with wlan0 saying that it is not associated. I cannot tell if there is an error I made somewhere, or if it is an error due to me being on the latest update as of now. Any help would be appreciated. Thanks

  • Comment Link Graeme Friday, 13 January 2017 21:01 posted by Graeme

    Hi Mafkann, thanks for the update on iwlist. still working for me on my up to date Pi's, presumable it affects new installs and not rolling updates as my Pi's are. I plan to make a few updates to this process soon so will look into the depreciations. thanks

  • Comment Link mafkaan Thursday, 12 January 2017 08:09 posted by mafkaan

    thanks. made it work
    I had not seen this was an older post so...

    few things I needed to work out. in /etc/rc.local
    ssids=( 'mySSID1','mySSID2' ) had to be space delimeted like this
    ssids=( 'mySSID1' 'mySSID2' )
    I had found out, it was treated as one long string so use spaces around
    The other was 'iwlist' seems to be deprecated. I found with google search. the command had to be 'iw dev wlan scan ap-force' run as superuser
    the lines changed : became
    ssids=( 'mySSID1' 'mySSID2' )
    if iw dev wlan0 scan ap-force | grep $ssid > /dev/null

    Using Jessie ( lite ) from november 2016
    - iw was already setup so no need to go install it

    Hope someone will benefit from this in the future

  • Comment Link Graeme Thursday, 29 December 2016 21:13 posted by Graeme

    Hi Oj, I think your routers password in /etc/wpa_supplicant/wpa_supplicant.conf is not correct. Check the entry for psk="" has the correct password. Also if your routers ssid and password are in /etc/network/interfaces then put a # infront of each line.
    #iface wlan0 inet dhcp
    # wpa-ssid "mySSID"
    # wpa-psk "Router Pasword"

    Hope this helps, let me know if this doesn’t work and I will look into it further. :)

  • Comment Link 0j Wednesday, 28 December 2016 21:51 posted by 0j

    Thank you for such usefull script.
    However I have problem

    However I got a problem to connect back to my home wifi.
    when running rc.local I got respond on "Obtaining IP from DHCP"

  • Comment Link Robert H Friday, 23 December 2016 22:46 posted by Robert H

    If anyone if having trouble with the rc.local script not resolving your AP name, change the following line in rc.local

    ssids=( 'mySSID1','mySSID2' )
    declare -a ssids=( "mySSID1" "mySSID2" )

  • Comment Link Graeme Tuesday, 29 November 2016 19:18 posted by Graeme

    Hi Vishal, glad you have it working, not sure what's going on with that. It worked when it was originally tested. I will have to look into that further.

  • Comment Link Vishal Verma Tuesday, 29 November 2016 02:32 posted by Vishal Verma

    Thanks Graeme for the feedback and resolution. I removed the multiple values from ssids=( 'mySSID1','mySSID2' ); and changed to have only one entry of my wifi router ssid, and it worked perfectly. Appreciate your help. Thanks again. Regards, Vishal

  • Comment Link Graeme Friday, 25 November 2016 22:52 posted by Graeme

    Hi Vishal, the rc.local script is not detecting your SSID as it is written, if it does detected the ssid but network config was wrong it would not go to a hotspot. Do you have more than 1 ssid entered, if so just try 1.
    You can run rc.local on its own with the command sudo /etc/rc.local
    you will see what decision it makes.
    Email me if no luck so I can help further. admin@ this website

  • Comment Link Vishal Verma Friday, 25 November 2016 09:47 posted by Vishal Verma

    Hi, Firstly thanks for the great step by step instructions. I am able to have my pi as an access point and SSH from my laptop to the pi with RPI3Wifi hotspot. But now the pi never connects to the home wifi router. Have changed the setting in rc.local. There is only one entry in wpa_supplicant.conf for the home wifi router. But it never gets that (even after reboot). Request help here. Regards, Vishal

  • Comment Link Graeme Thursday, 24 November 2016 19:09 posted by Graeme

    Hi Dimitar, sorry to hear it didn't work for you, if you want to try again you can e-mail me for support. As for removing it it sounds like you have done what is needed. the IP of is only set in rc.local so if that has been removed then I would check your WiFi settings with the Icon next to the clock. There should be no entry for the RPI3wifi or Or check wpa_Supplicant.conf and make sure only your routers SSID is listed. If it is in your WifI settings then that probably will be why it didn't work. let me know if you need further information.

  • Comment Link Dimitar Sunday, 20 November 2016 23:38 posted by Dimitar

    I tried to follow the instructions, but it did not work for me.
    Now I try to go back before I started but when RPI boots it always comes with the IP address of - can't connect to internet
    If I run sudo dhclient wlan0 - then I get a new ip address and i can connect to internet
    but if I reboot again - it comes back with IP again
    How can I fix that?

    I am using Raspberry Pi 3.
    I removed the script from rc.local
    in/etc/network/interfaces I uncommented
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    I checked that both services are disabled - dnsmasq and hostapd
    I did not revert the changes in/etc/dnsmasq.conf and/etc/default/hostapd

  • Comment Link Dan Saturday, 05 November 2016 18:14 posted by Dan

    I have an issue, that is although my Raspberry Pi 3 has successfully be an auto wifi hotspot thanks to your tutorial, but when i pluged in the ethernet cable, my PI cannot connect to Internet (but still connect to LAN, i still can SSH it over IP Other devices connect to my home network (cellphone, Laptop,etc...) still can connect to the internet, exept my PI
    So please tell me how to fix it?

    Response: In Hotspot mode no internet can be used even with a LAN cable connected. Once the SSID is recognised the internet is available.

  • Comment Link Graeme Monday, 31 October 2016 20:17 posted by Graeme

    Hi JI, i have tried various settings, i think your hotspot is being triggered because your router is not being detected which would be why dnsmasq is always active. The messages "No Wireless interface" is shown when the hotspot is active. can you e-mail me at admin@ this website, with a bit more detail of what is happening, also are you using a Pi3 or using a wifi adapter?
    SOLVED: hostapd password only 4 digits, minimum 8

  • Comment Link Graeme Monday, 31 October 2016 20:06 posted by Graeme

    Hi Ralf, check to make sure the SSID has also changed in the wpa_supplicant.conf file. This is usually where the details will be when they have been changed by the wifi icon by the clock. I have recently added details about the main wifi ssid and password in Step2 just above Start-up Script. let me know if this helps.

  • Comment Link Ralf Monday, 31 October 2016 12:46 posted by Ralf

    Thank you for this tutorial, the hotspot is working fine, but my router isn't recogniced any more. I changed the SSID of my router in the rc.local file and I tried even an other SSID but it's not working or better it's not finding my router. What can I do?

  • Comment Link JI Saturday, 29 October 2016 21:33 posted by JI

    First of all thank you for your quickly answer.
    I tried the "wpa_supplicant -B" line and WiFi still not working. I tried the other two options but enemas status continues being "active (running) since..."
    Another thing is that when I click on the double vertical line it says "No wireless interfaces found"
    Any new suggestions?

  • Comment Link Graeme Friday, 28 October 2016 20:01 posted by Graeme

    Hi Paul, it is possible there is another dns server running such as udhcpd or isc-dhcp-server.
    if you run the command "ip addr" you should get two inet entries under WLAN0. one should be 10.0.05 and the other the same as the wifi icon shows. my one is If is not showing then I believe something else is issuing an ip address.
    use sudo systemctl status udhcpd or isc-dhcp-server to see if they are running.

  • Comment Link Paul Atredies Friday, 28 October 2016 02:41 posted by Paul Atredies

    The tutorial works for setting up the hotspot to logon only to the pi, however it is issuing itself a strange Ipaddress that is not the address, nor can I use the hostname to SSH into the pi. Any suggestions as to why?

  • Comment Link Graeme Thursday, 27 October 2016 22:00 posted by Graeme

    Hi JI, I also have this running on a Pi3 with Pixel. I have managed to replicate your issue. If you copy the long line from rc.local starting with wpa_supplicant -B and paste it into terminal (preceded by sudo) does your wifi come back? it will only be for this session though.
    If systemctl disable is not working then try "sudo update-rc.d dnsmasq disable" and the same for hostapd. If no luck then check the /etc/default/dnsmasq file and change ENABLED=1 to ENABLED=0.

    The issue is dnsmasq is still running at boot so your wifi won't connect to your network.
    let me know if this works or if you still have an issue.

  • Comment Link JI Thursday, 27 October 2016 11:13 posted by JI

    I did all the steps but is not working. It not create a wifi
    I have the new pixel interface and the icon is a double vertical line with two red X on it. When i put the mouse on it I get:

    eth0: link is down
    wlan0: not associated

    I check the hostapd and dnsmasq status and they are active. I redo "sudo systemctl disable dnsmasq" and "sudo systemctl disable hostapd" and they still active (with and without a reboot).

    What can I do to fix it?

  • Comment Link Striker Monday, 17 October 2016 19:32 posted by Striker

    Hello. I did this and now my wifi icon dissapeared. I did everything as in the tutorial so i dont know what could be wrong. Any ideas of what could be or how to undo everything? Thanks

    Hi, if you are getting two screens instead of a Wifi icon, as shown at the bottom of the article, then it is generating a hotspot and not connecting to your router. Make sure the SSID is the same as your router in rc.local, also hostapd maybe running at boot. check this with
    "sudo systemctl status hostapd" and "sudo systemctl status dnsmasq" if there is a green text saying Active (i think) then they are running at boot. redo "sudo systemctl disable dnsmasq" and "sudo systemctl disable hostapd" and try again.
    Are you using a Pi3? to reverse; remove the added script from /etc/rc.local and in the /etc/network/interfaces remove the # from "# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf"
    e-mail me if you have further issues, happy to help get it up and running for you.

  • Comment Link Vijayenthiran Tuesday, 20 September 2016 12:07 posted by Vijayenthiran

    In the sudo nano /etc/hostapd/hostapd.conf

    commenting out driver=nl80211 works for raspberry pi 3.

  • Comment Link Graeme Thursday, 01 September 2016 19:07 posted by Graeme

    Hi Rob, i no expert at networking but i think you need to add a wifi dongle to use Wlan1. Instead of using a static IP are you able to connect via a Host name for your network set up. Then the interfaces setup can be set to manual. I connect to my PI's at home via there host name and the Hotspot IP when out.
    I'm happy to try some static/manual setting on my set up to see what works if need be.

  • Comment Link Rob Thursday, 01 September 2016 00:18 posted by Rob

    This looks really useful, I just seem to be hitting a snag (it's late and it's probably me).
    I've got my Pi set on a static IP address for my home network using the network interfaces file on wlan0. Will changing wlan0 from static to manual mess that up?
    Could I have wlan0 set to static and wlan1 set to manual to get round this?
    Sorry if this is an obvious question.

  • Comment Link Graeme Wednesday, 03 August 2016 20:35 posted by Graeme

    Hi Emanon, the Wifi password is stored in the the WPA_supplicant.conf file, but the wifi connection can be setup normally via the WiFi icon in the top right corner of the desktop. To have it as a preferred connection then add it to the ssids=(...) list in the rc.local file. The pi will broadcast 2 IP's one similar to the one stated and set in the script. Use I don't think the host name is reliable for this but it works fine with the IP.
    For the connection issue; are you using a RPi3 or other model with a WiFi dongle? if using dongle it may not be compatible with AP mode.
    I have just checked out a Pi2 with wifi dongle which did create a hotspot but kept dropping the connection. This was probably because of power issues on the battery as it was fine plugged into the mains.
    If you have no luck then e-mail me to try and sort it out (link in contact us)

  • Comment Link emanon Tuesday, 02 August 2016 01:06 posted by emanon

    thanks for this tutorial! However, by default the machine doesn't connect to the default router (where do I set the password for it, by the way? Is it still the wpa_supplicant file?) and creates a hotspot. I suceed in connecting to it, but I can't ssh the pi (neither by its host name nor by the ip. The IP the hotspot gives me seems to be in a completely different network ( Any ideas?

  • Comment Link Graeme Saturday, 11 June 2016 12:37 posted by Graeme

    hi, it uses an infrastructure Access Point, not a AdHoc connection. The pi doubles as a router so all devices connect to the pi's router (RPI3hot) so they are on the same network and communicate via the router and not directly connected to each other. For a ssh connection with a Tablet both the pi and the tablet are communication via the pi's router, even though there is physically only two devices from a network point of view there are 3.

  • Comment Link Alejandro Saturday, 11 June 2016 05:49 posted by Alejandro

    Hi, one question... This is a kind of Ad-Hoc conection?? I'm looking for that hours and hours and I can't find anything!


Additional information