Using an old phone as an IoT device

An idea I’ve been wanting to do for a while is to use an old phone as an IoT device. A second-hand smartphone is potentially a cheap way to get a processor, screen, and storage. The phone needs to be hackable – I think an operating system like LineageOS or JanOS needs to be installed on it. LineageOS has the best support for different phones. In order to be useful for IoT, the base phone should be extensible to add sensors or micro-controllers.