The heat comes from the bacteria consuming readily decompose materials and the oxidation process heats up the compost pile from ambient air temperature. Bacteria consume carbon as a source of energy (to keep on eating) and nitrogen to build protein in their bodies (so they can grow and reproduce).