Using PiHelper to monitor and manage Raspberry Pis

Sha Qian
The Startup
Published in
7 min readMar 18, 2020

PiHelper is an iOS app that can monitor and manage Raspberry Pi or similar Linux machines.

This guide will help you get started and get the most out of PiHelper.

Why the app reads clipboard:
In TERM, above the keyboard and under ESC button, there’s a clipboard-like (paste) button. When user taps on the button, the app reads the data in clipboard and paste it to the shell. It is useful when you need to create or edit a file. The app does NOT use the data anywhere else.

Overview

The 5 main screens of the app

From left to right, the screens are

  • Main screen: where you can have an overview of all machines, add/delete a machine, and change settings of the app.
  • Dashboard screen: where you can check the real-time status of a machine, run custom commands, and go to GPIO, Terminal and SFTP screens.
  • GPIO screen: shows GPIO status and lets you manage the pins.
  • Terminal screen: a simple SSH client.
  • SFTP screen: a simple SFTP client.

Now let’s take a closer look at each screen and their functionalities.

Main screen

Add a connection

When you open the app for the first time, there’s nothing on the main screen but an Add connection button.

Tap the button to create a new connection

To create a connection to a machine, the following information is needed:

  • Connection name: Any name that can help you identify this machine.
  • Host: An IP address (i.e. 10.0.0.1) or a host name (i.e. testmypi.com).
  • Port: The port on which SSH is listening. By default, it’s 22.
  • Password or Private key: The authentication method. You can select either one of them.
  • Username: The username of the SSH user. Used in both Password and Private key authentication.
  • Password: The password of the SSH user. Used only in Password authentication.
  • Private key: The private key used by the SSH user. Used only in Private key authentication.
  • Passphrase: Optional. Used only when the private key is protected by a passphrase.
  • Sudo password: Optional. Used only by Reboot and Halt button.

For private key authentication, here’s an example of how the key should look like. Note the app is tested with RSA keys only.

There are 2 buttons at the bottom of the screen.

  • Test connection: Test the connection to the machine. The result will pop up from the bottom.

Note that connection error usually indicates an issue with the machine or network, while authentication error means when connection is established but the credentials (username, password or key) are wrong.

  • Save: Save the connection and go back to main screen.

Once you setup the connections, the app will automatically connect to all machines and show their status (CPU, memory and disk usage) on the main screen. The status is refreshed every 10 seconds.

Edit or delete a connection

Tap the button to delete a connection
Tap the button to edit a connection

Reboot or halt a machine

Tap the button then select Reboot or Halt

Reorder the connections

Tap the right button on header bar

You can sort the connection by the following property in ascending or descending order:

  • Creation time
  • Connection Name
  • Host

Change settings of the app

Tap the left button on header bar
  • Language: English, Chinese, Japanese or Russian
  • Temperature scale: Celsius or Fahrenheit
  • Remove Ads: Pay $1 to support the app
  • Restore purchase: Restore your previous purchase
  • Report issue: Email to pihelper@outlook.com to report issue
  • Write review: Review the app on App Store

Dashboard screen

The charts and graphs on Dashboard screen are updated every 5 seconds. Refer to the last section of this article for the commands used by the app to get the data.

CPU and Memory chart

Shows the overall CPU and memory usage

Top CPU process

Shows the 5 processes with top CPU usage

Storage usage

Shows used and free disk space

Temperature

CPU and GPU temperature

Note the scale (°C or °F) can be changed in settings on main screen.

Custom commands

Tap the left button on header bar

In the commands screen, you can setup up to 15 custom commands.

The saved commands are listed in the dropdown menu.

When you tap a custom commands, wait for a few seconds and let it complete. The app will show the result of the command: the output if there’s any, success or failure if there’s no output.

Go to other screens

These buttons navigate you to other screens.

GPIO screen

This screen shows the GPIO status. You can tap the OUT/IN or 0/1 button under MODE or V column to change the input/output of a pin.

In protected mode, you will be prompted to confirm each change you make.

Disable protected mode

Tap the left button on header bar
Confirm if you want to make changes without confirmation

Terminal screen

The terminal is a simple SSH client. You can run commands and see the output in real-time.

One caveat is that the terminal is not stable (causes crashes) when network is slow or blips. If you use SSH extensively, I recommend to get a specialized app like Termius.

SFTP screen

The SFTP client by default goes to the home directory of the SSH user. You can navigate through the file system, and perform basic operations like delete, upload or download.

Go to parent directory

Tap the button to go to parent directory

Refresh the directory

Tap the button to refresh the current directory

Filter the files

Tap this button to open the filters

You can sort the files and directories by the following property in ascending or descending order:

  • Name
  • Size
  • Last modified time

Also you can choose to list all/files only/directories only, toggle hidden files, or search for a file/directory name.

Create folder or upload file

Tap the button then select Create folder or Upload file

Delete or rename directory

Swipe left on the directory then tap delete or edit button

Delete, rename or download file

Swipe left on the file then tap delete, edit or download button

Underlying commands

Here are the commands used by the app to get data from the machine.

If any of the chart or graph shows no data, you can run the corresponding command manually to troubleshoot the issue.

CPU chart

CPU=`top -bn2 -d 1 | grep 'Cpu(s)' | awk '{print $2+$4}' | tail -n1`;echo 'cpu:'$CPU

Expected output:

cpu:0.9

Memory chart

TOT=`cat /proc/meminfo | grep MemTotal: | awk ‘{print $2}’`;USED=`cat /proc/meminfo | grep Active: | awk ‘{print $2}’`;USEDPERC=$[$USED * 100 / $TOT];echo ‘mem:’$USEDPERC

Expected output:

mem:13

Disk usage

STORUSED=`df --output=used / | awk 'END {print $1}'`;echo 'storUsed:'$STORUSED;STORTOTAL=`df --output=size / | awk 'END {print $1}'`;echo 'storTotal:'$STORTOTAL

Expected output:

storUsed:4663464
storTotal:7613000

Top CPU Process

PROC=`ps -Ao comm,pcpu --sort=-pcpu | head -n 6 | sed 1d | tr '\n' '\#'`;echo 'proc:'$PROC

Expected output:

proc:systemd 0.5#Xorg 0.4#lxpanel 0.4#pcmanfm 0.3#bash 0.3#

CPU Temperature

cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null) || cpuTemp0=0;cpuTemp1=$(($cpuTemp0/1000));echo cputemp=$cpuTemp1

Expected output:

cputemp=39

GPU Temperature

echo gpu$(/opt/vc/bin/vcgencmd measure_temp 2>/dev/null)

Expected output:

gputemp=40.2'C

Credits

The app uses NMSSH to establish SSH connection:
https://github.com/NMSSH/NMSSH

The app uses wiringPi to access GPIO:
http://wiringpi.com/

Thank you for reading till the end. Hope the app is useful. :)

--

--