Friday, 30 June 2017 21:17

Raspberry Pi - Auto WiFi Hotspot Switch Internet

Written by 
  • Author Type: Individual

A script to allow the Raspberry Pi to connect to a know wifi router or automatically generate an Internet Hotspot Access Point if no network is found. You can then use SSH or VNC on the move and switch between the hotspot and network without a reboot.

 

Updated Oct 2017: now works with Raspbian Stretch and Raspbian Jessie


When i am home I like to have my Raspberry Pi connected to the home network and the internet but when I am out I would like to connect to it via a hotspot using a tablet, phone or laptop. Usually this means when you are out you can't use your Raspberry Pi. The alternative is set it up as an access point so you can connect to it while you are out but when you are home you have to connect it to you routers ethernet port to use it on your home network.

I wanted a Raspberry Pi that connects to my home networks Wifi when I am at home or generates a wifi Hotspot/Access Point when I am out.

I have done this in a previous script but, for my use, when it is in Hotspot mode it was not able to use the internet if you connect an ethernet cable. Which was fine for me but some users required this feature. So this article is how to setup a Raspberry Pi so it can automatically switch between a network wifi connection and an internet routed hotspot.

If you are using a Raspbery Pi Zero w that has no network port and don't need an internet routed Access Point then you can use the other Hotspot switch script Raspberry Pi - Auto WiFi Hotspot Switch - Direct Connection

If you would just like a permanent hotspot then you can use this guide Raspberry Pi - Hotspot/Access Point dhcpcd method

Aim:

  • When you're home:   On starting the Raspberry Pi it connects to your home routers wifi
  • When you're out: On starting, if any known wifi connection is not found it will generate a hotspot so a direct wifi connection can be made to the Raspberry Pi by a tablet, phone or laptop.
  • While in Hotspot mode:  if an ethernet cable is connected the Raspberry Pi, then it will have internet access along with any wifi device connected to the Hotspot.

Additional Features:

Using a Cron, a timer can be setup so the wifi connection can be regulary checked. It will switch between a wifi router and a hotspot without a reboot depending on the results. This is useful for

  • Raspberry Pi in car entertainment systems
  • If the RPi looses wifi connection in your garden or near your home when using the camera or sensors.
  • You run a script or program at home connected to your router and wish to monitor it while you are out. As a hotspot is generated without a reboot the script/program is not interuppted.

It is also possible to run the script from a GPIO button so you can manually run the script to switch depending on where you are.

 

 Requirements:

This has been tested on Raspbian Jessie and Raspbian Stretch. To see which version you have enter the command lsb_release -a

  • Raspberry Pi 3
  • Raspberry Pi 1,2 with a Wifi Dongle*,
  • Raspberry Pi Zero W and Zero with WiFi Dongle* (internet hotspot not useable as it has no ethernet port. I suggest you use the non internet version of the script Raspberry Pi - Auto WiFi Hotspot Switch - Direct Connection
  • Wifi already configured for your home router

*some WiFi dongles don't work in adhoc mode or don't work with with the nl80211 driver used in this guide for RPi 3 & zero W inbuilt wifi, so you may want to check this first before starting.

This setup has been tested on Raspbian Jessie and Raspbian Stretch using a RPI3, RPI Zero W and a RPI 2 . A connection has been made to the Hotspot using an Android Tablet, Ipad2, Raspberry PI and Windows 10. All worked fine with SSH.

Note: Existing Autohotspot users

If you are currently are using one of my other autohotspot scripts and would like to change it to this setup please read all sections as there are changes to the dnsmasq.conf file, interfaces file, the service file and the autohotspot file.

Note:

Dnsmasq bug: in versions below 2.77 there is a recent bug that may cause the hotspot not to start for some users. This can be resolved by removing the dns-root-data. It may be benificial to do this before you start the rest of the installation as it has been reported that doing it after installation for effected users does not work but you won't know if it is an issue until after the installation is complete.

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.

 

Note about Raspbian Stretch Network Device Names

For Raspbian Stretch there has been changes to how the network drivers are named, called Predictable Network Interface Names,  and may be different for the usual wlan0 and wlan1 for wifi and eth0 for ethernet connections. Though the official Foundation version of Raspbian Stretch seems to be keeping to the old standard names, at least at the time of writing,  this may not always be the case. For this guide I will use wlan0 as the device that is used.  

To check the device name for your setup enter the commmand iw dev and take a note of the "Interface" name. For wifi it should start with wl , replace your device name with any reference to wlan0 in the article, scripts and config files.

 

Step 1:

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

download file here:

interface=wlan0
driver=nl80211
ssid=RPiHotN
hw_mode=g
channel=6
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=1234567890
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

  • The interface will be wlan0
  • The driver nl80211 works with the Raspberry Pi 3 & Zero W 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 elinux.org/RPi_USB_Wi-Fi_Adapters

  • 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

Change:
#DAEMON_CONF=""
to
DAEMON_CONF="/etc/hostapd/hostapd.conf"

Check the DAEMON_OPTS="" is preceded by a #, so is #DAEMON_OPTS=""

And save.

DNSmasq configuration

Next dnsmasq needs to be configured to allow the Rpi to act as a router and issue ip addresses. Open the dnsmasq.conf file with

sudo nano /etc/dnsmasq.conf

Go to the bottom of the file and add the following lines (download here)


#AutoHotspot config
interface=wlan0
no-resolv
bind-dynamic 
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=192.168.50.150,192.168.50.200,255.255.255.0,12h

and the save (ctl & o) and exit (ctrl & x)

Step 2:

Now that hostapd and dnsmasq are configured we now need to make some changes to the interfaces file, the dhcpcd.conf file, setup ip_forwarding and create a service. Once these are done we can then add the autohotspot script.

The interfaces file is not required and should be empty of any network config. Depending which version of Raspbian you have this file may still contain network config.

Enter

sudo nano /etc/network/interfaces

If your file shows more than the standard top 5 lines like this


# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

then make a copy of of your file and then remove any excess lines from the interfaces file.

To make a backup of your interfaces file use the command

sudo cp /etc/network/interfaces /etc/network/interfaces-backup

Next we need to add a line to the dhcpcd.conf file. Open the file with

sudo nano /etc/dhcpcd.conf

then scroll to the bottom of the file and add the line

interface wlan0

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

 ip forwarding

While the RPi is in hotspot mode ip forwarding needs to be on so the internet works when an ethernet cable is attached. The autohotspot script will switch ip forwarding on and off between network mode and hotspot mode but it needs to be on by default for the script to manage ip forwarding.

enter

sudo nano /etc/sysctl.conf

look for the line

# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1

and remove the # so it is

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

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

autohotspot service file

Next we have to create a service which will run the autohotspot script when the Raspberry Pi starts up.

create a new file with the command

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

Then enter the following text or download here


[Unit]
Description=Automatically generates an internet Hotspot when a valid ssid is not in range
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/autohotspotN
[Install]
WantedBy=multi-user.target

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

 

For the service to work it has to be enabled. To do this enter the command

sudo systemctl enable autohotspot.service

Software check:

If your version of Raspbian has been repeatedly upgraded from an old OS image, it is possible that that you don't have the correct wifi tools install. These are installed by default on more recent versions of Raspbian.

to check you have iw installed enter the command

dpkg -s iw

If it is installed the first two lines that shown should be

Package: iw
Status: install ok installed

if not enter the command

sudo apt-get install iw

AutoHotspot Script

This is the main script that will manage your wifi connections between a wifi router and an Access Point.

It will search for any wifi connection that is setup on you Raspberry Pi by using the details found in /etc/wpa_supplicant/wpa_supplicant.conf

If no wifi signal is found for a known SSID then the script will shutdown the wifi network setup and create a Hotspot. If an ethernet cable that allows internet access is connect then the Hotspot will become a full internet access point. Allowing all connected devices to use the Internet. Without an ethernet connect the Raspberry Pi can be accessed from a wifi device using SSH or VNC.

 The script works with SSID's that contain spaces and by entering your routers MAC address it can be used with hidden SSID's.

Hidden SSIDs

If you routers SSID is not broadcast/hidden then find this section in the script

#Enter the Routers Mac Addresses for hidden SSIDs, seperated by spaces ie
#( '11:22:33:44:55:66' 'aa:bb:cc:dd:ee:ff' )
mac=()

and enter you routers MAC address in the brackets of mac=() as shown in the example. Make sure mutiple MAC addresses are seperated by a space.

 

 Creating the autohotspot script:

Create a new file with the command

sudo nano /usr/bin/autohotspotN

and add the autohotspot script. This can be downloaded from here


#!/bin/bash
#version 0.95-N/HS-I

#You may share this script on the condition a reference to RaspberryConnect.com 
#must be included in copies or derivatives of this script. 

#Network Wifi & Hotspot with Internet
#A script to switch between a wifi network and an Internet routed Hotspot
#A Raspberry Pi with a network port required for Internet in hotspot mode.
#Works at startup or with a seperate timer or manually without a reboot
#Other setup required find out more at
#http://www.raspberryconnect.com

wifidev="wlan0" #device name to use. Default is wlan0.
#use the command: iw dev ,to see wifi interface name 

IFSdef=$IFS
cnt=0
#These four lines capture the wifi networks the RPi is setup to use
wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=',' | sed 's/\"/''/g' | sed 's/,$//')
IFS=","
ssids=($wpassid)
IFS=$IFSdef #reset back to defaults


