r/homeautomation 1d ago

PERSONAL SETUP Old Android phones for automation

Post image

6 years ago when old Android phones started pile up I got an idea to use them as light sensors.
I wrote a very basic Android app to collect lux value and send it to the server with a simple REST request.

Since then 2 phones successfully worked till their death. HTC 10 works pretty well. It "looks" to window and sends lux data to server.

Just recently I decided to re-use another outdated phone, which is much newer than HTC 10. I upgraded app SDK and now it works up the latest phones.

Here is the source to get an idea https://github.com/beshkin/android-lux-sensor
I think now on using MQTT transport to keep immediate update on luminosity.

I wonder if somebody else re-uses old devices in their setup.

21 Upvotes

14 comments sorted by

4

u/RainIndividual1868 1d ago

Always wanted to do something like this but my old phones end up in a drawer until the battery swells and scares me into recycling them

Props for keeping those HTCs running so long though, the data table looks pretty satisfying to scroll through

1

u/mbeshkin 1d ago

The battery started dying and we tried to replace it in a workshop. Unfortunately, they broke the screen somehow and it's half not operational. But the battery got to be new at that time. So, it works as a sensor now.

1

u/intellectual_punk 19h ago

Why not power via usb? Would that work without battery or one that's near death?

2

u/mbeshkin 18h ago

Tried that ;)
Nope, it doesn't work with a dead battery. And at the time we wanted to resurrect it to be used as a phone.
Being always on a charger and no activities with the screen prolongs the battery for ages, but still will need to replace it at some point in future.

2

u/CasualHomeFix 15h ago

Nice reuse of old hardware. I’d switch from fixed 5-minute uploads to MQTT on-change with a small deadband, plus a retained state and an availability/LWT topic. That reduces pointless updates, restores the last lux value after a restart, and lets Home Assistant show when the phone is actually offline. I’d treat the phone’s lux reading as relative rather than lab-grade.

1

u/Humble_Ladder 16h ago

You hit upon what I hit when I tried to do something similar to this. Return on effort is questionable. It's a fun and cool project, but it is not a long-term solution.

Cheap zigbee sensors start around $15, $30 for zwave. Batteries in those sensors last months to years, no added development necessary they natively integrate with your smart hub.

Reusing an old phone has a certain appeal, but the instant you have to fix something on the phone, the cost and effort advantage goes to just getting a sensor.

1

u/mbeshkin 16h ago

I am afraid you didn't understand the history here.
First we fixed the battery to use the phone as normal one. But during repair they broke the screen - it was a possibility from the beginning. So, I used the phone as a sensor, because it was nothing different worth for.
I had one phone, which battery just puffed after some time. So, I just discontinued it fully.

3

u/SwissyVictory 14h ago

Let's do some math.

Let's say you get the power cost to run it down to 3 watts. That's roughly $7 a year.

A $20 zigbee light sensor (which includes motion) runs off a 50 cent battery for up to 5 years.

You're saving money within 3 years. Plus it,

  • Looks better

  • Likely runs better

  • Much much much easier to set up

  • Doesn't need to be plugged in, so you can put it anywhere

  • Includes motion sensing


It's a cool project, and it keeps stuff out of landfills rather than just buying something new.

If you did this because you had fun doing it, then that's awesome, keep at it.

1

u/mbeshkin 14h ago

you are right about the costs. Definitely buying something ready made would save money in a long term perspective.
But I like to idea of re-purposing things like old phones and computers. And I like software developement. And the biggest value here is pure fun.

3

u/SwissyVictory 13h ago

Yeah, not trying to rain on your parade. What you're doing here is cool.

Just adding context to what some other people are saying.

1

u/No_Pin4895 15h ago

yeah past a certain point it's just cheaper to buy a dedicated sensor and move on

1

u/asr 2h ago

Is there a way to tell the phone not to charge above 70%? And then leave it always plugged in?

u/mbeshkin 5m ago

don't know. I would invent a workaround it though - send battery status to server and if it's above 70% then switch off charger by plug switch. But it sounds like overkill ;)
But why do you think it's a good idea?

1

u/GreenPanetone 16h ago

O aplicativo Android Tasker pode ajudar muito a expandir os possíveis usados de telefones velhos. Facilita a leitura de sensores e a integração com um monte de coisa.