While smoke alarms are quite cheap devices, the cost of 9V batteries quickly exceeds their purchase price. Added to that is the irritation of random beeps from the alarm as the battery reaches the end of its useful life. This circuit allows typical smoke alarms to be powered from the 12V supply in a burglar alarm while still keeping the standard 9V batteries in place. It extends the 9V battery life to that of its "shelf life" as the battery is only required to drive the smoke alarm in the event the 12V supply is removed or shorted out.
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.