What's already in the drawer
An old phone has a battery, a camera, a microphone, light and motion sensors, and a network connection: most of a sensor node's bill of materials, already assembled and already for sale secondhand for almost nothing.
Termux and a small script
Installing Termux turns the phone into a small Linux environment. A short script reading the light sensor and publishing to an MQTT broker every minute was running within an hour. No soldering required.
Battery life needed a real strategy
Left plugged in permanently, the phone's battery degraded faster than expected, lithium cells don't love sitting at 100% charge indefinitely. A wake-lock through Termux, combined with a script that only powers the screen and radio on for the publish window, stretched runtime enough to run on battery alone for a few days between charges.
The camera turned it into more than a sensor
A cron-triggered script capturing a frame and running a simple brightness threshold turned the same phone into a crude motion-triggered camera, no separate hardware, no extra cost, just another script pointed at hardware that was already sitting there.
Why this beats buying a dedicated sensor, sometimes
For a stationary use case like monitoring a garage or a plant shelf, a phone that would otherwise sit unused in a drawer already includes a battery, a screen for status, and connectivity, and it keeps a working device out of a landfill for another few years.
Wi-Fi drops needed a watchdog, not a fix
Termux's background script would occasionally lose its Wi-Fi connection after the phone's radio power-saving kicked in, and Android doesn't guarantee a killed background process restarts itself. Rather than chasing down the exact power-management setting responsible, a small cron job that pings the broker every few minutes and restarts the publishing script if the ping fails turned an occasional silent gap in the data into a brief, self-healing hiccup.
A second phone made the case for redundancy
Adding a second retired phone running the same script, watching a different room, cost nothing beyond another device already sitting unused, and turned a single point of failure into two independent sensors that don't share a power source or a Wi-Fi radio, cheap redundancy that a single purpose-built sensor wouldn't have offered without buying a second one.
Before buying a purpose-built sensor, it's worth checking whether an old, unused phone already has everything the project needs.