When a project has outgrown using a small microcontroller, almost everyone reaches for a single-board computer — with the Raspberry Pi being the poster child. But doing so leaves you stuck with essentially a headless Linux server: a brain in a jar when what you want is a Swiss Army knife.
It would be a lot more fun if it had a screen attached, and of course the market is filled with options on that front. Then there’s the issue of designing a human interface: touch screens are all the rage these days, so why not buy a screen with a touch interface too? Audio in and out would be great, as would other random peripherals like accelerometers, WiFi, and maybe even a cellular radio when out of WiFi range. Maybe Bluetooth? Oh heck, let’s throw in a video camera and high-powered LED just for fun. Sounds like a Raspberry Pi killer!
And this development platform should be cheap, or better yet, free. Free like any one of the old cell phones that sit piled up in my “hack me” box in the closet, instead of getting put to work in projects. While I cobble together projects out of Pi Zeros and lame TFT LCD screens, the advanced functionality of these phones sits gathering dust. And I’m not alone.
Why is this? Why don’t we see a lot more projects based around the use of old cellphones? They’re abundant, cheap, feature-rich, and powerful. For me, there’s two giant hurdles to overcome: the hardware and the software. I’m going to run down what I see as the problems with using cell phones as hacker tools, but I’d love to be proven wrong. Hence the “Ask Hackaday”: why don’t we see more projects that re-use smartphones?
Hardware Encounters Smartphone
It’s absolutely impossible to beat the convenience of simply hooking up some wires to the pins of a robust microcontroller. I’ll admit that even today, in this era of low-voltage logic, I like to keep a number of chips on hand that have five-volt tolerant GPIOs. And it’s super handy to have a microcontroller that’ll source 20 mA on a pin (per the datasheet, and maybe more in practice). It’s already a tiny hassle to migrate some projects to a Raspberry Pi, where you have to be careful with 3.3 V inputs and a slightly weaker output buffer. But it’s not that big of a deal: connecting directly to anything that speaks I2C or SPI, or just needs a logic-level signal on a wire, is child’s play. Just wire pin to pin, and you’re set.
And then I look at my cell phone. Where do I even plug my motor controller into this thing? There’s the audio jack and the USB, and that’s it. I’m not sticking my Hello World LED into either of those ports and expecting success.
One solution is to throw money at the problem and buy a USB breakout board. For the price of a Raspberry Pi and SD card, you can buy an IOIO dev kit that seems to support nearly everything you’d want. Numato Labs has an eight-pin GPIO expander that sidesteps the whole Java API mess — more on that later — by presenting itself to the phone as a serial device. This means that you need to learn its command language, though. A while back, Motorola even toyed with releasing super-expensive “Mods Development Kit“, but beyond the press release, I haven’t heard anything more of that. Does Android or iOS have support for the FT232H chip? If so, you could press one of those into service pretty readily.
But if the point was to get by on the cheap by re-using an old cell phone, these options don’t make financial sense. Can we DIY something cheaper? WiFi and Bluetooth spring to mind, and indeed you can buy modules that use either for just a few of your local monetary units. For instance, a HC-05 style Bluetooth module makes a cheap and cheerful USART-to-cellphone bridge. All you have to do then is tie the microcontroller of your choice to the HC-05 and then write the firmware. Or go WiFi and do the same with an ESP8266 or ESP32. Again, you’re stuck writing the WiFi-to-GPIO end of the code, but that should be a one-time cost. So I looked around to find these obvious projects somewhere on the net, and came up empty. Anyone?
But what about that audio jack? You could encode your data in audio like we did in the dial-up-modem days of yore. This can be done on small microcontrollers easily enough that a full ATtiny85 audio bootloader can fit in 1 kB, for instance. Now you just add the GPIO-driving firmware.
At the end of the day, these alternatives are all doable, but they all require doing. That is, tacking physical GPIOs onto a cell phone is a project in and of itself. Before you even get to thinking about programming the phone to do your bidding, you have to figure out your hardware-side API. And because it’s a project in itself, you’ve got to really value the additional capabilities that the smartphone brings to the table to warrant getting up and over the hardware hurdle.
Software Needs to Make It All Work
But let’s assume that you’re committed to buying or building a GPIO adapter, how do you start development on your project, given that the software needs to run on the cellphone? Our own Adam Fabio looked at the lay of the land back in 2015 for Android. (Apple folks, what’s the situation like for you?)
Suffice it to say that app development for Android is non-trivial, but at least there’s a ton of documentation to get you started. Even if you’re a Java master, which I’m not, you’ll still want to make sure that the rest of the software components that you’d like to integrate into your own are available on Android. This is where the picture actually gets a little bit brighter. For instance, if you intend to make use of the camera and abundant processing power for computer vision, you’ll be glad to know that OpenCV has been ported to Android, as has CMU’s PocketSphinx voice recognizer.
But Java isn’t my cup of tea. A few years back, I wrote some simple cellphone apps using SL4A — scripting languages for Android. It was pretty pleasant, and I was able to cobble together a Python script that uploaded photos to Imgur and then pasted the resulting URL into the system clipboard in an afternoon. It was actually really great to have Python up and running on the phone — it almost felt like a little computer. Now, SL4A seems to be no longer supported. What’s the new hotness?
As with the hardware hurdles, taking advantage of the processing power inside a cellphone looks like I’m going to have to put in the hours to learn Java and the Android OS way of doing things. And when I compare this with the ease of getting similar things done on a Raspberry Pi, it’s a show stopper.
Giving Up?
Faced with these hardware and software hurdles, you might just retreat back to the friendly environment of the Raspberry Pi or download one of the myriad apps that turn your cell phone into a glorified remote control. With shame, I’ll admit that’s what I’ve done, but I’d honestly like to change. If you’ve hacked a cell phone into a project, let us know! And if, like me, you’ve tried and failed, tell us where you got stuck.
Please enjoy Python with SL4A on Android, it should be still working completely ;)
https://gofile.io/?c=yFQDZt
all copyright goes to authors, u know ;)