A machine (20) for the preparation of a cooled or heated product comprising: —a receiving seat (1) for accommodating a container (8) comprising at least part of the ingredients for the preparation of a product —a heat exchange element (1a) arranged to be in contact with an outer wall of the container (8), when the container (8) is placed in the receiving seat (1), and —temperature sensing means (100) arranged to measure the temperature at an outer wall of the container (8) when the container (8) is placed in the receiving seat (1), the temperature sensing means (100) comprising at least two temperature sensors, a primary temperature sensor (101) arranged to measure the temperature (TS1) in proximity to an outer wall of the container (8) and a secondary primary sensor (102) arranged to measure the temperature (TS2) in a position located in the heat path through which heat travels between the inside the container (8) and the external environment.