A method for the detection of location and size of a crack in simple structures using a nanocomposite sensor is discussed. In the present study, a piezoelectric/single walled carbon nanotube composite sensor is modeled on piezoelectric principle. The effective piezoelectric and dielectric properties of the composite at 0.2 volume fraction loading of single walled carbon nanotubes is determined by micromechanical analysis. By means of these effective properties a piezoelectric sensor has been modeled. The transfer function and bode response of this sensor is investigated. The sensor is fixed at a location on a cantilever beam and the response of the sensor with respect to the size and location of the crack is modeled. The analytical values are compared with ANSYS. It is assumed that there is no slippage between the sensor and the beam surface. The sensor behavior with respect to dynamic loading conditions is also studied. It is ascertained that the relative position of the sensor with respect to crack is crucial and determines the sensitivity of the sensor to detect a crack. Results are presented in the form of voltage output from the sensor at different crack locations and at varying lengths of the crack. © 2016, The Institution of Engineers (India).