DEV Community

loading...
Cover image for Setup a Raspberry Pi without Laptop

Setup a Raspberry Pi without Laptop

Nico Braun
I travel the galaxy with my blue towel.
Updated on ・3 min read

Sometimes we find ourself in a situation where we need to setup a Raspberry Pi but have no PC or Laptop available. Luckily, there is a way to do the complete setup with only an android phone.

Prerequisites

To follow along you need an android phone and the below listed apps installed. You also need of course the pi and a sd card.

Material

Android Apps

Flash SD Card

Insert the SD Card into a android phone and use the Raspi Card imager to create the image.

Select the Raspbian lite version which does not include a GUI. Also check the Wi-Fi and headless box. With this setup the PI behaves like a server instead of a Desktop PC.

Phone Screen: Card imager config menu showing headless and Wi-Fi boxes check as well as the Raspbian lite 32bit image

! Important: create a wpa_supplicant.conf at the root of the SD Card. For more info see this question on Raspberry Pi Stack Exchange.

This makes the PI connect to the specified router on boot up. That way we can connect over SSH to the device when we are connected to the same router.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=«your_ISO-3166-1_two-letter_country_code»

network={
    ssid="«your_SSID»"
    psk="«your_PSK»"
    key_mgmt=WPA-PSK
}
Enter fullscreen mode Exit fullscreen mode

Find your Country Code.

To create and edit the file I have used QuickEdit Text Editor.

Boot & Find Device

Eject the card from phone and insert into it into Raspberry Pis card slot. Power the PI and wait several minutes until the first boot is completed.

Use Fing to find the IP address of the device. You need to connect with your phone to the same Wi-Fi router as you have configured in the wpa_supplicant.conf file.
Fing will list all devices that are connected to the router. once the PI has booted and connected, it will show in Fing.

Phone screen: Fing discovering pi at address 192.168.1.41

Connect to Device

The Device is now ready to accept ssh connection. You can use any ssh client such as Termius to establish the connection.

The IP address will be the one you have found with Fing. The default user is pi and the default password is raspberry.

# default pw is raspberry
ssh pi@192.168.1.41
Enter fullscreen mode Exit fullscreen mode

Configure Device

First, change the default password, upgrade the system and reboot the device.

# change the default password
sudo raspi-config
# upgrade system & reboot
sudo apt update && apt full-upgrade
sudo shutdown -h now
Enter fullscreen mode Exit fullscreen mode

Wait some time and re-plug the Pi to boot again and finish the configuration.

# allow more data transfer over wlan interface
# 1500 is the same for eth0
sudo ifconfig wlan0 mtu 1500 up

# install system packages
sudo apt install \
    arduino \
    python3-pip

# install docker
curl -fsSL https://get.docker.com | bash

# install some python modules
python3 -m pip install --user \
    RPi.GPIO \
    gpiozero \
    docker-compose \
    s3cmd \
    ansible

# install arduino cli
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh \
    | BINDIR=~/.local/bin sh
Enter fullscreen mode Exit fullscreen mode

Wrapping Up

The Device is now configured and ready to be used over the local network. From here the possibilities are endless.

If you are planning to use this outside of your private network, you should take additional security measurements.

Have fun hacking.

Discussion (0)