Some nights you drift off to dreamland before you count your third sheep. Other times you toss and turn for hours before you slip into a fitful sleep. After lunch you may be dragging. Later, your energy levels soar, just in time for bed.

How and when you feel sleepy has to do with your sleep/wake cycles, which are triggered by chemicals in the brain.
Brain Chemicals & Sleep
Chemicals called neurotransmitters send messages to different nerve cells within the brain. Nerve cells in the brainstem release neurotransmitters. These include norepinephrine, histamine, and seratonin. Neurotransmitters act on parts of the brain to keep it alert and functioning while you are awake.
Other nerve cells stop the messages that tell you to stay awake, causing you to feel sleepy. One chemical involved in that process is called adenosine. Caffeine promotes wakefulness by blocking the receptors to adenosine. Adenosine seems to work by gradually building up in your blood when you are awake, leading you into drowsiness. While you sleep, the chemical slowly dissipates.