Monitoring ventilation rate is key to improve the quality of cardiopulmonary resuscitation (CPR) and increase the probability of survival in the event of an out-of-hospital cardiac arrest (OHCA). Ventilations produce discernible fluctuations in the thoracic impedance signal recorded by defibrillators. Impedance-based detection of ventilations during CPR is challenging due to chest compression artifacts. This study presents a method for an accurate detection of ventilations when chest compressions are delivered using a piston-driven mechanical device. Data from 223 OHCA patients were analyzed and 399 analysis segments totaling 3101 minutes of mechanical CPR were extracted. A total of 18327 ventilations were annotated using concurrent capnogram recordings. An adaptive least mean squares filter was used to remove compression artifacts. Potential ventilations were detected using a greedy peak detector, and the ventilation waveform was characterized using 8 waveform features. These features were used in a logistic regression classifier to discriminate true ventilations from false positives produced by the greedy peak detector. The classifier was trained and tested using patient wise 10-fold cross validation (CV), and 100 random CV partitions were created to statistically characterize the performance metrics. The peak detector presented a sensitivity (Se) of 99.30%, but a positive predictive value (PPV) of 54.43%. The best classifier configuration used 6 features and improved the mean (sd) Se and PPV of the detector to 93.20% (0.06) and 94.43% (0.04), respectively. When used to measure per minute ventilation rates for feedback to the rescuer, the mean (sd) absolute error in ventilation rate was 0.61 (1.64) min-1. The first impedance-based method to accurately detect ventilations and give feedback on ventilation rate during mechanical CPR has been demonstrated.