You may have seen reports in the news of how prices of technology have shot up. Recently there have been steep price rises for RaspberryPi models for example.
The price rises are due to increased demand for memory from AI data centres, which are absorbing much of the production capacity for memory chips. Additionally, manufacturers are prioritising high-bandwidth memory (HBM) for AI applications over consumer-grade memory, leading to a significant supply shortage.
If you are a hobbyist this can quickly burn a hole in your pocket if you are looking for devices for your projects. While contemplating this I came across a suggestion that you could use an old Android device instead. Obviously this wouldn’t be any good if you were looking to incorporate this into a hardware project that required sensors, but it would work well as a small web server. I wondered whether I could get my pi-watchdog project to work this way.
What do I need?
Well, obviously, you need an old Android device. I used a Lenovo tablet running Android 10 with 2GB of RAM and a Qualcomm Snapdragon 429 processor. The specs of this compare well with the Raspberry Pi Model B I had been using which only had 256MB of RAM.
This specification allowed me to use the device for two purposes: firstly I used it as an always on Home Assistant display and secondly, running in the background, the web server running pi-watchdog.
You can’t just whack Linux on an Android device and be done with it, well you can, but that means rooting your device which I wanted to avoid. I looked for alternative routes and came across Termux, a Linux emulator that can run as an Android app. If you are interested in the differences between installing full Linux on your Android device and Termux have a read of this dev.to article.
Getting Termux onto your device still requires you to jump through a few hoops as it isn’t available in Google’s Play Store. Instead you need F-Droid.
Installing F-Droid
Google aren’t keen on you installing outside of the Play Store, and there are some reasons, both good and bad, for that. On the positive side, via the Play Store, it is easier to find apps that have been approved in some way, such as “Verified by Play Protect”. The other side of that is that Google gets to choose what you can and cannot install and, of course, monetise.
Enter F-Droid, a free and open-source app store for Android that only hosts free and open-source software, focusing on transparency and privacy by flagging apps with anti-features like ads or tracking.
Head to https://f-droid.org/ and follow the links to download the app. This is appears as an apk which you need to open and on doing so you will see this message:
For your security, your phone is not allowed to install unknown apps from this source.
This is Google trying to protect you. Go to Settings and set Allow from this source.
Installing Termux
Now that you have F-Droid on your device the next step you can use this to search for and install Termux. There are lots of similar sounding things on F-Droid: Termux Hub, Termux:Gui, Termux:Boot. Look for the one called simply Termux and install that.
Once again you will get the “For your security…” message. Do as above.
Keeping Termux alive
Android may try to suspend or terminate background applications, particularly when the screen is off. So in order to prevent this in Termux, run:
termux-wake-lock
Also change Android’s battery settings for Termux to allow unrestricted background activity, where available.
Accessing Remotely
Now you have Termux on your phone you can access the command line and issue commands just like you would on any other Linux distribution. However, it would be much easier to be able to access from another device with a full-sized keyboard. In order to do so the first thing I would do is install openssh.
In Termux issue the following commands to update the packages and install openssh:
pkg update && pkg upgrade
pkg install openssh
Who am I?
Before you can access you need to do a few things. In the device issue the following commands:
passwd
whoami
sshd
This is what these commands do:
passwdallows you to set a password to access the device via ssh.whoamiwill return an Android-specific username, something likeu0_a123. Make a note of this for later.sshdstarts the openssh service.
Find your IP Address
In order to connect you need to find the IP address of your device. You can do this by going to the connections section in Settings and looking for the address shown for your connection. Assuming that you are using this on your own network via Wi-Fi I would add a static reservation for the device in your router.
Termux’s SSH server normally listens on port 8022, rather than 22. From your main device such as Mac or PC, you can connect with:
ssh -p 8022 <username from whoami>@<device IP address>
Installing and Running pi-watchdog
I am using pi-watchdog as an example here but you can, of course, use any lightweight web app of your choosing.
Installing the Web Server
Hopefully, you can now access your device and so the next step is to install the requirements. For pi-watchdog these are as follows:
pkg install php git curl sqlite
Once that has completed check that it has all installed correctly:
php -v
php -m | grep -Ei 'curl|pdo_sqlite|sqlite3'
If you receive an error similar the following from the above commands:
CANNOT LINK EXECUTABLE "php": library "libicuio.so.79" not found
Then run the following and retry:
pkg update
pkg upgrade
Install pi-watchdog
Get the latest code from the GitHub repository:
git clone https://github.com/williamsdb/pi-watchdog.git
Then following the instructions in the README.
Running a Web Server
While this is a more than capable Android device you want to keep the services it runs lightweight so that rules out installing full Apache. PHP’s built-in server is lightweight and perfectly reasonable for a small, trusted-LAN dashboard with occasional requests. Keep in mind, however, that it is intended for development and controlled environments, not exposure to the public internet.
To start issue the following commands:
cd ~/pi-watchdog
php -S 0.0.0.0:8080 -t public
The key part here is the 0.0.0.0. This allows connections from other devices on your network, rather than just the phone itself.
If you later want a dedicated web server, I’d consider Lighttpd.
Accessing your Server
Everything should now be in place to allow you to access pi-watchdog from another device.
Reaching the phone from your network
Go to a web browser on another machine and go to the following URL:
http://<device IP address>:8080
If all is working ok you should see the pi-watchdog dashboard.
Accessing from the Internet
If you need to access pi-watchdog from outside your home network that I would suggest that you use a service such as Tailscale. This is really outside the scope of this article but here are some brief notes to get your started.
Install the Tailscale Android app on the old phone/tablet and run the PHP server in Termux. The Android app handles the VPN, so there’s no need to install tailscaled inside Termux or root the phone.
- Sign in to Tailscale on the old phone using the same tailnet as your laptop or viewing phone. Copy the old phone’s Tailscale IP from the app.
- In Termux, start Watchdog as before:
cd ~/pi-watchdog php -S 0.0.0.0:8080 -t public - On another device connected to your tailnet, open
http://100.x.y.z:8080, replacing100.x.y.zwith the old phone’s Tailscale IP. Try it from mobile data to verify it works away from home.
No router port forwarding is needed. The 0.0.0.0 binding also makes Watchdog reachable on the phone’s local network, including its admin page, so use it on a trusted LAN.
For an always-on setup, test again after the old phone has been locked for a while. Both Tailscale and the Termux server need to stay running. If hostname-based checks fail, check Use Tailscale DNS in the Android app’s preferences.
Wrapping Up
I always hate to throw old tech away and so I have been glad to be able to repurpose this old Android tablet for a couple of new uses. This has also freed up the Raspberry Pi Model B so that’s ear-marked as an overhead plane spotter – watch this space!




