As a fruit fly sails from sunshine into a patch of shade, its temperature drops by 10 degrees F or so. Immediately, certain neurons in its brain spring into action, telling the fly’s circadian clock about the temperature change. By tracking the environment in this way, these temperature neurons help the insect keep track of night and day, the time to sleep and the time to wake, according to a recent paper in Nature.

That isn’t at all what the scientists were expecting, says senior author Orie Shafer, a chronobiologist at the University of Michigan in Ann Arbor. After all, flies and other animals don’t suddenly fall asleep when they get a brief, midday chill. The researchers assumed that the fly’s circadian network would respond to large, or long, changes in temperature.

While exposure to light has received the bulk of attention for its powerful role in setting body clocks, scientists already knew that the warmth of morning and the chill of twilight also contribute. First authors Swathi Yadlapalli and Chang Jiang put flies in a device that could rapidly raise or lower their temperature. Starting with a setting of 23 degrees Celsius, they either dropped the temperature to 16 degrees, or raised it to 29. They made each temperature change for five seconds, and did so 10 times in succession. Then they examined the animals’ brains. To monitor the activity of the 150 nerve cells in the circadian network, the researchers used fluorescent markers that change color or light up when calcium fills the cell, a surrogate marker for neurons firing.

One particular class of neurons, the posterior dorsal neurons 1 (DN1 p s), did pay attention to changes in temperature. When Jiang and Yadlapalli chilled flies, these neurons turned on. When they raised the temperature, the DN1 p s were less active than in flies held at a constant 23 degrees, indicating they were inhibited by heat. “These neurons at the heart of this time-keeping network, they’re just second-to-second monitoring the temperature,” says Shafer.

Flies have temperature-sensing organs on their bodies and antennae. When the researchers removed the antennal organs, called aristae, the flies had a diminished response of DN1 p s to temperature change. The same occurred when they used flies with a mutation in the gene nocte, which causes defects in the body temperature sensors.

But would problems with the DN1 p s interfere with sleep-wake cycles? To find out, the authors accustomed a set of flies to a cycle of temperatures mimicking natural conditions—between 18 degrees Celsius at night and 25 degrees during the day. In general, flies with functioning clocks tend to become more active as their world heats up, and start to fall sleep shortly before cooling, because their circadian network anticipates the onset of night.

But the nocte mutants were less likely to drowse before the temperature dropped. And when the researchers removed aristae from nocte flies, the insects lost all rhythm to their sleep and activity, Shafer says. Directly blocking the activity of DN1 p s also interfered with circadian rhythm. Shafer and colleagues propose that at night, DN1 p action puts flies to sleep, and the warming that occurs every morning turns those neurons off, making the insects active.

Circadian rhythms are found across the animal kingdom. Might an analogous system be at play in other creatures, including people? Humans’ core body temperature does drop as we get sleepy.

“It really offers some impetus to consider the role of temperature in other animals,” says neuroscientist Paul Taghert at Washington University in St. Louis, a former adviser to Shafer but not a participant in the current study. A better understanding of temperature’s role in sleep might, he speculates, lead to new advice on how to get some shuteye, or point to therapeutics for sleep disorders.