Throughout the outer body shell (ectoderm), encompassing skin and subcutaneous fat tissue, thermoceptors are embedded on free nerve fibres (so, these types of receptors are not special cell types, in contrast to photoreceptors for example). There are two types of fibres: group-III afferences (cold-sensitive) and group-IV afferences (heat-sensitive).
In the membranes of these nerve cell fibres are specific proteins anchored. Those proteins are called TRP channels (Transient receptor potential), which can conduct ions on demand.
When temperature difference on the skin periphery is detected, they change their conformation and open themselves which leads to the influx of Na+, Cal2+ and Mg2+ ions leading to action potentials transmitted to the central nervous system.
Those types of thermoceptors work like proportional-differential-sensors: rapid skin temperature changes (touching a warm cup of coffee) are answered with very high action potential frequency; afterwards they adapt to the temperature and fire less frequent, but still more frequent than in default. This kind of firing leads to the impression of holding something in the hand which is warmer than one's own skin before touching it.
Now, very interestingly, TRP receptors can be activated via capsaicin (chili spicy molecule), allicin (garlic aroma molecule), allyl isothiocyanat (wasabi compound), menthol or even THC. This is the reason why chili can evoke a real sensation of hotness while menthol evokes the impression of coldness when you for example taste a menthol chewing gum.
With those biological devices one person can perceive temperature differences of 0.2 K at best.