Pion electro- and photoproduction off the nucleon close to threshold is studied in covariant baryon chiral perturbation theory at O($p^3$) in the extended-on-mass-shell scheme, with the explicit inclusion of the $Delta(1232)$ resonance. The relevant low energy constants are fixed by fitting the available experimental data with the theoretical model. The inclusion of the $Delta$ resonance as an explicit degree of freedom substantially improves the agreement with data and the convergence of the model.