#Note:If you only want to check for certain SSIDs
#Remove the # in in front of ssids=('mySSID1'.... below and put a # infront of all four lines above
# separated by a space, eg ('mySSID1' 'mySSID2')
#ssids=('mySSID1' 'mySSID2' 'mySSID3')

#Enter the Routers Mac Addresses for hidden SSIDs, seperated by spaces ie 
#( '11:22:33:44:55:66' 'aa:bb:cc:dd:ee:ff' ) 
mac=()

ssidsmac=("${ssids[@]}" "${mac[@]}") #combines ssid and MAC for checking

createAdHocNetwork()
{
    ip link set dev "$wifidev" down
    ip a add 192.168.50.5/24 brd + dev "$wifidev"
    ip link set dev "$wifidev" up
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    iptables -A FORWARD -i eth0 -o "$wifidev" -m state --state RELATED,ESTABLISHED -j ACCEPT
    iptables -A FORWARD -i "$wifidev" -o eth0 -j ACCEPT
    systemctl start dnsmasq
    systemctl start hostapd
    echo 1 > /proc/sys/net/ipv4/ip_forward
}

KillHotspot()
{
    echo "Shutting Down Hotspot"
    ip link set dev "$wifidev" down
    systemctl stop hostapd
    systemctl stop dnsmasq
    iptables -D FORWARD -i eth0 -o "$wifidev" -m state --state RELATED,ESTABLISHED -j ACCEPT
    iptables -D FORWARD -i "$wifidev" -o eth0 -j ACCEPT
    echo 0 > /proc/sys/net/ipv4/ip_forward
    ip addr flush dev "$wifidev"
    ip link set dev "$wifidev" up
}

ChkWifiUp()
{
	echo "Checking WiFi connection ok"
        sleep 10 #give time for connection to be completed to router
	if ! wpa_cli -i "$wifidev" status | grep 'ip_address' >/dev/null 2>&1
        then #Failed to connect to wifi (check your wifi settings, password etc)
	       echo 'Wifi failed to connect, falling back to Hotspot.'
               wpa_cli terminate "$wifidev" >/dev/null 2>&1
	       createAdHocNetwork
	fi
}


FindSSID()
{
#Check to see what SSID's and MAC addresses are in range
ssidChk=('NoSSid')
i=0; j=0
until [ $i -eq 1 ] #wait for wifi if busy, usb wifi is slower.
do
        ssidreply=$((iw dev "$wifidev" scan ap-force | egrep "^BSS|SSID:") 2>&1) >/dev/null 2>&1 
	if echo "$ssidreply" | grep "No such device (-19)" >/dev/null 2>&1; then
		NoDevice
	elif ! echo "$ssidreply" | grep "resource busy (-16)"  >/dev/null 2>&1 ;then
		i=1
	elif (($j >= 5)); then #if busy 5 times goto hotspot
                 ssidreply=""
		 i=1
	else #see if device not busy in 2 seconds
		j=$((j = 1))
		sleep 2
	fi
done

for ssid in "${ssidsmac[@]}"
do
     if (echo "$ssidreply" | grep "$ssid") >/dev/null 2>&1
     then
	      #Valid SSid found, passing to script
              ssidChk=$ssid
              return 0
      else
	      #No Network found, NoSSid issued"
              ssidChk='NoSSid'
     fi
done
}

