The effect of caffeine on sleep has been well documented. However, most studies examined this relationship in laboratories or used a cross‐sectional design analysing between‐person differences. This study investigated the within‐person relationship between caffeine intake and sleep duration at home. In a national database, 377 participants (aged 35–85 years) completed a 7‐day diary study. Sleep duration was measured by Actigraphy and caffeine intake was self‐reported in sleep logs. Three analytic strategies were used. The average sleep duration and the average caffeine intake were not significantly correlated. Multilevel regressions using daytime caffeine intake to predict night‐time sleep, and using night‐time sleep to predict next day caffeine intake, also did not detect any significant effect. Then dynamical systems analysis was performed, where the daily change rate and change tendency of caffeine and sleep were estimated, and the relationship among these momentums was examined. Results revealed a significant effect of sleep duration on the change tendency of caffeine use: a shorter sleep duration predicted a stronger tendency to consume caffeine, and this phenomenon was only found in middle‐aged adults (aged 35–55 years) not in older adults (aged 55+). This study did not detect any effect of daily caffeine intake on sleep duration, implying that habitual use of caffeine in real life may not coincide with laboratory findings, and that using caffeine to compensate for sleep loss is the habit of middle‐aged adults, not the elderly. The advantage of using a dynamic approach to analyse interrelated processes with uncertain time lags is also highlighted.