An electric rotary machine comprising a casing and a device for analysing the atmosphere inside and directly outside said casing of the electric rotary machine, said device being connected to said casing and comprising: - an explosion-proof box housing with an atmosphere inlet opening, said atmosphere inlet opening being connected with said casing of said electric rotary machine; - a suction pump for sucking in the atmosphere inside said casing of said electric machine, - a pump inlet duct to place said atmosphere inlet opening in fluid communication with said suction pump, - an atmosphere inlet duct connected with said atmosphere inlet opening of the housing of the device and with said casing of the electric rotary machine for placing the inside of said casing in fluid communication with said atmosphere inlet opening, - a second atmosphere inlet duct (CN1') suitable for placing the direct outside of said casing in fluid communication with said inlet opening, - transducer means suitable for measuring the percentage volume of at least one explosive compound present in said atmosphere sucked in by said pump, said transducer means being suitable for generating an electric signal proportional to the percentage volume of said explosive compound, - comparing means suitable for comparing said percentage volume of at least one explosive compound with a predetermined threshold percentage volume value, said comparing means being suitable for generating an alarm signal once said predetermined threshold value has been exceeded, - at least one filter arranged between said pump and said transducer means for filtering the condensation present in the fluid path between said suction pump and said transducer means, - a resistance temperature detector associated with said pump inlet duct and suitable for adjusting the temperature of said internal atmosphere sucked in by said suction pump, wherein: - said transducer means and said suction pump and said pump inlet duct are arranged in said housing and - said device comprises valve means in fluid communication with the atmosphere inlet opening and adapted to intercept the atmosphere flow flowing through the first and/or the second inlet conduit (CN1'). - an explosion-proof box housing with an atmosphere inlet opening, said atmosphere inlet opening being connected with said casing of said electric rotary machine; - a suction pump for sucking in the atmosphere inside said casing of said electric machine, - a pump inlet duct to place said atmosphere inlet opening in fluid communication with said suction pump, - an atmosphere inlet duct connected with said atmosphere inlet opening of the housing of the device and with said casing of the electric rotary machine for placing the inside of said casing in fluid communication with said atmosphere inlet opening, - a second atmosphere inlet duct (CN1') suitable for placing the direct outside of said casing in fluid communication with said inlet opening, - transducer means suitable for measuring the percentage volume of at least one explosive compound present in said atmosphere sucked in by said pump, said transducer means being suitable for generating an electric signal proportional to the percentage volume of said explosive compound, - comparing means suitable for comparing said percentage volume of at least one explosive compound with a predetermined threshold percentage volume value, said comparing means being suitable for generating an alarm signal once said predetermined threshold value has been exceeded, - at least one filter arranged between said pump and said transducer means for filtering the condensation present in the fluid path between said suction pump and said transducer means, - a resistance temperature detector associated with said pump inlet duct and suitable for adjusting the temperature of said internal atmosphere sucked in by said suction pump, wherein: - said transducer means and said suction pump and said pump inlet duct are arranged in said housing and - said device comprises valve means in fluid communication with the atmosphere inlet opening and adapted to intercept the atmosphere flow flowing through the first and/or the second inlet conduit (CN1').