NoDevice()
{
	#if no wifi device,ie usb wifi removed, activate wifi so when it is
	#reconnected wifi to a router will be available
	echo "No wifi device connected"
	wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1
	exit 1
}

FindSSID

#Create Hotspot or connect to valid wifi networks
if [ "$ssidChk" != "NoSSid" ] 
then
       echo 0 > /proc/sys/net/ipv4/ip_forward #deactivate ip forwarding
       if systemctl status hostapd | grep "(running)" >/dev/null 2>&1
       then #hotspot running and ssid in range
              KillHotspot
              echo "Hotspot Deactivated, Bringing Wifi Up"
              wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1
              ChkWifiUp
       elif { wpa_cli -i "$wifidev" status | grep 'ip_address'; } >/dev/null 2>&1
       then #Already connected
              echo "Wifi already connected to a network"
       else #ssid exists and no hotspot running connect to wifi network
              echo "Connecting to the WiFi Network"
              wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1
              ChkWifiUp
       fi
else #ssid or MAC address not in range
       if systemctl status hostapd | grep "(running)" >/dev/null 2>&1
       then
              echo "Hostspot already active"
       elif { wpa_cli status | grep "$wifidev"; } >/dev/null 2>&1
       then
              echo "Cleaning wifi files and Activating Hotspot"
              wpa_cli terminate >/dev/null 2>&1
              ip addr flush "$wifidev"
              ip link set dev "$wifidev" down
              rm -r /var/run/wpa_supplicant >/dev/null 2>&1
              createAdHocNetwork
       else #"No SSID, activating Hotspot"
              createAdHocNetwork
       fi
fi

and save (ctl & o) and exit (ctl & x)

 

For the autohotspotN script to work it needs to be executable. This is done with the command

sudo chmod +x /usr/bin/autohotspotN

Thats it, you are ready to go. Now test that everything is working ok.

Thanks to Willem Me and Tino for there contributions to the development of this script.

Testing the Hotspot

To test that the RPi is setup ok reboot the RPI. When the desktop returns you should have the wifi icon Raspbian Pixel WiFI icon by the clock.
For those setting this up on a headerless RPi then you should see the pi on your routers network. 

To test the hotspot works ok edit the ssid name of your router in the wpa_supplicant file.

enter

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

and add 'off' to the end of your routers ssid. For example:


network={
	ssid="mySSID1"
	psk="myPassword"
	key_mgmt=WPA-PSK
}

change to


network={
	ssid="mySSID1off"
	psk="myPassword"
	key_mgmt=WPA-PSK
}

save (ctrl & o) and close (ctrl & x) the file

Now reboot the Raspberry Pi.

Once the RPi is up and running the wifi icon near the clock should now be two arrows facing opposite directions Raspbian Pixel AP mode icon This means it is an access point. On a Tablet, phone or Laptop scan for wifi signals. You should see one for RPiHotN.

Select this as the wifi signal to connect to. The password is what you setup in the hostapd.conf file. From my example it is 1234567890

android wifi in range list

Local wifi signals in range on Android

For SSH and VNC the connection ip is 192.168.50.5 also if you have setup the Rpi as a webserver use the same ip to see the webpage.

For ssh use ssh This email address is being protected from spambots. You need JavaScript enabled to view it..5

For vnc use 192.168.50.5::5900

If you now connect an ethernet cable to the Raspbery Pi and your router and wait a few seconds the hotspot will allow connected wifi devices to use the internet as well as the RPi.

 Once you are happy the setup is working ok change the wpa_supplicant.conf file back to your routers ssid. From the next reboot the autohotspotN script will manage your wifi connection.

 

Setting up a Timer

If the autohotspotN script is set to be run at set intervals, when you go out of range of your home router it will automatically generate a hotspot and then when you get back in range it will deactivate the hotspot and connect to the routers wifi. If you run a program in the background or use programs like tmux then any software you are running will keep working.

If you have an active ssh or vnc session running when the switch happens it will be lost.

Using a Cron job, tasks can be set off automatically at certain times, dates or intervals. For my use running the script every 5 minutes is fine but this can be changed to your needs. To setup a cron task enter the command

crontab -e

At the bottom of the file enter the command

*/5 * * * * sudo /usr/bin/autohotspotN >/dev/null 2>&1

There is a space after each entry and * except the first *.

The first * position is for minutes. If you want it to check every minute just use * instead of */5

If you want to use hours, say every 2 hours enter it as

* */2 * * * sudo /usr/bin/autohotspotN >/dev/null 2>&1

 Save the cron tab with ctrl & o and close it with ctrl & x

The cron job will automatically start straight away.

Note on Permissions:

by default the pi user does not need to enter a password to use the sudo command. If you are not using the default pi user and while doing this guide you have had to enter a password every time sudo is needed then you will find the the cron job will not work as it wont have permission to run the autohotspotN script.

To fix this you can give the user permission to run the script without a password.
Enter the command

sudo visudo

enter your password
at the bottom of the file add the following line, where username is the user that will be using the script:

username ALL= NOPASSWD: /usr/bin/autohotspotN

Now you will be able to run the script with sudo with the cron.

Thanks to Jim for pointing this out as an issue for some users.

Disable Cron Timer

If you no longer need the timer running edit the cron with

crontab -e

and put a # infront so it is now

#*/5 * * * * sudo /usr/bin/autohotspot

The script will now only work at boot up or if you manually run the autohotspotN script with the command

sudo /usr/bin/autohotspotN

 

Script Removal

If you don't wish to continue using the autohotspotN script then the Raspberry Pi can be revered back to a standard wifi setup with the following steps.

