Disclosed is a method for measuring pressure in a container (1) filled or capable of being filled, using a pressure sensor (6) and a control unit (5). The filling or emptying is carried out under the control of the control unit (5) which receives as input signal, in addition to the pressure value (Ps) measured by the pressure sensor (6), a switching state (8) of a valve (4) controlled to fill or empty the container (1).