Method to control the functioning of a heating apparatus which comprises a tank containing an electrolytic solution inside it, an electrode immersed in said electrolytic solution, an electric energy generator connected to said electrode and to said tank, and a controller provided with a measurer which measures at least one electric quantity which is established between said electrode and said tank, said method providing at least a step in which said electric energy generator is regulated to maintain, between said electrode and said tank, a protection potential with a first value (Vp), known and substantially constant over time, suitable to guarantee the protection of said tank from corrosion, characterized in that it comprises at least a step of detecting alternating currents of electric dispersions present in said tank, wherein said detection step comprises: - a first step in which said electric energy generator alternates cyclically, between said electrode and said tank, a variation of potential that varies between a first potential value and a second potential value, less than the value of said first potential, to establish said protection potential (Vp) in said electrolytic solution; - a second step in which said measurer performs a plurality of measurements of the currents circulating between said electrode and said tank; - a third step in which said controller verifies whether the values measured (Im) of the current circulating between said electrode and said tank remain variable around a balanced current with value (Ie) and, in this case, said controller recognizes a condition wherein there is an absence of stray currents; - a fourth step in which, if the values measured (Im) of the current circulating between said electrode and said tank are outside a balanced current with value (Ie), said controller verifies whether the frequency of the values of variation of said currents measured corresponds to the cyclicity of said stray currents and, in this case, recognizes the presence of electric dispersions deriving from alternating currents in said tank. - a first step in which said electric energy generator alternates cyclically, between said electrode and said tank, a variation of potential that varies between a first potential value and a second potential value, less than the value of said first potential, to establish said protection potential (Vp) in said electrolytic solution; - a second step in which said measurer performs a plurality of measurements of the currents circulating between said electrode and said tank; - a third step in which said controller verifies whether the values measured (Im) of the current circulating between said electrode and said tank remain variable around a balanced current with value (Ie) and, in this case, said controller recognizes a condition wherein there is an absence of stray currents; - a fourth step in which, if the values measured (Im) of the current circulating between said electrode and said tank are outside a balanced current with value (Ie), said controller verifies whether the frequency of the values of variation of said currents measured corresponds to the cyclicity of said stray currents and, in this case, recognizes the presence of electric dispersions deriving from alternating currents in said tank.