A sensor has a cylindrical shape and is equipped with: a housing where first and second holes penetrating the exterior wall are opened; a cap where first and second female screws are provided on the side surface facing the inner wall of the housing with a gap therebetween; a first substrate attached to the housing; a second substrate attached to the cap and facing the first substrate; a generation portion attached to one of the first and second substrates; a detection portion attached to the other of the first and second substrates; a first screw member passing through the first hole and joined to the first female screw; a second screw member passing through the second hole and joined to the second female screw; and a biasing member for applying force directing toward the inner side of the housing to the first and second screw members.