Method for generating electric energy in a tyre