Disable the script with the command

sudo systemctl disable autohotspot

Then disable ip forwarding

sudo nano /etc/sysctl.conf

look for the entry

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

and add a # as follows

# Uncomment the next line to enable packet forwarding for IPv4
# net.ipv4.ip_forward=1

Remove the line "interface wlan0" from the bottom of the /etc/dhcpcd.conf file.

If you had previous config in your interfaces file and made a backup you can restore your original interfaces file with the command

sudo mv /etc/network/interfaces-backup /etc/network/interfaces

Then reboot

The autohotspotN script will no longer have control of you wifi. Dnsmasq and hostapd can be uninstalled if you no longer need them.

 Trouble Shooting

  • If you get no wifi connection or no hotspot and have this icon Network Downthen it is most likley the autohotspotN script is not executable or the service has not been enabled

redo the follow commands

sudo chmod +x /usr/bin/autohotspotN

 

sudo systemctl enable autohotspot.service

 

  • You are in range of your router but it only creates a hotspot. If there is an issue with connecting to the router, such as the password is wrong. The script will fall back to the hotspot so you still have some type of connection. Check your password in the wpa_supplicant.conf file. 
  • You can connect to the hotspot via an Android Phone but you can't get a ssh connection. Some users have found this issue where Android uses there data connection rather than the wifi. Disabeling data has allowed them to use ssh.   
  • If this setup is not working as expected you can check the script for errors by running it manually in a terminal window with the command, sudo /usr/bin/autohotspotN ,you can also check the service status with, sudo systemctl status -l autohotspot ,and if the hotspot has failed try, sudo systemctl status -l hostapd
  • You need to add a new wifi network to the RPi but it is in Hotspot mode so you are unable to scan for new wifi signals. You will need to add the new network to /etc/wpa_supplicant/wpa_supplicant manually. Enter the following details replacing mySSID and myPassword with the correct details. If your router has a hidden SSID/not Broadcast then include the line;  scan_ssid=1
network={
	ssid="mySSID1"
	psk="myPassword"
	key_mgmt=WPA-PSK
}

 

Last modified on Sunday, 19 November 2017 11:05
Google
roboberry

RapberryConnect.com SuperUser.  Contactable via the site admin e-mail in the Contact Us link.

Website: www.raspberryconnect.com

Leave a comment

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

