here is the wikipedia page on it
"The ability to sense infrared thermal radiation evolved independently in several different families of snakes. Essentially, it allows these animals to “see” radiant heat at wavelengths between 5 and 30 μm to a degree of accuracy such that a blind rattlesnake can target vulnerable body parts of the prey at which it strikes.[1] It was previously thought that the organs evolved primarily as prey detectors, but recent evidence suggests that it may be used in thermoregulation and predator detection, making it a more general-purpose sensory organ than was supposed.[2][3]"