FAQ

How do I host a Wi-Fi access point with TinyPilot?

Have you been in a situation where you have no access to a network but need to use your TinyPilot? Maybe you're administering a router, and you don't want to get locked out of the network if it reboots.

In situations where you need a dedicated network for your TinyPilot, you can set up your TinyPilot as a Wi-Fi access point without any additional equipment.

As an access point, TinyPilot creates its own Wi-Fi network, allowing you to use a laptop to join the network and access the TinyPilot web interface.

Setting up the access point

First, SSH into your TinyPilot and run the following snippet, replacing the defaults with values you want to use for your access point:

# Choose the name for the Wi-Fi network that TinyPilot will create.
NETWORK_NAME="TinyPilotWiFi"

# Choose a password for TinyPilot's Wi-Fi network.
# The leading space on the next line excludes it from the shell's history.
 NETWORK_PASSWORD="CHOOSE-A-SECURE-PASSWORD"

# Choose IP addresses and ranges to use.
WIFI_AP_IP_ADDRESS='192.168.50.1'
WIFI_AP_CLIENT_IP_RANGE_START='192.168.50.2'
WIFI_AP_CLIENT_IP_RANGE_END='192.168.50.100'

# Enter your country code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
WIFI_COUNTRY="US"

Now, run the following commands to install the required software (hostapd and dnsmasq) and set up the Wi-Fi network and access point:

sudo apt install hostapd dnsmasq --yes && \
  sudo sed --in-place '/interface wlan0/d' /etc/dhcpcd.conf && \
  sudo sed --in-place "/ip_address=${WIFI_AP_IP_ADDRESS}/d" /etc/dhcpcd.conf && \
  sudo sed --in-place '/nohook wpa_supplicant/d' /etc/dhcpcd.conf

. /opt/tinypilot-privileged/scripts/lib/markers.sh
cat << EOF | sudo tee --append /etc/dhcpcd.conf
${MARKER_START}
interface wlan0
static ip_address=${WIFI_AP_IP_ADDRESS}/24
nohook wpa_supplicant
${MARKER_END}
EOF

cat << EOF | sudo tee /etc/hostapd/hostapd.conf
country_code=${WIFI_COUNTRY}
interface=wlan0
ssid=${NETWORK_NAME}
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=${NETWORK_PASSWORD}
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF

cat << EOF | sudo tee /etc/dnsmasq.conf
interface=wlan0
dhcp-range=${WIFI_AP_CLIENT_IP_RANGE_START},${WIFI_AP_CLIENT_IP_RANGE_END},255.255.255.0,24h
domain=wlan
address=/gw.wlan/${WIFI_AP_IP_ADDRESS}
EOF

sudo cp --no-clobber /etc/wpa_supplicant/wpa_supplicant.conf \
  /etc/wpa_supplicant/wpa_supplicant.conf.bak

if ! rfkill list wlan | grep -q "yes"; then
  sudo touch /etc/wpa_supplicant/wlan_enabled
fi

cat << EOF | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
EOF

sudo rfkill unblock wlan && \
  sudo systemctl unmask hostapd dnsmasq && \
  sudo systemctl enable hostapd dnsmasq && \
  sudo systemctl restart hostapd dnsmasq

Once the commands finish successfully, your TinyPilot will advertise itself as a Wi-Fi access point.

Connecting to your TinyPilot Wi-Fi access point

On your client device, open your Wi-Fi network list and select your TinyPilot's access point.

A Wi-Fi network list is open. In the 'other networks' section, 'TinyPilotWiFi' is highlighted as an avilable network. A red arrow points to the hightlighted network

Enter your TinyPilot access point's password and wait for your client to connect. Once connected, you can access your TinyPilot's web interface using https://tinypilot.local.

A TinyPilot web interface is open in a browser, showing the desktop of the PC connected to TinyPilot. The Wi-Fi network list is open on the client machine, showing that it's connected to the TinyPilotWiFi network. A red arrow points to the TinyPilotWiFi network.

Note: Your client device won't have access to the Internet in this configuration.

Removing the access point

To disable the access point, remove the access point configuration and uninstall hostapd and dnsmasq. To do this, SSH into your TinyPilot and run the following snippet:

. /opt/tinypilot-privileged/scripts/lib/markers.sh

dhcpcd_original=()
is_in_marker_section='false'
while IFS= read -r line; do
  if "${is_in_marker_section}" && [[ "${line}" == "${MARKER_END}" ]]; then
    is_in_marker_section='false'
    continue
  fi
  if "${is_in_marker_section}" || [[ "${line}" == "${MARKER_START}" ]]; then
    is_in_marker_section='true'
    continue
  fi
  dhcpcd_original+=("${line}")
done < /etc/dhcpcd.conf

if "${is_in_marker_section}"; then
  echo 'Unclosed marker section' >&2
  exit 1
fi

printf "%s\n" "${dhcpcd_original[@]}" | sudo tee /etc/dhcpcd.conf

sudo mv /etc/wpa_supplicant/wpa_supplicant.conf.bak \
  /etc/wpa_supplicant/wpa_supplicant.conf

if [[ -e /etc/wpa_supplicant/wlan_enabled ]]; then
  sudo rm --force /etc/wpa_supplicant/wlan_enabled
else
  sudo rfkill block wlan
fi

sudo systemctl stop hostapd dnsmasq && \
  sudo rm --force /etc/hostapd/hostapd.conf && \
  sudo rm --force /etc/dnsmasq.conf && \
  sudo apt remove hostapd dnsmasq --yes