Smashed Toilet Phone Web Server
OffTheBricks
Menu
Smashed Toilet Phone Web Server
Behold my smashed Samsung a70 smartphone. It's seen better days but it's serving up this nice webpage for your enjoyment
Don't feel bad for this beat-up phone. Sure it's been smashed, then later dropped in a toilet before sitting for over a year in a bag of rice;<br>whatever, that just adds character to the phone, right?
Life Signs
Our story begins after that year in a bag of rice when I found it by accident in the garage, and decided to see if there were any signs of life.<br>After a long sit on the charger I was pleased to see that indeed there were life signs, and the readings were strong!<br>Once charged back up to full, the phone booted up as if it were brand-new in the box!<br>That's where the fun stopped however, as it immediately became clear that the touchscreen no longer functioned,<br>and thus its days as a portable phone were long over.
You would not be foolish to think this should be the end of the story; how are you supposed to do anything with a device you can't control?<br>It may seem counter-intuitive but actually Android devices have pretty good mouse and keyboard support; most now even support external monitors.<br>It stems from a desire to make the smartphone the center of your computing life. The thinking from these big tech corps is that if your phone<br>can do everything, why even both with a desktop in the first place. That logic is debatable depending on your needs, but it helps in this case<br>so I'll take it!
The Plan
I've long been interested in the possibilities for old phones that have outlived their 'portable phone' days. It might be because I remember when<br>computers ran at 8 MHZ with 640 KB of RAM, and could do all sorts of fun things. These 'old' phones by comparison are hundreds of times more<br>powerful than those old computers, and have all sorts of sensors and networking abilities built-in. Surely they can serve a need other than food for<br>the recycler.
While I have some neat ideas for remote control and other IoT applications, a web server is kind of like the "Hello World" of repurposing hardware.<br>If you can get it to talk to other machines, all the other features can be bolted on afterwards.
Technology Auditions
The most critical part of any project, is the technology selection stage.<br>You need to select a solid foundation for your project, that you won't regret later on.<br>These days there are a dizzying amount of options, but surely an Android based web server isn't common, and will have fewer options.
That thought didn't age well.<br>It seems I'm not the only one looking at hobby or even commercial applications for web servers on Android phones,<br>as there are a surprising number of options.<br>Aside from native Java or Kotlin, there are apps built with Apache and PHP built-in; just upload your scripts and start serving.<br>You can also get a linux command line with Termux, and install any environment you're used to.
Hardware First
Let's take a break from the software side, and sort out hardware first instead.<br>Normally this is just a big a challenge as software, but since the phone isn't modular there's actually less to worry about here.<br>The phone's WiFi works just fine but we need wired ethernet for reliability.<br>We also want power, as the phone battery isn't going to run forever. Here's what I came up with.
The USB-C hub provides power to the phone, while also supporting peripherals like the pictured USB ethernet adapter.<br>With the other hub slots we could potentially add USB storage, cameras, printers, etc.
With some careful networking setup, the phone will switch seamlessly between WiFi and ethernet (keeping the same IP address).<br>If it's unplugged the battery takes over as normal; it's got built-in redundancy!
About That Battery
Undoubtedly at least one of the readers of this story will raise alarms at the prospect of keeping a lithium battery on full charge all of the time.<br>It's a fire hazard! It can explode!
I have a fair bit of experience with charging batteries of many types, and with confidence I can say that these concerns are largely overblown.<br>Any appropriately designed battery charging system will stop charging the battery once it's fully charged.<br>It's very easy for a charging circuit to detect when a lithium ion battery is fully charged (especially compared to NiMH),<br>so there's little (not nothing, but little) to go wrong.<br>Sure if the battery is already damaged that could be a problem, but then it would have been a problem anyway.<br>There's also some suggestions out there that leaving a lithium ion battery fully charged will degrade its max capacity over time;<br>I haven't seen any evidence of that in practice, but in our case we don't really care much about that anyway.
If you're interested in some more basic facts about batteries, check out my Battery Basics article.
Back to Software
The first software option was an app with an AMPP stack (Apache, MySQL, PHP).<br>It was ultra easy to setup and load...