A method for measuring the rotational speed of a shaft of an aircraft engine from a square wave signal (Sc), said square wave signal being obtained from an alternating rotational speed detection signal (Sv) acquired at the terminals of a speed sensor including a phonic wheel driven in rotation by the shaft, said square wave signal (Sc) switching to a low voltage level (U 1), respectively to a high voltage level (U 2), in correspondence with the passage of the voltage of the alternating signal (Sv) below a restart threshold (U R), respectively above a reset threshold (U A), the method comprising the following steps: - recording, in a circular buffer type memory, a plurality of period samples (T 1,...,T n) of square wave signal (S c), - comparing each of said samples with a lower period limit (P t min) and an upper period limit (P t max), to determine samples called valid samples whose value is comprised between these two limits; - if the number of determined valid samples is greater than a first threshold (A 1), determining from said valid samples a useful period (P t) of the square wave signal (S c). the method being characterised in that at least on condition that the number of valid samples is less than the first threshold (A 1), the determination of the useful period (P t) of the square wave signal (Sc) implements the following steps: - calculating a plurality of sums of at least two consecutive samples (S 12,..., S 1n, S 23,..., S (n-1)n), - determining, among said plurality of sums, valid sums of consecutive samples, said valid sums being comprised between the lower period limit (P t min) and the upper period limit (P t max) - calculating the average of a set comprising valid period samples and valid sample sums, the useful period (P t) of the square wave signal being taken equal to said average. said square wave signal (Sc) switching to a low voltage level (U 1), respectively to a high voltage level (U 2), in correspondence with the passage of the voltage of the alternating signal (Sv) below a restart threshold (U R), respectively above a reset threshold (U A), the method comprising the following steps: - recording, in a circular buffer type memory, a plurality of period samples (T 1,...,T n) of square wave signal (S c), - comparing each of said samples with a lower period limit (P t min) and an upper period limit (P t max), to determine samples called valid samples whose value is comprised between these two limits; - if the number of determined valid samples is greater than a first threshold (A 1), determining from said valid samples a useful period (P t) of the square wave signal (S c). - recording, in a circular buffer type memory, a plurality of period samples (T 1,...,T n) of square wave signal (S c), - comparing each of said samples with a lower period limit (P t min) and an upper period limit (P t max), to determine samples called valid samples whose value is comprised between these two limits; - if the number of determined valid samples is greater than a first threshold (A 1), determining from said valid samples a useful period (P t) of the square wave signal (S c). the method being characterised in that at least on condition that the number of valid samples is less than the first threshold (A 1), the determination of the useful period (P t) of the square wave signal (Sc) implements the following steps: - calculating a plurality of sums of at least two consecutive samples (S 12,..., S 1n, S 23,..., S (n-1)n), - determining, among said plurality of sums, valid sums of consecutive samples, said valid sums being comprised between the lower period limit (P t min) and the upper period limit (P t max) - calculating the average of a set comprising valid period samples and valid sample sums, the useful period (P t) of the square wave signal being taken equal to said average. - calculating a plurality of sums of at least two consecutive samples (S 12,..., S 1n, S 23,..., S (n-1)n), - determining, among said plurality of sums, valid sums of consecutive samples, said valid sums being comprised between the lower period limit (P t min) and the upper period limit (P t max) - calculating the average of a set comprising valid period samples and valid sample sums, the useful period (P t) of the square wave signal being taken equal to said average.