The invention concerns a medical device (10) designed for delivering a medical fluid or designed for controlling delivery of a medical fluid, and to a method of operating such a medical device. The medical device (10) comprises a user interface (12) associated with an electronic circuit (4) connected to a first port (31) and to a second port (31) of a controller (3). The electronic circuit (4) enables the controller (3) to detect actuation of the user interface (12). The controller is configured to execute the following sequence of steps: first step: configure (S4) the first port (31) as an output port and to apply (S5) a first signal to the first port; second step: to acquire (S6) a second signal from the second port (32); and third step: to determine (S8) on the basis of the second signal if a short circuit has occurred and to generate (S81) a short circuit alert signal if applicable.