Enroll Course

100% Online Study
Web & Video Lectures
Earn Diploma Certificate
Access to Job Openings
Access to CV Builder



Online Certification Courses

How To Directly Connect To A Raspberry Pi Without Internet

How to Directly Connect to a Raspberry Pi Without Internet. 

When You Might Use This

Wirelessly connecting to a Raspberry Pi whether it has wireless networking enabled or is connected via Ethernet to your router is certainly more convenient. It’s almost certainly the preferred option, whether you’re at home, at school, or at a maker event.

However, it isn’t ideal for every scenario.

For instance, if you’re using your Pi with the camera module, you may like to take it outside, perhaps to capture some time-lapse photography. Without a wireless network to connect to your Pi via SSH, you’ll need another solution, something that will work via a PC or perhaps a mobile device.

That’s where a direct connection comes in. You have two reliable options here: Ethernet and USB.

Connect to Your Raspberry Pi via Ethernet

The most obvious option for such a connection is via Ethernet cable. All Raspberry Pi computers (save the Pi Zero) have Ethernet ports, making this the option that works best.

For this, you’ll need:

  1. Raspberry Pi (Model B, B+, 2, or 3).
  2. Fresh Raspbian installs (for best results).
  3. Micro USB cable & power supply.
  4. MicroSD card.
  5. An Ethernet cable, with RJ45 connectors at each end.

Standard Ethernet cables are fine here, as the Raspberry Pi can reconfigure the port. In times past, a crossover cable would have been used to connect two computers, but that isn’t necessary here.

You’ll need your Pi setup to accept SSH connections. This isn’t enabled by default, but there are two ways around this.

  1. Boot up with a keyboard and monitor to enable SSH via raspi-config.
  2. Insert the SD card into your PC, browse to /boot, and create an empty file called ssh.

Everything you need to connect to the Pi via SSH is now in place. All you need is the device’s IP address. You can find this by connecting to your router (typically 192.168.0.1, but you’ll need to check the router for the correct IP) or by booting the Pi with a keyboard and monitor and entering

ifconfig

You’ll need to check that the Pi boots correctly before proceeding anyway and that SSH works under normal circumstances. 

Once you’re satisfied the Pi boots and normal wireless activity via your router is satisfactory, shut down the device.

sudo shutdown

Now, connect your Raspberry Pi to your PC with an Ethernet cable.

Say Bonjour!

To get this to work, you’ll need a particular piece of software: Bonjour Zeroconf. This Apple software is a for network device recognition and comes pre-installed in macOS.

With this installed and the direct cable connection with your Pi established, once the little computer is powered on and fully booted, you should be able to connect.

However, patience is advised here. The Pi will first attempt to fetch an IP address from a DHCP server, then when it fails, default to private addressing in the range 169.254.x.x. You may also find it useful to switch to Airplane mode on your PC or laptop to ensure no confusion with other devices on the network. Once the IP is assigned, Bonjour networking establish the .local domain addressing.

After a short while, simply open your SSH tool and connect to raspberrypi.local (or [email protected]), with the default password “raspberry”.

Windows users may need to force the operating system to abandon the router-assigned IP address for this to work, however. This is easy enough to do by opening the Command Prompt and typing:

ipconfig /renew

This will result in a random private IP in the 169.254.x.x range.

Connect Your PC to Raspberry Pi Zero via USB

If you have a Raspberry Pi Zero, you can also connect directly to it via your PC or laptop’s USB port, though this also requires Bonjour on Windows and Mac or avahi-daemon on Linux (avahi-daemon is pre-installed with Ubuntu).

Begin with a fresh copy of Raspbian Jessie or Raspbian Jessie Lite (May 26th, 2016 or later) flashed to your SD card. Before inserting it into your Pi Zero, use your desktop file explorer to find the boot partition, and find config.txt. Open this in a raw text editor (such as Notepad on Windows) and scroll to the bottom. Right at the end, add:

dtoverlay=dwc2

Once you’ve done this, save and close the file, then find and open cmdline.txt. Find “rootwait” and insert this right after:

modules-load=dwc2,g_ether

Ensure this is on the same line, separated only by a space, like this:

Save and close, then eject the microSD card. You can then insert it into your Raspberry Pi Zero and connect it to your PC before booting the device. The connection should be via USB.

Corporate Training for Business Growth and Schools