A system for harvesting energy comprising: - an electrical machine including a first and a second structures (8, 10), movable with respect to each other, each of said first and second structures alternately forming the rotor or the stator of said electrical machine, the first structure being configured to be constrained to a rotating or rotating and translating element, so as to be driven in rotation by the rotating or rotating and translating element; - a counterweight coupled to the second structure so that the second structure is subject to a first gravitational torque; - a power transfer structure (18, 22), electrically connected to the first structure, configured to be connected to a load and adapted to transfer electrical power from the first structure to the load, in an electrically controllable manner, said electrical power transfer causing the application of a second torque on the second structure, the module of which is a function of the electrical power transferred, said second torque being balanced, when the counterweight is in an angular stability region, by said first torque so as to cause the generation of an electrical voltage (V g) in the first structure; - an angular position sensor constrained to the first structure and configured to provide a position signal ( ε ( t)) indicating the angular position of the counterweight, said angular position being referred to a local reference system (u, w) fixed to the first structure; and - an accelerometer constrained to the first structure and configured to provide an acceleration signal ( a ( t)) indicating an acceleration which affects the first structure, said acceleration being referred to the local reference system; said system for harvesting energy further comprising a control unit, which comprises: - a first stage configured to generate, based on the acceleration signal, a limit position signal ( ε lim ( t)) indicating an angular instability region (R-I), said angular instability region being referred to the local reference system and being such that, when the counterweight is within the angular instability region, the counterweight tends to rotate synchronously with the first structure; and - a second stage configured to control said power transfer structure based on the position signal and on the limit position signal, so as to modulate the transfer of electrical power to the load so as to prevent the counterweight from entering into the angular instability region. - an electrical machine including a first and a second structures (8, 10), movable with respect to each other, each of said first and second structures alternately forming the rotor or the stator of said electrical machine, the first structure being configured to be constrained to a rotating or rotating and translating element, so as to be driven in rotation by the rotating or rotating and translating element; - a counterweight coupled to the second structure so that the second structure is subject to a first gravitational torque; - a power transfer structure (18, 22), electrically connected to the first structure, configured to be connected to a load and adapted to transfer electrical power from the first structure to the load, in an electrically controllable manner, said electrical power transfer causing the application of a second torque on the second structure, the module of which is a function of the electrical power transferred, said second torque being balanced, when the counterweight is in an angular stability region, by said first torque so as to cause the generation of an electrical voltage (V g) in the first structure; - an angular position sensor constrained to the first structure and configured to provide a position signal ( ε ( t)) indicating the angular position of the counterweight, said angular position being referred to a local reference system (u, w) fixed to the first structure; and - an accelerometer constrained to the first structure and configured to provide an acceleration signal ( a ( t)) indicating an acceleration which affects the first structure, said acceleration being referred to the local reference system; - a first stage configured to generate, based on the acceleration signal, a limit position signal ( ε lim ( t)) indicating an angular instability region (R-I), said angular instability region being referred to the local reference system and being such that, when the counterweight is within the angular instability region, the counterweight tends to rotate synchronously with the first structure; and - a second stage configured to control said power transfer structure based on the position signal and on the limit position signal, so as to modulate the transfer of electrical power to the load so as to prevent the counterweight from entering into the angular instability region.