Disturbed sleep is common in ageing and dementia, but objectively quantifying it over time is challenging. We validated a contactless under-mattress pressure sensor and developed a data analysis method to assess sleep patterns in the home over long periods. Data from 13,588 individuals (3.7 million nights) from the general population were compared to a dementia cohort of 93 patients (>40,000 nights). Dementia was associated with heterogeneous sleep disturbances primarily characterised by advanced and delayed sleep timing, longer time in bed, and more bed exits. Explainable machine learning was used to derive the Dementia Research Institute Sleep Index (DRI-SI), a digital biomarker quantifying sleep disturbances and their evolution. The DRI-SI can detect the effects of acute clinical events and dementia progression at the individual level. This approach bridges a gap in dementia care by providing a feasible method for monitoring health events, disease progression and dementia risk.