How to Connect Headless Raspberry Pi to Mobile Hotspot ?

Hemanth Marupudi
6 min readApr 11, 2024

If you’re in a location with no Wi-fi or your Wi-fi provider uses a captive portal to authenticate users, you may want to configure your Pi to use your personal hotspot. In this article I’ll take you through the steps of setting it up.

Photo by Karminski-牙医 on Unsplash

Tools Needed

Before you start you would need the following:

  1. Raspberry Pi : You will also need a constant power supply to the Pi.
  2. Micro SD Card : 8GB is the bare minimum.
  3. Micro SD Card Reader : A Micro SD Card Reader that can be connected to your laptop.
  4. Personal Hotspot

Overview

Accessing the Pi over network with any external monitor or keyboard is headless operation. The steps that are to be followed are:

  1. Downloading Raspberry Pi Imager on a laptop.
  2. Burning the Raspberry Pi OS image to the microSD card with the network config.
  3. Connecting to the Raspberry Pi from your computer.

Step 1: Downloading the Raspberry Pi Imager.

  • Go to https://www.raspberrypi.com/software/ and download the imager that’s built for your OS( I’m on a Mac so I downloaded the MacOS version).
  • Plug the microSD card to your laptop or plug the microSD card to the microSD card reader and plug the reader into your computer.
  • Open the Raspberry Pi Imager application. The interface should look like this.

Step 2: Burning the Raspberry Pi OS image.

  • Click on Choose Device and choose the Raspberry Pi that you own. I own a Pi 4 B.
  • Next, click on Choose OS. Imager would recommend you to download Raspberry Pi OS with Pi Desktop. Pi Desktop is the UI that comes along with the OS image. Since, this is a headless installation, Pi Desktop is essentially of no use. So, scroll down and click Raspberry Pi OS (other) and select Raspberry Pi OS with no Desktop Environment.
  • Click on Choose Storage and select the microSD card or microSD card reader that you plugged into your computer and click next.
  • Click on Edit Settings. A customisation page would open that looks like this.
  • Set the hostname. I’ve set it as raspberrypi, you’re free to set up the name of your choice, but don’t include any upper-case letters or spaces. Note down the hostname, since it’s essential to connect to the Pi in the upcoming steps.
  • Set up a username and password. These credentials would be used to login to the Pi once the setup is complete.
  • For your Personal Hotspot to work properly, its name should not contain spaces, quotation marks, or any special characters. If it does contain any of these characters, on a iPhone, you can change it by going to Settings > General > About > Name. For example, if your iPhone’s name is “H’s iPhone,” change it to “HiPhone”.
  • Enter your Personal Hotspot name in the SSID field and its password in the password field. Select your country( IN for India, GB for Great Britain).
  • Go to the Services pane at the top, enable SSH, and select password authentication. This option would allow you to login to the Pi using the username and password that you’ve setup.
  • Click Save and then click Yes to apply the customisation. You might be asked to enter your computer password in order to make changes to the microSD card. If so, enter your password and click OK. You would see the process of writing and then verifying. This would take a few minutes to complete.
  • Once complete, eject the microSD card or the microSD card reader from your computer.
  • If you’ve reached this far, you successfully burned the Raspberry Pi OS image to a microSD card.

Step 3: Connecting to your Pi.

  • Before you plug the microSD card to the Pi, make sure the Pi is turned off.
  • Plug the microSD card to the microSD card slot at the bottom of the Pi.
  • For iPhone users: Make sure the hotspot has Maximise Compatibility enabled.
  • Turn on your hotspot and make sure it’s in discoverable mode.
  • Power your Raspberry Pi. You might see a red light continuously glowing and a yellow light flashing. The yellow light would flash synchronously with the CPU.
  • In case your Pi does not boot or is unresponsive, try reformatting the microSD and burn a new OS image all over again. It can take as long as 1 minute for the Pi to boot.
  • You should see your Phone getting connected to the Raspberry Pi. On an iPhone, you might see a Green indicator at the top left or Press and hold the wireless section in the top-left corner of the Control Center. You’ll see the number of connected devices below the Personal Hotspot toggle.
  • Important: Connect your laptop to your personal hotspot, if not done already.
  • Open terminal on your Mac Laptop. Command Prompt in case of Windows.
  • To open terminal on a Mac, Command+Space, search Terminal, then hit Enter or click the result.
  • You should see something like this.
  • It’s time to recall your hostname, username, and password that you’ve entered during customization.
  • In the terminal, enter the following command.
ssh username@hostname
  • Replace the username and hostname with the ones that you’ve setup and hit enter.
  • When prompted “Are you sure you want to continue connecting ?”, enter “yes” and click enter.
  • You would be prompted to input the password. Enter the password that you’ve setup. The characters you type will not be displayed on the screen as you enter your password. This is a security mechanism and doesn’t mean that the input isn’t getting captured.
  • Hit enter. You should be logged into the Raspberry Pi if the password and the username is correct.
  • You should see something like this.
  • Any command you run would be running on the Raspberry Pi. To exit from the Pi simply type exit.
  • Before you plan on powering off your Raspberry Pi, it’s important to run the following command to shutdown the Pi.
sudo shutdown
  • With this you’ve successfully setup your Raspberry Pi to connect to your personal Hotspot.
  • Drop a comment if you see any error or unable to connect to the hotspot. Let’s debug together.
  • In the next article, let’s see how to configure a NFS server on a Raspberry Pi.

--

--