Two doctors at Penn State University have developed Caffeine Zone, a free iOS app that tells you the perfect time to take a coffee break to maintain an optimal amount of caffeine in your blood — and, perhaps more importantly, it also tells you when to stop drinking tea and coffee, so that caffeine doesn’t interrupt your sleep.
Or, if you don't have a smart phone, just remember the half-life is 6 hours for most people.So if you want to sleep at night (since the cutoff for sleep is about 100mg), just make sure you have 200g or less in your blood 6 hours before going to bed.That translates to no coffee after 4pm for me 🙂