Sleep apnea (SA) is a risk factor for atrial fibrillation (AF) occurrence. Sympathovagal imbalance is a mechanism that predisposes to the development of AF and that occurs in SA. Some pacemakers can detect SA events and continuously measure a time domain measure of heart rate variability (HRV), i.e. the standard deviation of 5-min median atrial–atrial sensed intervals (SDANN). We evaluated the association between the occurrence of AF and device-detected SA and SDANN in patients who received pacemakers.