Circuit diagram:

Smoke Alarm Battery Life Extender Circuit Diagram
In normal operation, the LM317 supplies 9.7V and this is fed via diode D2, resulting in just over 9V at the smoke alarm supply terminals. Q1 is not biased on, so the 9V battery is disconnected from the circuit. If the 12V supply is removed, the output of the LM317 will be 0V and Q1 will be biased on via the 4.7kO resistor and thus the smoke alarm will continue to be powered. The circuit could be assembled on a piece of Veroboard and fitted inside the smoke alarm. Alternatively, you could house the circuit and 9V battery within a standard electrical flush-mount box which the smoke alarm covers when mounted.
Author: Paul Blackler