loading...
Cover image for Using Raspberry Pi 4 with a power adapter only

Using Raspberry Pi 4 with a power adapter only

limal profile image Łukasz Wolnik Updated on ・3 min read

Story

I ordered my Raspberry Pi 4 one hour after its world premiere on Monday morning from a train to London. I rushed through the https://thepihut.com/ checkout process to ensure that I got my board before they run out of stock and, more importantly, while I still got a 3G signal on my mobile.

I admit I got prompted by the website to buy an HDMI cable which I kindly refused to. After all I also have a Raspberry Pi Zero W which uses a Mini-HDMI port so I was sure I was fully covered and I didn't need yet another HDMI cable.

How wrong I was! The next evening I received the board I noticed my Mini-HDMI is huge compared to the Micro-HDMI connectors that Raspberry Pi 4 use now.

I quickly ordered a Micro-HDMI cable with a next-day delivery but I still wanted to use my newly arrived board now. No, I mean it. NOW!

Headless mode

Luckily I knew there was a way to run the previous version of Raspberry Pi in a headless mode, i.e. without a display, keyboard and mouse. So I thought that maybe it would be possible to install the operating system without connecting it to a display too.

And it was indeed. Here is how I did it. The key part was to skip the NOOBS installer entirely (even with its silentinstall option which didn't work for me) and clone the Raspbian image directly onto the SD card.

All you need to start enjoying your new board with only a power adapter at your disposal is:

  • a Unix-based computer with an SD card reader
  • an SD card

Download Raspbian

Go to https://www.raspberrypi.org/downloads/raspbian/ and start downloading Raspbian Buster Lite zip file.

Prepare your SD card

Insert your SD card to your card reader and run sudo fdisk -l to check its /dev/sdX path.

In my case the SD card reader was at /dev/sde.

Now run an app called gparted and select your device from a drop-down in the top-right.

If your SD card is a brand new one and has not been formatted yet you might need to create a partition table. Simply click DeviceCreate Partition Table… from the main menu.

You can now create a new partition. Just create a single one with the maximum capacity and format it using ext4 filesystem.

Install Raspbian

Extract an 2019-06-20-raspbian-buster-lite.img file from the downloaded Raspbian Buster Lite zip package.

Write the image onto the SD card using below command:

sudo dd if=2019-06-20-raspbian-buster-lite.img of=/dev/sde bs=4M conv=fsync

Enable SSH and setup WiFi

The above dd utility has created two partitions on your SD card: boot and roofs.

Go to the boot “directory in your file browser and create an empty file named ssh. This will enable the SSH protocol for you Raspberry.

Create another file in the same boot path named wpa_supplicant.conf and paste below content to it:

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="Your network name, e.g. BTHub1-123QWE"
    psk="Y0ur_P455w0rd"
    key_mgmt=WPA-PSK
}

Replace country, ssid and psk values to match your WiFi settings.

Grande finale

Your SD card is now ready. Insert it to your Raspberry Pi SD card slot at the bottom of the board.

Connect a power adapter.

Scan your local network (in my case 192.168.1.*) to see what IP address has been assigned to the Raspberry Pi.

sudo nmap -sS -p 22 192.168.1.0/24 | grep "Nmap scan"

You can power off the board to see which of the IP addresses will disappear from the list to identify the Pi.

Connect to the board:

ssh pi@192.168.1.101

The password is raspberry.

You're back in the game! Change your password with passwd and enjoy!

Bonus! Change WiFi after installation

Let's say you have changed your WiFi password but your Raspberry is no longer in a pre-installation mode. Don't worry! It's much easier to change WiFi password for a Raspberry that has an operating system already installed.

Simply eject an SD card from your Raspberry and read it on your PC's card reader. Then locate the /etc/wpa_supplicant/wpa_supplicant.conf file and replace your WiFi settings there. Remember to sudo yourself in order to access and overwrite this file.

Posted on by:

limal profile

Łukasz Wolnik

@limal

React / React Native / JavaScript / IoT developer

Discussion

markdown guide
 

Completely forgot about the new (smaller) micro HDMI ports on the Pi 4. Knew there had to be a way to enable SSH. You saved my life!

Even easier suggestion if you're on a Mac and using BalenaEtcher: just use BalenaEtcher to copy the image over to Micro SD. All you have to do after that is open a terminal window, go to the newly created boot partition on the Micro SD and create the ssh file as described in the article above:

cd /Volumes/boot
touch ssh

And you're done.

Eject the Micro SD (go to finder, click the eject icon), stick the Micro SD in the Pi, and power it up. I'm using a wired ethernet cable, so didn't need to configure WiFi. Once you've figured out the IP address of the Pi, you're good to go.

 

Thanks, Nao! I'm glad it helped you.

Nice write up on a MacOS SD tooling too. Much shorter than mine. Ha!

 

Hello,
ssh.txt to allow SSH? with a .txt extension? Are you sure ?
A change with buster?
friendships
Philippe

 

Hi, Philippe! You're right. The ssh is the right filename. Thanks a lot for this correction.

Now I wonder if I made this mistake just in the article or if ssh.txt got recognised by my Raspberry nevertheless. Anyway it's better to use just ssh.