This is the following up the previous Android Phone as Server article. Last update 22/03/2017.
Servers: So having now tried various phones and tablets, it does look like the Linux Deploy App on a rooted Android phone makes for a good Debian installation in order to run software like Apache, SQLITE, MQTT and Node-Red – in some cases surpassing the capabilities of the likes of Raspberry Pi by some way. When I say it looks that way, it is to early to comment on reliability – though my little K10000 monster phone has now been sitting on the bench for several days running this stuff without a hitch.
Resource: The next step then is to add value to this – modern Android phones are awash with features, none of which are currently being used in this setup. With MQTT communication, it seems natural to take all of those sensors and outputs and use them, firing info back and forth in MQTT or similar between Debian (Node-Red for example) and the Android phone (or tablet).
Some time ago when messing with the infamous TASKER on Android – which can access most phone/tablet features, I noted the Tasker/MQTT plug-in – which means that Tasker can communicate via MQTT. The only problem with this – is that the MQTT app has not been updated since 2015, recent reviews suggest that it packs in after a while and the author does not at first glance appear to be responsive. I’ve written to him and not yet had any answer. This makes me extremely reticent to go down this route. I’m wondering if there are other ways to use Tasker to do the same thing. Remember that for this to be useful, this has to be something that will start up automatically when the phone is on – and also something that will run in the background when the phone is on standby.
So recently, friend Antonio sent me a link to another option – Sensor Node – the link here is to the free version and I splashed out and bought the full one. This seems ideal, instant access to at least sensors (though not controls) via MQTT at a user-selectable rate. Well, it didn’t quite work out that way when I tested it – firstly some of the touted sensor readings for some inexplicable reason are not included in the options for MQTT output – like battery power and percentage charge – which would be really very good for sensing if the power has been lost and doing something about it – (like backing up any RAM cache to disk). I’ve written to the author and asked about this – but when I started testing this it got worse, the software would not store my MQTT readings properly and there is no facility that I can see to run this in the background or ensure that readings commence when the phone starts up.
Anyway it turned out that Sensor Node was CRAP – even the paid version-and it turns out that there is an updated MQTT Client add-in for Tasker so I gave THAT a go.
Verdict: It is looking like TASKER and the MQTT Client plug-in are winners. It did not take long to have Tasker sending BATTERY STATUS back to Debian every time the percentage changed – and in the process I found this link detailing a LOAD of variables you can use. The next thing was to get a Tasker task taking in an MQTT message and SPEAKING it out – that works a treat. If I could just figure out how to get it to take in serial (see the article on the RFLINK gadget) – I could take in my doorbell presses and have them play bells!!! I do however have the thing taking in MQTT and playing a REALLY nice doorbell.
Update: All of this incidentally while in standby – I fully charged the K10000 phone and disconnected from the mains. The screen is off and occasionally as well as running Debian and my Node-Red stuff, it acts as a doorbell. THREE days later the battery is around 76% – how many server backup systems manage that!!! We’re talking at least a week in the absence of power. I can see a solar project coming on here.
Hi Pete / All,
Long time lurker on your blog….. This topic is one I have been working on for a few years now….
Been trying to use ‘old’ Android phones as IoT devices for a while. So full of sensors, so much hope, crippled by a lack of apps.
Sensor Node is great, but has a memory leak. After a few days it crashes the phone. The author is unresponsive. (Also, as you have found, it only includes some sensors as MQTT, others only via XML).
The other apps have similar issues, crash, or don’t include the full suite of sensors.
If all you are after is battery level, then OwnTracks have had that for ages and I have been using Node-Red to extract that for some time.
I am after noise, light and perhaps vibration.
Looking forward to seeing if we can come up with a combination of software to make all this available via Node-RED…. The old phones are a great resource.
Here is this Android Server on RPI0- W running DietPi with MQTT SqLite/phpliteadmin Sonoff WiFi integration, from The Guy With The Swiss Accent 😉
Could be cheaper than $20 on the $9 CHIP with some tweaks.
that’s just the script, nothing about android… the same script can be run on android, too, not natively but with a little of virtualization (not really, but only to be clear), using an app that allows to run debian 🙂
latest app has a github also, with recent mods published, so it should be active and hoping better supported than the previous one… i’m linking this blog in his video, let’s see 🙂
https://github.com/dc297/mqttclpro
Hey hi
Saw the link to this comment on my video on youtube. Maybe you could get me up to speed with you guys.
oh, thanks! Seen that you updated your app this morning 🙂
very good 🙂
let’s wait Peter and his tests 🙂
the guy seems quite responsive, well, it’s a good start 😀
he published a video of what i asked him just a few minutes before! great! 😀
And it works! 🙂
If you combined that with a Sonoff you could turn off your charger at the mains when the battery is charged. Might be useful if you were leaving it unattended.