The answer to 'how to fix smoke detector' is to first check if the smoke detector is malfunctioning or needs new batteries. Start by pressing the test button on the smoke detector - if it does not sound, the detector may need to be replaced. If the detector is sounding but you suspect a problem, try replacing the batteries. Ensure you use the correct battery type specified for your smoke detector model.
If the smoke detector still does not work after replacing the batteries, it may need to be cleaned or recalibrated. You can try gently vacuuming the exterior and interior of the detector to remove any dust or debris that could be interfering with its sensors. If the detector still does not function properly, it's best to contact a professional electrician to diagnose and repair the issue.