Introduction: Connect to Raspberry Pi in Headless Mode Using Android Phone Also Configure WiFi
(Image used is Raspberry Pi 3 Model B from https://www.raspberrypi.org)
This Instructables will show you how to connect Raspberry Pi with Android phone also configure WiFi on Raspberry Pi in headless mode i.e. without Keyboard, Mouse and Display . I was struggling to connect my Raspberry Pi to new WiFi due to unavailability of display, then I searched many ways to connect to WiFi and finally was able to connect to WiFi. I found this way as helpful hence sharing here.
Requirement :
1. Raspberry Pi (I have used Raspberry Pi 3 with Raspbian Stretch)
2. Android Phone
3. USB Cable (to Connect Android Phone to Raspberry Pi)
4. Ping & Net Android App
5. JuiceSSH (or any ssh Android App)
Before continuing install Ping & Net and JuiceSSH app from Google Play Store
Step 1: Setting Up Raspberry Pi
Assuming you have Raspbian installed on your Raspberry Pi turn on the power supply of Raspberry Pi and wait for some time (if not please follow process given here and this may need Keyboard, Mouse and Display for 1st time configuration and in that case this Instructable in not needed as you can configure WiFi yourself using GUI / command line here).
Step 2: Connect Raspberry Pi to Phone
- Connect the Android Phone to Raspberry Pi using USB cable.
- Turn On the USB Tethering mode (sharing phone's internet connection e.g. Mobile data / WiFi with other device) in Android Settings
- Goto Settings -> More (Wireless and Networks) -> Tethering & portable hotspot -> Turn On the USB tethering by clicking on toggle button.
Step 3: Get IP Address Using Ping & Net
- Open the Ping & Net App on your phone.
- Click on Network Info you will get the internal ip address assigned to phone in IP neighbors section which will always be looks similar to 192.168.42.*.
- Once you get IP address you can turn off the mobile data if you don't want to share phone's internet with Raspberry Pi.
Step 4: Connecting to Raspberry Pi Using SSH
- Open JuiceSSH on your phone.
- Goto Connections and Add new connection enter the IP address you received in step 3 and save connection
- Connect using recently created connection, it will prompt for the Host verification click on Accept and on next screen it will ask for password. Enter the password you already setup or default password is "raspberry" for user "pi".
Cheers !! You are connected to Raspberry Pi successfully.
Now follow the steps to configure WiFi on your Raspberry Pi and after connecting to WiFi for future use note down the IP address (for wlan) using command:
ifconfig
Now you can use your raspberry Pi using Juice SSH or if you want to use it on your Laptop / Dekstop connected to same WiFi then you can use PuTTY for SSH connection or Remote Desktop Connections on windows with new IP address you noted using ifconfig.
Step 5: Static IP for USB Interface (Optional)
Once you are connected to Raspberry Pi, you can eliminate the step 3 by configuring Static IP for USB interface. In this step we will configure a USB interface to have a static IP, which we will use later to connect to the Raspberry from your Android phone. To do so type the following and press enter:
sudo nano /etc/dhcpcd.conf
Add the following code at the end of file:
interface usb0
static ip_address=192.168.42.42
Once entered above lines in the file press "Ctrl+X", on the next prompt press "Y" and then press "Enter" to save new changes to file.
Thanks !!
Note: This is my first Instructables, please share your feedback with me.