46 comments

  • Comment Link roboberry Friday, 03 November 2017 21:48 posted by roboberry

    Hi Dominaezzz, Thanks for the info. Having a blank wpa_supplicant file is fine, that doesn't cause an issue.

    Your dnsmasq output is fine, the lines you mention, dnsmasq[733]: using nameserver 8.8.8.8#53"
    "dnsmasq[733]: read /etc/hosts - 5 addresses"
    "dnsmasq[734]: Too few arguments."

    are the same as my output. I decided to do a system update this evening and now I am getting issues as well. My laptop will connect to the AP and eventually get internet through the access point but my android tablet won't hold a connection. So may be related to your issue. It was all working fine until the update.
    Check your hostapd status as well to see if that shows an issue.

    I will try and solve my issue which may be related :(

    Report
  • Comment Link Dominaezzz Friday, 03 November 2017 21:05 posted by Dominaezzz

    Everything seems okay.
    The output of dnsmasq status is:
    Nov 02 01:32:38 raspberrypi dnsmasq-dhcp[733]: DHCP, IP range 192.168.50.150 -- 192.168.50.200, lease time 12h
    Nov 02 01:32:38 raspberrypi dnsmasq-dhcp[733]: DHCP, sockets bound exclusively to interface wlan0
    Nov 02 01:32:38 raspberrypi dnsmasq[733]: using nameserver 8.8.8.8#53
    Nov 02 01:32:38 raspberrypi dnsmasq[733]: read /etc/hosts - 5 addresses
    Nov 02 01:32:38 raspberrypi dnsmasq[734]: Too few arguments.
    Nov 02 01:32:38 raspberrypi systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
    Nov 02 01:38:09 raspberrypi dnsmasq-dhcp[733]: DHCPREQUEST(wlan0) 192.168.50.199 e4:a7:a0:45:e3:0e
    Nov 02 01:38:09 raspberrypi dnsmasq-dhcp[733]: DHCPACK(wlan0) 192.168.50.199 e4:a7:a0:45:e3:0e DOMINIC-LAPTOP
    Nov 02 01:46:09 raspberrypi dnsmasq-dhcp[733]: DHCPREQUEST(wlan0) 192.168.50.199 e4:a7:a0:45:e3:0e
    Nov 02 01:46:09 raspberrypi dnsmasq-dhcp[733]: DHCPACK(wlan0) 192.168.50.199 e4:a7:a0:45:e3:0e DOMINIC-LAPTOP

    Report
  • Comment Link Dominaezzz Thursday, 02 November 2017 22:44 posted by Dominaezzz

    Also, I forgot to mention I don't have any wifi networks setup in my wpa_supplicant file because I didn't require it to connect to WiFi at all unless I can make it a wifi extender. I wanted the AP to always show.

    Report
  • Comment Link Dominaezzz Thursday, 02 November 2017 22:36 posted by Dominaezzz

    Hello again,
    Everything seems to be correct.
    The only thing that raised and eyebrow was the status of DNSmasq.
    The service is still active (running) but one of the lines says:

    "dnsmasq[733]: using nameserver 8.8.8.8#53"
    "dnsmasq[733]: read /etc/hosts - 5 addresses"
    "dnsmasq[734]: Too few arguments."

    Report
  • Comment Link Roboberry Thursday, 02 November 2017 09:41 posted by Roboberry

    Hi Dominaezzz, That sounds like DNSmasq is the issue. Have a look at the status with sudo systemctl status dnsmasq and also try sudo journalctl -xe
    This will tell you what is going on with it. During development of this I was getting the error; device not found wlan0.
    Double check that in /etc/dhcpcd.conf that the line added; interface wlan0 was not ending in a s, interfaces. You can guess how I know about that one :) and also double check the /etc/network/interfaces file has no device config in it.

    Let me know if that's not the issue and I will look into it further.

    Report
  • Comment Link Dominaezzz Thursday, 02 November 2017 01:44 posted by Dominaezzz

    Hello,
    Thank you for your post, found it very useful. Have been struggling with this on Stretch for a while now.
    I followed the instructions on a fresh install of Stretch and the access point shows up on my computer but there's no internet connection and I can't ssh into the pi using the IP address.

    Report
  • Comment Link roboberry Monday, 30 October 2017 21:47 posted by roboberry

    Hi Z, you're welcome. Thanks for confirming I didn't mess up the instructions :)

    Report
  • Comment Link Z Monday, 30 October 2017 21:39 posted by Z

    Confirmed it works perfectly. Very well done! This made my day.

    Report
  • Comment Link Z Monday, 30 October 2017 20:52 posted by Z

    Roboberry,

    Wow, thank you so much! I'm going to try it right now. I'll post back with any issues.

    Report
  • Comment Link roboberry Monday, 30 October 2017 20:01 posted by roboberry

    Hi Z, The new script is now available, ran out of time at the weekend. This should get you up and running. Has been working fine for me :)

    Report
  • Comment Link Z Monday, 30 October 2017 04:51 posted by Z

    Hey roboberry,

    Still no joy, that that might be due to the fact that I didn't start with a fresh pi install. Looking forward to the updated tutorial!

    Report
  • Comment Link roboberry Thursday, 26 October 2017 23:31 posted by roboberry

    hi Stephane, Thanks, i'm glad you have found it useful. you must be using Raspbian Jessie as it worked. I plan on updating the article this weekend with some changes so it will work on Raspbian Stretch as well. So if you upgrade to Stretch at some point, you will need to change your setup.

    Report
  • Comment Link Stéphane Thursday, 26 October 2017 09:44 posted by Stéphane

    Fantastic tutorial, thank you so much :) I didn't use the script cause I really just need the hotspot to use the pi as a local server to manage usb midi devices. I've set up an apache server, I just need to connect to the pi in wifi with my phone or tablet and I can interact in ssh or via the web server and some cgi.
    Great job!

    Report
  • Comment Link roboberry Tuesday, 24 October 2017 11:37 posted by roboberry

    Hi Z, I think recent updates to Hostapd and WPA_Supplicant have fixed the issues I was having with Stretch as I have it all working straight after the updates. I have one minor fix to make and will update the articles. Hopefully by the end of the week.
    For your issue on Stretch it sounds like the Hotspot and Wifi are both active, i.e. Hostapd and Dnsmasq are conflicting with wpa_supplicant.
    for this setup to work on stretch remove all the device setup from /etc/network/interfaces so it only shows the default 5 lines at the top.
    then in /etc/dhcpcd.conf at the bottom enter interface wlan0

    Wpa_supplicant is now run with the dhcpcd service but the entry in the interfaces file also runs it.

    If that doesn't help then check back later this week and the full setup will be posted plus the extra tweaks to the scripts.

    Report
  • Comment Link Z Tuesday, 24 October 2017 07:53 posted by Z

    Hey, great work here. As many have mentioned. Stretch is having some issues.

    I followed Popcorn's suggestion and changed a few lines in the code. However I'm still having issues getting the pi to connect to my home wifi. It runs the AP fine, however whenever I turn on my home wifi, the AP disappears like normal, but it has trouble connecting to the home wifi. It was able to reconnect once, however all other times I simply do not see it on my network.

    Anything you can suggest? Looking forward to that update for stretch! Thank you!

    Report
  • Comment Link Randall Burks Thursday, 19 October 2017 04:59 posted by Randall Burks

    Have been successfully using your hotspot this year via SSH for development. I am very interested in the following:
    1: On starting RPi 3B-Pixel, it unconditionally creates hotspot.
    2: While OS is running, if RPi 3B-Pixel detects my Android Phone Hotstpot (which has internet connection), dump your hotspot and connect to my Android Phone Hotspot so that it can get to the internet.
    3: While running, if RPi 3B-Pixel does not detect my Android Phone Hotspot, restart your hotspot.
    4: Would be nice if RPi 3B-Pixel detects my ethernet on my home network with internet, it overrides everything and uses ethernet to get to internet and SSH through ethernet.

    Note that all year I have been using your older version with great success to access via SSH over your hotspot and over ethernet and over WiFi. I just can't figure out how to integrate 1 thru 4 above. Any suggestions? This is very important for my project.

    Thank You
    BurksFamly

    Report
  • Comment Link Roboberry Wednesday, 11 October 2017 19:59 posted by Roboberry

    Hi Valerio, for now you would need Jessie for this script to work as you need. Unfortunately the foundation only offers stretch so unless you have a backup you may find it hard to go back to Jessie.

    Lakshmi,
    I'm hoping to get it working soon as i want it working for myself as well. So hopefully a new script wont be too far away.

    Graeme

    Report
  • Comment Link Lakshmi Narasimman Wednesday, 11 October 2017 16:41 posted by Lakshmi Narasimman

    Is fix ready for raspbian stretch

    Report
  • Comment Link Valerio Tuesday, 10 October 2017 18:57 posted by Valerio

    .... apologies, I just went through the script and noticed a new bit at the end to disable the script :)

    Report
  • Comment Link Valerio Tuesday, 10 October 2017 18:46 posted by Valerio

    Hi Graeme,

    Thanks for your reply! Essentially you're right, it turns out I'm using stretch and not jessie. However the script works in the sense that the RPi does set up its own hotspot and I can VNC into it (and WinSCP files to and from the RPi), which is what I needed it to do.

    However I now need to download some Arduino packages which require an internet connection, and this is where problems begin: I never quite checked whether the RPi could connect to a wifi on top of setting up the hotspot (the wifi at work is a bit of a nightmare for that), but I don't even see available networks on the RPi and just plugging in an ethernet cable makes no difference.

    I have tried the first troubleshooting example, but it didn't make a difference (and I suppose it won't if I'm using Stretch)
    Also, when I run the sudo /usr/bin/autohotspotN command, I get "Hotspot already active"

    ... so long story short, the script does the main thing I wanted it to do (the hotspot), but is there a way to 'temporarily' undo the changes described on this page, get the 'original' connectivity, download what I need and then 're-activate' the hotspot set up? One obvious way would be to follow the changes described here in reverse, but I was wondering if there was a quicker way.

    Also, can I just choose to install Raspbian Jessie as opposed to Raspbian Stretch if I were to re-install the OS? By the way, I'm using a RPi 3 Model B.

    Thanks again! In the meantime I will make the changes to the interfaces file

    Valerio

    Report
  • Comment Link Roboberry Sunday, 08 October 2017 21:10 posted by Roboberry

    Hi Popcorn, im glad you find the script useful. Thanks for the update. I have not had a lot of luck getting this working in Stretch, it didn't help that the call wpa_cli status just returns disconnected which was causing me problems so seeing that it works with wpa_cli -i wlan0 status solves part of my issue thank you.

    I have been working on the other script, direct access, but the suggestion you make are not working. The hotspot just won't come to life even though everything is running and in place.
    Stretch uses the dhcpcd service for network and wpa_supplicant is triggered with that so the /network/interfaces file should be blank. Ifup and ifdown use the interfaces file so wont work if the interfaces file is blank. Also for this script some of the settings in the interfaces file are not required so i updated it a few days ago. Also on stretch the wpa-conf line should be removed otherwise wpa_supplicant will be run twice.

    Is your version of stretch a new image or an upgrade of jessie? If you upgraded some Jessie features are available that may help this work that wont on a new image.

    I was starting to write a new script from scratch but i can have another go at a fix as it works on your setup at least.

    Roboberry

    Report
  • Comment Link Popcorn Sunday, 08 October 2017 00:13 posted by Popcorn

    Hi Jeff,

    I'm using Raspbian Stretch and I was able to fix this intermittent "Failed to connect to non-global ctrl_ifname: (nil) error". For some reason, wpa_supplicant needs a full cycle when switching wifi configurations or else it randomly does that. So I added the following in the autohotspotN script:

    In the function called createAdHocNetwork(), add the following on the line after the opening "{" character

    ifdown wlan0
    ifup wlan0

    And also in the function called KillHotspot() add the following after the line "ip link set dev wlan0 down"

    ifdown wlan0
    ifup wlan0

    I also made one more change because wpa_cli was intermittently reporting a strange interface called "p2p-dev-wlan0" so this was causing a false negative situation that made the script think that the wifi connection couldn't be established causing the hotspot to reactivate.

    Look in the function called ChkWifiUp() and change this line:

    if ! wpa_cli status | grep 'ip_address' >/dev/null 2>&1

    with this line:

    if ! wpa_cli -i wlan0 status | grep 'ip_address' >/dev/null 2>&1

    That explicitly requests the wlan0 interface.

    After those changes, the script is working pretty great on Raspbian Stretch. Thanks for the great script, Roboberry. This has helped me (and apparently many others) immensely. Kudos to you for the hard and detailed work!

    Report
  • Comment Link Roboberry Friday, 06 October 2017 20:23 posted by Roboberry

    Hi Valerio, firstly I have made a change to the interfaces file. I thought I had done this weeks ago but clearly not. So can you also change your interface file, not that it will have caused your issue it's just is no longer required.

    The two lines with a cross means your wifi is down, which is usually because of configuration issues. You say "it worked beautifully" so does this mean it was working at some point, both network wifi and hotspot?

    Have you tried the first example in the trouble shooting section at the bottom of the guide?

    also if you open a terminal window and enter sudo /usr/bin/autohotspotN what happens?

    and also just to confirm did you enter the commend in the red text, lsb_release -a ,and did it show the name Jessie? if it didn't show Jessie but showed Stretch then this script won't work for you. I'm still looking into a solution for Stretch but I think it will need a new script.
    Let me know how you get on and I will look into the issue further.

    Graeme

    Report
  • Comment Link Valerio Friday, 06 October 2017 11:55 posted by Valerio

    Hello,

    First and foremost thanks for the scripts and instructions - it works beautifully. However I now don't seem able to connect to the internet via ethernet cable anymore, and I also see the icon with the two parallel lines and the red crosses. Any tips?
    I am new to RPi, so apologies if it's very obvious.

    Thanks,

    Valerio

    Report
  • Comment Link Graeme Sunday, 24 September 2017 09:03 posted by Graeme

    Hi Jeff

    It looks like you are using Raspbian Stretch. The script currently is not working on stretch due to changes in the network setup. Works fine on Jessie

    I'm working on a fix but it is unstable at the moment.

    Report
  • Comment Link Jeff Hagedorn Sunday, 24 September 2017 03:08 posted by Jeff Hagedorn

    $ sudo wpa_cli status
    Failed to connect to non-global ctrl_ifname: (nil) error: No such file or directory

    On a RPi-ZeroW, so ChkWifiUp :
    if ! wpa_cli status | grep 'ip_address' >/dev/null 2>&1

    Will always fail.. :(

    Report
  • Comment Link Graeme Friday, 08 September 2017 09:48 posted by Graeme

    Hi Jon, the wifi network should be available before the desktop comes up, but that is a bit slow.
    With wpa_cli checking for ssid you will get true even if the connection has not been made as the ssid will be broadcast. The ip_address check is used because that isn't available until a valid connection to the router has been made. If no ip_address line appears in 10 seconds, or in your case 60 seconds, then it falls back to a hotspot. Using the ssid check will not cause it to fall back to the hotspot if a connection to the router is not successful. This solves the issue if a wifi password is wrong the router connection fails so no IP is issued. The script gives control back to the hotspot.

    Not sure about wpa_cli using the 50.5 ip while scanning. I It should be as long as wlan0 is up it should be able to see SSIDs, Mac addresses and react regardless of IP.
    Check that you haven't got both the hotspot and network active as network will take priority.
    check sudo systemctl status hostapd and sudo systemctl status dnsmasq. These should be inactive dead if wifi network is active. If they are "Active" the wpa_cli should show "Failed to connect to non-global....." if you get a response then there is an issue in the script as they both shouldn't be up at the same time.

    Report
  • Comment Link Jon Wagner Friday, 08 September 2017 01:14 posted by Jon Wagner

    Hello again.
    Update / correction on my previous message.
    I ran into more issues I have them resolved and have all now running with the interfaces section commented out.
    1) When trying to connect to a hidden network, my Pi takes a long time. Connection 40 seconds after desktop comes up. Solved by replacing sleep 10 with sleep 60.
    2) Script would no longer start AP. wpa_cli shows status "Scanning" with the 50.5 ip address. The test "wpa_cli status | grep "ip_address" is always true. I don't understand why this started happening after my initial tests. Fixed with changing from grep "ip_address" to grep "ssid".

    I have not tried if commenting the interfaces file resolved the above problems.

    Report
  • Comment Link Graeme Thursday, 07 September 2017 20:22 posted by Graeme

    Hi Jon, ok thats a bit odd, my interfaces file looks like this now

    auto lo wlan0
    iface lo inet loopback

    iface eth0 inet manual

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

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

    and so far seems to be working fine with no mods to anything else.

    Couple of suggestions for what you are doing that may be of use, either strip out the first part of the the first part of the main IF section and keep the bit within Else and the bottom, not including ELSE. easier option is duplicate autohotspotN and rename to autohotspotN2.
    Change the wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf line so wpa_supplicant.conf is wpa_supplicant2.conf.
    create a blank file as wpa_supplicant2.conf in the same path. when signal is high run the new autohotspotN2 file. No wifi will be found and it will go to a hotspot. Then you can still run the original autohotspotN to go back to wifi if needed.

    Yes I will be updating this to work with Stretch soon as I will need it work with it as well before I upgrade myself.

    Report
  • Comment Link Jon Wagner Thursday, 07 September 2017 18:26 posted by Jon Wagner

    Hi Graeme
    I commented out the the static section in the interface file. AP works fine but Pi no longer connects to home WiFi. Also tried with un-comment the iface and wpa_conf lines. Same result. And finally removed the wlan0 from the auto line. Again no connection to home WiFi. I can work with script as-is, so no need to do any further work.
    I want to expand the script to read a digital input and on high force AP even if home WiFi in range. Will let you know that worked.
    P.S. Do you plan to get this working on Raspbian Stretch?

    Report
  • Comment Link Graeme Wednesday, 06 September 2017 22:45 posted by Graeme

    Hi Jon, I made the hotspot ip static in the network interfaces as there was an issue using Ethernet in hotspot mode to get internet access of which that resolved the issue. The Hotspot IP being active in Network mode has had no issues in my experience, the routers issued ip is used. VNC reports the hotspot ip but will connect using the routers issued ip.
    A secondary Ethernet issue was resolved, which may have been the real cause, so the iface wlan0 inet static section in the interfaces is probably not required. I have briefly tested it and seems to be working but not enough to make an update to the process yet. If you comment out that section in the interfaces file and test it you should find that it still works ok but i can't confirm that yet.
    Though this is being written on a pi in hotspot mode through an Ethernet connection :)

    Report
  • Comment Link Jon Wagner Wednesday, 06 September 2017 01:38 posted by Jon Wagner

    Hello Graeme. Great functionality. All works as intended. I need some added functionality so I want to understand the script. My question is about the 'wpa_cli status' command. After running the script the RasPi is connected to my (hidden) home network. The wpa_cli status shows correct bssid and ssid. However the ip_address shows 192.168.50.5, the address of the access point.
    Why? What impact may that have?

    Report
  • Comment Link Graeme Thursday, 31 August 2017 20:46 posted by Graeme

    Hi Andreas, If you can't see the ssid being broadcast then hostapd is the issue. check the status with sudo systemctl status -l hostapd see if there are any errors as it sounds like it fails to start.

    The autohotspot service only runs once at boot up so to run the script again just use sudo /usr/bin/autohotspoN
    After it fails as boot can you run the above line and let me know what feedback it gives and what happens and I will look into it further.

    Report
  • Comment Link Andreas Wednesday, 30 August 2017 23:05 posted by Andreas

    Hello, I followed the instructions on a RPi 3 running Raspbian Jessie, connected to my router via ethernet cable.

    When testing the hotspot (by altering the router ssid in "wpa_supplicant.conf") I can ssh into the Pi by using the ethernet interface's ip. Running ifconfig, I see that wlan0 is up and has indeed taken ip 192.168.50.5. Also, checking "sudo systemctl status autohotspot.service" I see the service is running.However, I cannot see the hotspot ssid in my laptop or phone wifi.

    I managed to get it to work by stopping the service, ifdown-ing wlan0 and running the script manually. However, if I reboot, the same thing happens (basically, nothing). Any suggestions on what to do?

    Report
  • Comment Link Graeme Sunday, 27 August 2017 13:40 posted by Graeme

    Hi Zack, sorry for slow response,
    The password connect to the wifi hotspot is the one in hosapd.conf file, 1234567890 by defaults. Are you are using a wifi dongle? make sure it can do access point mode. If it doesn't it will be the issue.

    For my pi3 it will connect with a dynamic ip to my router but the hotspot needs to be static. The static ip is listed on the pi but always uses a dynamic ip for me

    Report
  • Comment Link Zack Tuesday, 22 August 2017 05:26 posted by Zack

    Hi - terrific script and tutorial. Many thanks.

    Running into two issues.
    #1: Can see the hotspot in wifi networks but keeps saying password is incorrect. I confirmed it many times.


    #2: Instead of a static IP when the pi connects to my wifi network, can it just get and use a dynamic IP?

    Report
  • Comment Link Graeme Friday, 11 August 2017 14:05 posted by Graeme

    Hi ahasbini, During development of the script, I tried various combinations between setting the details in the script and in the interfaces file. This setup was the most stable setup to switch modes with. In network mode the ip is from the router, though the static ip is listed, and Ethernet routing works in hotspot mode.

    ipconfig is depreciated so not an option, ip is used now.

    The script is stable and working fine for me but I do plan on doing additional work on the script so I will look at it again then, as I need to finish a different project first.
    Thanks for your comment :)

    Report
  • Comment Link ahasbini Thursday, 10 August 2017 20:59 posted by ahasbini

    Hey Graeme,

    Thanks for the post, was looking for that recently and was glad to find one.

    I have a question though, I see that the wlan0 is being set to a static ip within the interfaces file, meaning on boot it will be the static ip automatically. I think it might not be necessary as I tried reading the script and see that if it is setting the IP while switching. Could you explain a bit on why that is needed? The reason why I am asking is because I once got RPi3 to hotspot an ethernet internet connection, and had to set the IP just by using ifconfig.

    Here's the link: http://elinux.org/RPI-Wireless-Hotspot

    It states that if you want things automatic upon boot then alter the interfaces file, if not just use ifconfig to statically set the ip address of wlan0.

    Looking forward,
    Thanks :)

    Report
  • Comment Link Graeme Tuesday, 01 August 2017 20:52 posted by Graeme

    Hi Jogi, I have run my pi through a few swaps between network and hotspot and am not able to replicate your issue. Is this still an issue after a reboot?
    This issue seems to be due to dns cache which is not available as standard. Can you see if you have nscd installed, in terminal enter sudo dpkg -s nscd it should say it is not installed. If it is installed that is probably your issue.

    You can also make sure that the dnsmasq.conf file exactly matches the one in the article.
    While in wifi mode enter sudo systemctl status -l dnsmasq it should say it is Active: inactive (dead)

    If it is still active try disabling it again with sudo systemctl disable dnsmasq

    let me know if this helps. If not send me a few more details about what happens, is it an issue if you reboot between modes rather than run the autohotspot script, are you using a PI3, do you connect a LAN cable in hotspot mode. Hopefully we can find the issue.

    Report
  • Comment Link Jogi Tuesday, 01 August 2017 14:01 posted by Jogi

    Thanks for that great example.

    I face the following issue. The transition from Wifi into Hotspotmode works perfectly, but when I try to switch back (running the automode script again with a valid SSID) the networ connection is established and everything looks fine but when I try to access a webpage via the browser I receive the following error code ERR_NAME_Resolution_Failed.

    Report
  • Comment Link Graeme Sunday, 30 July 2017 20:11 posted by Graeme

    Hi Ojas, I would guess if you can't enable it then the file name is wrong of it is not in the correct folder. what message are you getting when you try to enable it?
    firstly double check the file exist in the correct location. in terminal enter ls /etc/systemd/system/ you should see autohotspot.service listed. if it is check the spelling if it is not then just create the file again from the guide.

    If autohotspot.service does exist but sudo systemctl enable autohotspot.service is not working then double check the content of the file is ok.

    enableing it means it will start at boot up. you can run the service manually and see if you get any issues. Enter sudo systemctl start autohotspot
    then enter sudo systemctl status -l autohotspot it should give you details of the issue.

    If no luck let me know the details of what is happening and I will look into it further.

    Report
  • Comment Link Ojas Sunday, 30 July 2017 11:03 posted by Ojas

    Hello............ thanks for this great tutorial.
    But I am not able to ebable the autohotspot.service file on my raspberry pi 3. What should I do?
    Please help me.

    Report
  • Comment Link Graeme Monday, 24 July 2017 00:37 posted by Graeme

    Hi Logan, I presume you are connecting on Hotspot mode. Which it will use 192.168.50.5::5900 but it looks like your VNC is configured to use ::5902. You can see which port it is set to in the connection settings on real vnc on the pi.
    I have just connected my self using real vnc viewer on a android tablet. My one is setup for ::5900 or :0 so connected fine after a reboot so, im not getting an issue at reboot.
    What I have noticed though is when the Pi is connected to the network the Real VNC window show ip address 192.168.50.5 which is wrong. It should be the ip your router issues. in my case 192.168.0.26 and port 5900.

    I think you are getting blank screen because the port has changed, every time you run vncserver it opens a new channel. If the old channel has closed then you won't be able to connect to it.
    I did run vncserver 3 times and got 3 new channels but was still able to connect to ::0 as it didn’t close. At bootup the channel should be ::0 (::5900) so that should be the one to use

    When you are connected to a router use the ip shown in the Real VNC window under "other ways to connect" that is from your router and not 192.168.50.5

    When you are in hotspot mode use 192.168.50.5

    let me know how you get on.

    Report
  • Comment Link Logan Sunday, 23 July 2017 17:58 posted by Logan

    For the record I have VNC configured through raspi-config to be enabled at start.

    When I try to VNC into my Pi using the provided IP above (192.168.50.5::5900) it only shows a black screen and white cursor. Im using RealVNC that comes with Pixel and Im using VNC Viewer on my android device.

    However if I run the command vncserver it provides with a different IP address that looks like this 192.XXX.X.X:2. If I then add that IP to my VNC viewer I can see the desktop and control the Pi. However if I reboot and try to connect again to the VNC viewer I get the error about failed port communication. Somthing like "the port on which the computer is listening for a connection could not be contacted".

    When that occurs, if I run the command vncserver again, I am able to connect but not with the IP provided above, only from the one provided by vncserver command. I suppose as a work around I could write a script that runs vncserver after boot but I thought I was already doing that by having it configured to start on boot through raspi-config.

    More pressing, why am I getting the black screen with white cursor. I am also configured to boot to desktop and be logged in. Any thoughts?

    Report
  • Comment Link Graeme Thursday, 20 July 2017 19:49 posted by Graeme

    Hi manny, I wouldn't like to say if you can or can't without trying. But in principal I would think yes. In hotspot mode you can have a device connected via ssh and another connected via VNC. So server client setups work. You will also be able to control kodi through the web server set-up in hotspot mode.


    If you try it out I would be interested to know how you get on.

    Report
  • Comment Link manny Thursday, 20 July 2017 03:45 posted by manny

    Is it possible to use Kodi installed on Raspbian Jessie while running the RPI3 in hotspot mode so that one can control playback and use the pi as a DLNA media renderer over the same wifi from another device connected to the pi? I'm trying to eliminate a router in my car setup and use the pi as a media server and DLNA DMR while also being the router.

    Report

Additional information