Science and technology

Cast your Android machine with a Raspberry Pi

It’s laborious to steer clear of the devices we use every day. In the hustle and bustle of recent life, I need to be certain that I do not miss out on the vital notifications from family and friends that pop up on my cellphone display. I am additionally busy and don’t need to get misplaced in distractions, and choosing up a cellphone and replying to messages tends to be distracting.

To additional complicate issues, there are a whole lot of units on the market. Luckily, most of them, from highly effective workstations to laptops and even the standard Raspberry Pi, can run Linux. Because they run Linux, nearly each resolution I discover for one machine is an ideal match for the others.

One measurement suits all

I wished a strategy to unify the totally different sources of knowledge in my life on no matter display I’m looking at.

I made a decision to resolve this downside by copying my cellphone’s display onto my laptop. In essence, I made my cellphone into an app working alongside all of my different purposes. This helps me hold my consideration on my desktop, prevents me from mentally wandering away, and makes it simpler for me to answer to pressing notifications.

Sound interesting? Here’s how you are able to do it too.

Set up Scrcpy

Scrcpy, generally referred to as Screen Copy, is an open supply screen-mirroring instrument that shows and controls Android units from Linux, Windows, or macOS. Communication between the Android machine and the pc is primarily executed over a USB connection and Android Debug Bridge (ADB). It makes use of TCP/IP and doesn’t require any root entry.

Scrcpy’s setup and configuration are very simple. If you are working Fedora, you possibly can set up it from a Copr repository:

$ sudo dnf copr allow zeno/scrcpy
$ sudo dnf set up scrcpy -y

On Debian or Ubuntu:

$ sudo apt set up scrcpy

You also can compile scrcpy your self. It does not take lengthy to construct, even on a Raspberry Pi, utilizing the directions on scrcpy’s GitHub page.

Set up the cellphone

Once scrcpy is put in, you will need to allow USB debugging and authorize every machine (your Raspberry Pi, laptop computer, or workstation) as a trusted controller.

Open the Settings app in your Android and scroll all the way down to Developer choices. If Developer choices is just not activated, comply with Android’s instructions to unlock it.

Next, allow USB debugging.

Then join the cellphone to your Raspberry Pi or laptop computer (or no matter machine you are utilizing) over USB and set the mode to PTP, if that is an possibility. If your cellphone does not use PTP, set the mode your cellphone makes use of for transferring recordsdata (reasonably than, for example, serving as a tethering or MIDI machine).

Your cellphone will in all probability immediate you to authorize your laptop, recognized by its RSA fingerprint. You solely have to do that the primary time you join; after that, your cellphone will acknowledge and belief your laptop.

Confirm the setting with the lsusb command:

$ lsusb
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.zero root hub
Bus 011 Device 004: ID 046d:c21d Logitech, Inc. F310 Gamepad
Bus 005 Device 005: ID 0951:1666 Kingston Technology DataTraveler G4
Bus 005 Device 004: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 004 Device 001: ID 18d1:4ee6 Google Inc. Nexus/Pixel Device (PTP + debug)
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.zero root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation three.zero root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.zero root hub

Then execute $ scrcpy to launch it with the default settings.

Performance and responsiveness range relying on what machine you are utilizing to manage your cellular. On a Pi, a few of the animations will be sluggish, and even the response typically lags. Scrcpy supplies a straightforward repair for this: Reducing the bitrate and determination of the picture scrcpy shows makes it simpler to your laptop to maintain up. Do this with:

$ scrcpy --bit-rate 1M --max-size 800

Try totally different values to search out the one you favor. To make it simpler to kind, as soon as you’ve got settled on a command, think about making your own Bash alias.

Cut the twine

Once scrcpy is working, you possibly can even join your cellular and your laptop over WiFi. The scrcpy set up course of additionally installs adb, a command to speak with Android units. Scrcpy additionally makes use of this command to speak along with your machine and adb can join over TCP/IP.

To attempt it, be certain that your cellphone is linked over WiFi on the identical wi-fi community your laptop is utilizing. Do NOT disconnect your cellphone from USB but!

Next, get your cellphone’s IP deal with by navigating to Settings and choosing About cellphone. Look on the Status choice to get your deal with. It normally begins with 192.168 or 10.

Alternately, you will get your cellular’s IP deal with utilizing adb:

$ adb shell ip route | awk 'print $9'

To hook up with your machine over WiFi, you will need to allow TCP/IP connections. This, you will need to do by way of the adb command:
$ adb tcpip 5555
Now you possibly can disconnect your cellular from USB.
Whenever you need to join over WiFi, first hook up with the cellular with the command adb join. For occasion, assuming my cellular's IP deal with is 10.1.1.22, the command is:
$ adb join 10.1.1.22:5555

Once it is linked, you possibly can run scrcpy as typical.

Remote management

Scrcpy is simple to make use of. You can attempt it in a terminal or as a GUI application.

Do you employ one other screen-mirroring software? If so, tell us about it within the feedback.

Most Popular

To Top