A thermocouple is a device that is made of two different metals that produce a small electrical charge when heated on one side. This small electrical charge switches on an electromagnet which opens a valve and allows the water or gas to flow through .