We describe measurements of the pyroelectric coefficient of epitaxial layers of Ba0.6Sr0.4TiO3 (BST) and PbZr0.2Ti0.8O3 (PZT) using a modulated laser as the heat source in the frequency range 1 Hz to 10 MHz. The pyroelectric coefficient is also measured as a function of applied static electric field and for films grown on SrTiO3, DyScO3, and GdScO3 substrates. The heat diffusion equation is solved in cylindrical coordinates for the temperature field in a multilayer sample heated by a Gaussian-shaped laser beam. The secondary contribution to the pyroelectric effect caused by piezoelectric effects and in-plane thermal expansion is revealed by the difference between the pyroelectric coefficients at high and low frequencies. The secondary pyroelectric effect has the same dependence on applied field as the pyroelectric coefficient. The magnitude of the secondary effect changes with heating frequency because of changing mechanical conditions, but the pyroelectric coefficient has no other frequency dependence between 1 Hz and 10 MHz. The secondary effect is approximately 15% and 20% of the total pyroelectric response for PZT and BST films, respectively.